wallet-core: report number of coins in withdrawal details

This commit is contained in:
Florian Dold 2023-05-24 12:58:33 +02:00
parent ea953f2b77
commit 4627c0781c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 12 additions and 0 deletions

View File

@ -1134,6 +1134,13 @@ export interface ManualWithdrawalDetails {
*/ */
amountEffective: AmountString; amountEffective: AmountString;
/**
* Number of coins that would be used for withdrawal.
*
* The UIs should warn if this number is too high (rougly at >100).
*/
numCoins: number;
/** /**
* Ways to pay the exchange. * Ways to pay the exchange.
*/ */

View File

@ -1107,12 +1107,17 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
Amounts.parseOrThrow(req.amount), Amounts.parseOrThrow(req.amount),
req.restrictAge, req.restrictAge,
); );
let numCoins = 0;
for (const x of wi.selectedDenoms.selectedDenoms) {
numCoins += x.count;
}
const resp: ManualWithdrawalDetails = { const resp: ManualWithdrawalDetails = {
amountRaw: req.amount, amountRaw: req.amount,
amountEffective: Amounts.stringify(wi.selectedDenoms.totalCoinValue), amountEffective: Amounts.stringify(wi.selectedDenoms.totalCoinValue),
paytoUris: wi.exchangePaytoUris, paytoUris: wi.exchangePaytoUris,
tosAccepted: wi.termsOfServiceAccepted, tosAccepted: wi.termsOfServiceAccepted,
ageRestrictionOptions: wi.ageRestrictionOptions, ageRestrictionOptions: wi.ageRestrictionOptions,
numCoins,
}; };
return resp; return resp;
} }