taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 74eead878dbb935d1f3dd35941e15baadc687c76
parent abc9cad5358c3361b10112cd513f37df8fca249a
Author: Florian Dold <dold@taler.net>
Date:   Wed, 22 Jul 2026 10:57:04 +0200

wallet: skip unspendable coins in the maximum deposit amount

Coins whose deposit fee exceeds their value were counted towards the maximum
although selectGreedy refuses to select them.

Diffstat:
Mpackages/taler-wallet-core/src/coinSelection.ts | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/packages/taler-wallet-core/src/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts @@ -1388,6 +1388,13 @@ function getMaxDepositAmountForAvailableCoins( let fees = Amounts.zeroOfCurrency(req.currency); for (const cc of candidateRes.coinAvailability) { + // Don't count a coin if depositing it is more expensive than the amount + // it would give the merchant. This is the same rule selectGreedy uses, + // so counting it here would promise an amount that can't be selected. + if (Amounts.cmp(cc.feeDeposit, cc.value) > 0) { + continue; + } + if (!wireFeeCoveredForExchange.has(cc.exchangeBaseUrl)) { const wireFee = candidateRes.currentWireFeePerExchange[cc.exchangeBaseUrl];