commit 7a22d181ff6eac813dcb78704b5a780f09dc4c00 parent 4e241673715eaf71d10c6c1f035667ddb123d776 Author: Florian Dold <dold@taler.net> Date: Wed, 22 Jul 2026 00:32:53 +0200 wallet: preselect only a payable contract choice The search for the cheapest payable choice started from the first choice without testing whether it could be paid, and nothing cheaper than it could win, so an unpayable first choice was offered as the default and a payable one was passed over. No default is reported when none is payable. Diffstat:
| M | packages/taler-wallet-core/src/pay-merchant.ts | | | 13 | +++++++++---- |
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -2661,13 +2661,18 @@ async function calculateDefaultChoice( } // If there are more, choose the payable one with lowest amount. - var cheapestPayableIndex = 0; - var cheapestPayableChoice = contractTerms.choices[0]; - for (let i = 1; i < contractTerms.choices.length; i++) { + let cheapestPayableIndex: number | undefined; + let cheapestPayableChoice: + | (typeof contractTerms.choices)[number] + | undefined; + for (let i = 0; i < contractTerms.choices.length; i++) { const choice = contractTerms.choices[i]; const details = choiceDetails[i]; + if (details.status !== ChoiceSelectionDetailType.PaymentPossible) { + continue; + } if ( - details.status === ChoiceSelectionDetailType.PaymentPossible && + cheapestPayableChoice == null || Amounts.cmp(choice.amount, cheapestPayableChoice.amount) < 0 ) { cheapestPayableIndex = i;