taler-typescript-core

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

commit 615af373158029b1308fc131358955e7de34f9ae
parent c2d7afb6b12d09b6317592eea09932c63d9061bb
Author: Florian Dold <dold@taler.net>
Date:   Wed, 22 Jul 2026 15:37:22 +0200

wallet: count the exchange public key balance by its own criterion

The receiver-*-acceptable balances are each defined as the part of the
material balance that satisfies one criterion, but the public key one was
only counted when the URL or the auditor matched as well, so a coin accepted
solely by master public key never reached it.

The mismatch hint derived from it now requires URL-accepted balance that is
not public-key-accepted, which is the situation its description names.

Diffstat:
Mpackages/taler-wallet-core/src/balance.ts | 16++++++++++------
Mpackages/taler-wallet-core/src/coinSelection.ts | 6+++++-
2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/packages/taler-wallet-core/src/balance.ts b/packages/taler-wallet-core/src/balance.ts @@ -974,6 +974,16 @@ export async function getPaymentBalanceDetailsInTx( d.balanceAgeAcceptable, coinAmount, ).amount; + // Each receiver-*-acceptable balance is defined by its own criterion, so + // the public key one must not depend on the URL or the auditor matching + // as well. The other two are only reached when their own criterion + // holds, which already implies merchantExchangeAcceptable. + if (merchantExchangePubAcceptable) { + d.balanceReceiverExchangePubAcceptable = Amounts.add( + d.balanceReceiverExchangePubAcceptable, + coinAmount, + ).amount; + } if (merchantExchangeAcceptable) { d.balanceReceiverAcceptable = Amounts.add( d.balanceReceiverAcceptable, @@ -991,12 +1001,6 @@ export async function getPaymentBalanceDetailsInTx( coinAmount, ).amount; } - if (merchantExchangePubAcceptable) { - d.balanceReceiverExchangePubAcceptable = Amounts.add( - d.balanceReceiverExchangePubAcceptable, - coinAmount, - ).amount; - } if (merchantExchangeAuditorAcceptable) { d.balanceReceiverAuditorUrlAcceptable = Amounts.add( d.balanceReceiverAuditorUrlAcceptable, diff --git a/packages/taler-wallet-core/src/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts @@ -590,11 +590,15 @@ export async function reportInsufficientBalanceDetails( exchDet.maxMerchantEffectiveDepositAmount, ), missingGlobalFees, + // Balance at an exchange the merchant accepts by URL but whose master + // public key it does not accept, i.e. the key the merchant configured + // differs from the one the coins were issued under. The reverse case + // is a URL the merchant does not list, not a key mismatch. exchangeMasterPubMismatch: Amounts.cmp( exchDet.balanceReceiverExchangeUrlAcceptable, exchDet.balanceReceiverExchangePubAcceptable, - ) != 0, + ) > 0, causeHint: !!wex.ws.devExperimentState.merchantDepositInsufficient ? InsufficientBalanceHint.MerchantDepositInsufficient : getHint(req, exchDet),