taler-typescript-core

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

commit 7178dc4415e864374dee3cb0d4a19b478379b0c3
parent 648e4324daca08678c33e8e422dc2413109ab93d
Author: Iván Ávalos <avalos@disroot.org>
Date:   Wed,  3 Dec 2025 09:55:36 +0100

wallet-core: skip withdrawal coin selection when amount is zero

Diffstat:
Mpackages/taler-wallet-core/src/withdraw.ts | 49++++++++++++++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 17 deletions(-)

diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts @@ -2951,28 +2951,43 @@ export async function getExchangeWithdrawalInfo( withdrawalType, }); - logger.trace("updating withdrawal denoms"); - await updateWithdrawalDenomsForExchange(wex, exchangeBaseUrl); + let candidateDenoms: DenominationRecord[]; + let selectedDenoms: DenomSelectionState; - wex.cancellationToken.throwIfCancelled(); + if (Amounts.isNonZero(instructedAmount)) { + logger.trace("updating withdrawal denoms"); + await updateWithdrawalDenomsForExchange(wex, exchangeBaseUrl); - logger.trace("getting candidate denoms"); - const candidateDenoms = await getWithdrawableDenoms( - wex, - exchangeBaseUrl, - instructedAmount.currency, - ); + wex.cancellationToken.throwIfCancelled(); - wex.cancellationToken.throwIfCancelled(); + logger.trace("getting candidate denoms"); + candidateDenoms = await getWithdrawableDenoms( + wex, + exchangeBaseUrl, + instructedAmount.currency, + ); - logger.trace("selecting withdrawal denoms"); - // FIXME: Why not in a transaction? - const selectedDenoms = selectWithdrawalDenominations( - instructedAmount, - candidateDenoms, - ); + wex.cancellationToken.throwIfCancelled(); + + logger.trace("selecting withdrawal denoms"); + // FIXME: Why not in a transaction? + selectedDenoms = selectWithdrawalDenominations( + instructedAmount, + candidateDenoms, + ); - logger.trace("selection done"); + logger.trace("selection done"); + } else { + candidateDenoms = []; + selectedDenoms = { + totalCoinValue: Amounts.stringify(instructedAmount), + totalWithdrawCost: Amounts.stringify(instructedAmount), + selectedDenoms: [], + hasDenomWithAgeRestriction: false, + }; + + logger.trace("selection skipped, amount is zero"); + } const exchangeWireAccounts: string[] = [];