commit 506b5b61a8563e724bd02a207e072f2c594dcdd6
parent 3e4377a6abe11b1de27b7e8dc6e0596f46e9b8b2
Author: Florian Dold <florian@dold.me>
Date: Mon, 20 Oct 2025 17:08:59 +0200
wallet-core: refactor, adapt to changed withdrawal error response
Diffstat:
1 file changed, 29 insertions(+), 27 deletions(-)
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
@@ -1839,34 +1839,33 @@ async function processPlanchetExchangeBatchRequest(
timeout: Duration.fromSpec({ seconds: 40 }),
});
if (resp.status === HttpStatusCode.UnavailableForLegalReasons) {
- await transitionKycRequired(
- wex,
- withdrawalGroup,
- resp,
- 0,
- requestCoinIdxs,
- );
- return {
- batchResp: { ev_sigs: [] },
- coinIdxs: [],
- };
- }
- if (resp.status === HttpStatusCode.Gone) {
- const e = await readTalerErrorResponse(resp);
- // FIXME: Store in place of the planchet that is actually affected!
- await storeCoinError(e, requestCoinIdxs[0]);
- return {
- batchResp: { ev_sigs: [] },
- coinIdxs: [],
- };
}
- if (resp.status === HttpStatusCode.InternalServerError) {
- const e = await readTalerErrorResponse(resp);
- await storeCoinError(e, requestCoinIdxs[0]);
- return {
- batchResp: { ev_sigs: [] },
- coinIdxs: [],
- };
+ switch (resp.status) {
+ case HttpStatusCode.UnavailableForLegalReasons: {
+ await transitionKycRequired(
+ wex,
+ withdrawalGroup,
+ resp,
+ 0,
+ requestCoinIdxs,
+ );
+ return {
+ batchResp: { ev_sigs: [] },
+ coinIdxs: [],
+ };
+ }
+ case HttpStatusCode.Gone:
+ case HttpStatusCode.InternalServerError:
+ case HttpStatusCode.NotFound: {
+ // The concrete handling of the error
+ // happens in the caller.
+ const e = await readTalerErrorResponse(resp);
+ await storeCoinError(e, requestCoinIdxs[0]);
+ return {
+ batchResp: { ev_sigs: [] },
+ coinIdxs: [],
+ };
+ }
}
const r = await readSuccessResponseJsonOrThrow(
resp,
@@ -1877,6 +1876,7 @@ async function processPlanchetExchangeBatchRequest(
batchResp: r,
};
} catch (e) {
+ // Network error or unexpected response.
const errDetail = getErrorDetailFromException(e);
// We don't know which coin is affected, so we store the error
// with the first coin of the batch.
@@ -2757,6 +2757,7 @@ async function processWithdrawalGroupPendingReady(
case TalerErrorCode.EXCHANGE_GENERIC_DENOMINATION_EXPIRED:
case TalerErrorCode.EXCHANGE_GENERIC_DENOMINATION_REVOKED:
case TalerErrorCode.EXCHANGE_GENERIC_KEYS_MISSING:
+ case TalerErrorCode.EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN:
redenomRequired = true;
return;
}
@@ -2764,6 +2765,7 @@ async function processWithdrawalGroupPendingReady(
});
if (redenomRequired) {
+ logger.warn(`redenomination required for withdrawal ${withdrawalGroupId}`);
return startRedenomination(ctx, exchangeBaseUrl);
}