diff options
author | Florian Dold <florian@dold.me> | 2023-06-26 12:57:00 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-06-26 12:57:00 +0200 |
commit | 4b61945f6b7b073acf5de825b7678bddc56ad5d0 (patch) | |
tree | ae4cc6d49ea934f34ce0a5b37c18975be24ff0fa | |
parent | eae357160760fba990f705b092e30a0eec6f7b29 (diff) | |
download | wallet-core-4b61945f6b7b073acf5de825b7678bddc56ad5d0.tar.xz |
wallet-core: return numCoins in checkPeerPullCredit response
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 6 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts | 6 |
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 index 52ce87725..3710e6d3c 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -2474,6 +2474,12 @@ export interface CheckPeerPullCreditResponse { exchangeBaseUrl: string; amountRaw: AmountString; amountEffective: AmountString; + + /** + * Number of coins that will be used, + * can be used by the UI to warn if excessively large. + */ + numCoins: number; } export interface InitiatePeerPullCreditRequest { exchangeBaseUrl?: string; diff --git a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts index 5baba8cdc..c0b728567 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer-pull-credit.ts @@ -649,10 +649,16 @@ export async function checkPeerPullPaymentInitiation( logger.trace(`got withdrawal info`); + let numCoins = 0; + for (let i = 0; i < wi.selectedDenoms.selectedDenoms.length; i++) { + numCoins += wi.selectedDenoms.selectedDenoms[i].count; + } + return { exchangeBaseUrl: exchangeUrl, amountEffective: wi.withdrawalAmountEffective, amountRaw: req.amount, + numCoins, }; } |