commit a1c5f00aedb75e5e2deb6b12c3cfb06eefb355e4
parent d040c3b861cb6c7f79606d9d46f79db15c6d2e4c
Author: Florian Dold <florian@dold.me>
Date: Tue, 6 Dec 2022 19:41:32 +0100
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.
Diffstat:
1 file 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
@@ -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;