commit 5b1fa298c12542b51ba4b61c0429ecf1d0eb9e84
parent 193eeea9f7a230f88a88d985b1ec30b0fca8a329
Author: Florian Dold <florian@dold.me>
Date: Wed, 17 Sep 2025 02:41:36 +0200
tops blunder fixup WIP
Diffstat:
2 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
@@ -3704,10 +3704,7 @@ async function fixup20250916TopsBlunder(
let numActiveDenoms = 0;
if (wg.denomsSel?.selectedDenoms) {
for (const sd of wg.denomsSel.selectedDenoms) {
- if (sd.skip) {
- continue;
- }
- numActiveDenoms++;
+ numActiveDenoms += sd.count - (sd.skip ?? 0);
}
}
if (numActiveDenoms > 0) {
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
@@ -2274,32 +2274,33 @@ async function processQueryReserve(
// See https://bugs.taler.net/n/9732
// We also re-select when the initial selection had zero coins
// (skipped denoms are not counted).
- let shouldReselectDenoms = false;
- if (
+ let amountChanged =
Amounts.cmp(
result.response.balance,
withdrawalGroup.denomsSel.totalWithdrawCost,
- ) === -1 ||
- withdrawalGroup.denomsSel.selectedDenoms.filter((x) => !x.skip).length === 0
- ) {
- shouldReselectDenoms = true;
- }
+ ) === -1;
- const exchangeBaseUrl = withdrawalGroup.exchangeBaseUrl;
- const currency = Amounts.currencyOf(withdrawalGroup.instructedAmount);
+ let numActiveDenoms = 0;
+ for (const sd of withdrawalGroup.denomsSel.selectedDenoms) {
+ numActiveDenoms += sd.count - (sd.skip ?? 0);
+ }
+ const selectionBad = numActiveDenoms > 0;
- // If we re-select denominations, make sure we have current
- // information about the exchange.
- if (shouldReselectDenoms) {
- // FIXME: Would be better if we transition to a new state here.
- // Or at least set some lastError (lastWarning?) state.
- await fetchFreshExchange(wex, withdrawalGroup.exchangeBaseUrl);
+ if (amountChanged || selectionBad) {
+ // If we change the denom selection, make sure we have
+ // fresh info about the exchange.
+ await fetchFreshExchange(wex, withdrawalGroup.exchangeBaseUrl, {
+ forceUpdate: selectionBad,
+ });
await updateWithdrawalDenomsForExchange(
wex,
withdrawalGroup.exchangeBaseUrl,
);
}
+ const exchangeBaseUrl = withdrawalGroup.exchangeBaseUrl;
+ const currency = Amounts.currencyOf(withdrawalGroup.instructedAmount);
+
const transitionResult = await ctx.transition(
{
extraStores: ["denominations", "bankAccountsV2", "planchets"],
@@ -2321,7 +2322,7 @@ async function processQueryReserve(
if (lastOrigin != null && !externalConfirmation) {
await storeKnownBankAccount(tx, currency, lastOrigin);
}
- if (shouldReselectDenoms) {
+ if (amountChanged) {
const planchetKeys = await tx.planchets.indexes.byGroup.getAllKeys(
wg.withdrawalGroupId,
);