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.
This commit is contained in:
Florian Dold 2022-12-06 19:41:32 +01:00
parent d040c3b861
commit a1c5f00aed
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -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;