commit 4627c0781c982421585e4adf9e3320b56f644965
parent ea953f2b772b07780b94daecdefde6cd253a7e90
Author: Florian Dold <florian@dold.me>
Date: Wed, 24 May 2023 12:58:33 +0200
wallet-core: report number of coins in withdrawal details
Diffstat:
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts
@@ -1135,6 +1135,13 @@ export interface ManualWithdrawalDetails {
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.
*/
paytoUris: string[];
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
@@ -1107,12 +1107,17 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
Amounts.parseOrThrow(req.amount),
req.restrictAge,
);
+ let numCoins = 0;
+ for (const x of wi.selectedDenoms.selectedDenoms) {
+ numCoins += x.count;
+ }
const resp: ManualWithdrawalDetails = {
amountRaw: req.amount,
amountEffective: Amounts.stringify(wi.selectedDenoms.totalCoinValue),
paytoUris: wi.exchangePaytoUris,
tosAccepted: wi.termsOfServiceAccepted,
ageRestrictionOptions: wi.ageRestrictionOptions,
+ numCoins,
};
return resp;
}