diff options
author | Florian Dold <florian@dold.me> | 2022-12-06 19:41:32 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-12-06 19:45:04 +0100 |
commit | a1c5f00aedb75e5e2deb6b12c3cfb06eefb355e4 (patch) | |
tree | bf232ebe2ba5760e1ccceed9efab5206a49cb944 | |
parent | d040c3b861cb6c7f79606d9d46f79db15c6d2e4c (diff) |
wallet: fix p2p coin selection
The p2p coin selection didn't work properly when all available denoms
are needed.
Thanks to Florian Jung for finding the issue and suggesting a fix.
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts b/packages/taler-wallet-core/src/operations/pay-peer.ts index f31a7f37c..cc859f243 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer.ts @@ -191,12 +191,7 @@ export async function selectPeerCoins( }[] = []; for (const coin of coinInfos) { if (Amounts.cmp(amountAcc, instructedAmount) >= 0) { - const res: PeerCoinSelection = { - exchangeBaseUrl: exch.baseUrl, - coins: resCoins, - depositFees: depositFeesAcc, - }; - return res; + break; } const gap = Amounts.add( coin.feeDeposit, @@ -217,6 +212,14 @@ export async function selectPeerCoins( ageCommitmentProof: coin.ageCommitmentProof, }); } + if (Amounts.cmp(amountAcc, instructedAmount) >= 0) { + const res: PeerCoinSelection = { + exchangeBaseUrl: exch.baseUrl, + coins: resCoins, + depositFees: depositFeesAcc, + }; + return res; + } continue; } return undefined; |