diff options
author | Florian Dold <florian@dold.me> | 2024-04-04 22:05:52 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-04-04 22:05:52 +0200 |
commit | e5e74328640a6a66a6d32a0abec2f185a72c6a65 (patch) | |
tree | b259b5f94b617d90060a567e5e85d4ab0793a80d /packages/taler-wallet-core | |
parent | 2f176e23b5754e70274feacf31572cdcdd813ae3 (diff) |
wallet-core: remove bogus code for denom re-selection in refresh
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/refresh.ts | 65 |
1 files changed, 5 insertions, 60 deletions
diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts index aece14e55..e6013938d 100644 --- a/packages/taler-wallet-core/src/refresh.ts +++ b/packages/taler-wallet-core/src/refresh.ts @@ -95,7 +95,6 @@ import { WalletDbReadWriteTransaction, } from "./db.js"; import { selectWithdrawalDenominations } from "./denomSelection.js"; -import { fetchFreshExchange } from "./exchanges.js"; import { constructTransactionIdentifier, notifyTransition, @@ -105,10 +104,7 @@ import { getDenomInfo, WalletExecutionContext, } from "./wallet.js"; -import { - getCandidateWithdrawalDenomsTx, - updateWithdrawalDenoms, -} from "./withdraw.js"; +import { getCandidateWithdrawalDenomsTx } from "./withdraw.js"; const logger = new Logger("refresh.ts"); @@ -604,62 +600,10 @@ async function refreshMelt( return; } - const exchangeBaseUrl = oldCoin.exchangeBaseUrl; - const currency = Amounts.currencyOf(oldDenom.value); - if (resp.status === HttpStatusCode.Gone) { const errDetail = await readTalerErrorResponse(resp); - switch (errDetail.code) { - case TalerErrorCode.EXCHANGE_GENERIC_DENOMINATION_REVOKED: - case TalerErrorCode.EXCHANGE_GENERIC_DENOMINATION_EXPIRED: { - logger.warn(`refresh ${transactionId} requires redenomination`); - await fetchFreshExchange(wex, exchangeBaseUrl, { - forceUpdate: true, - }); - await updateWithdrawalDenoms(wex, exchangeBaseUrl); - await wex.db.runReadWriteTx( - ["refreshGroups", "refreshSessions", "denominations"], - async (tx) => { - const rg = await tx.refreshGroups.get(refreshGroupId); - if (!rg) { - return; - } - if (rg.timestampFinished) { - return; - } - const rs = await tx.refreshSessions.get([ - refreshGroupId, - coinIndex, - ]); - if (!rs) { - return; - } - if (rs.norevealIndex !== undefined) { - return; - } - const candidates = await getCandidateWithdrawalDenomsTx( - wex, - tx, - exchangeBaseUrl, - currency, - ); - // We can just replace the existing coin selection, because melt is atomic, - // and thus it's not possible that some denoms in the selection were already - // withdrawn. - const input = Amounts.parseOrThrow(rg.inputPerCoin[rs.coinIndex]); - const newSel = selectWithdrawalDenominations(input, candidates); - rs.amountRefreshOutput = newSel.totalCoinValue; - // FIXME: This is wrong! When denoms are re-selected, the melt commitment breaks. - rs.newDenoms = newSel.selectedDenoms.map((x) => ({ - count: x.count, - denomPubHash: x.denomPubHash, - })); - await tx.refreshSessions.put(rs); - }, - ); - break; - } - } + + // FIXME(#7935): Remove coin from refresh group, but allow the whole group to finish. throwUnexpectedRequestError(resp, errDetail); } @@ -695,7 +639,8 @@ async function refreshMelt( const historyJson = await historyResp.json(); logger.info(`coin history: ${j2s(historyJson)}`); - // FIXME: Before failing and re-trying, analyse response and adjust amount + // FIXME(#7935): Before failing and re-trying, analyse response and adjust amount. + // If response seems wrong, report to auditor (in the future!). } const meltResponse = await readSuccessResponseJsonOrThrow( |