diff options
author | Florian Dold <florian@dold.me> | 2023-07-06 20:17:59 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-07-06 20:17:59 +0200 |
commit | 8b06874f42715b0397a6735ff330e5f75eb0cb86 (patch) | |
tree | 608049f43d04fc375fe9e3f6599c18d4296fb479 /packages | |
parent | d98f048fd65c46cd774eabdef8599efb75153ac3 (diff) | |
download | wallet-core-8b06874f42715b0397a6735ff330e5f75eb0cb86.tar.xz |
wallet-core: support passing transactionId to confirmPay
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 9 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/withdraw.ts | 4 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 15 |
3 files changed, 25 insertions, 3 deletions
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 7926cdd4f..f2384ad8e 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -1751,14 +1751,19 @@ export const codecForPreparePayTemplateRequest = .build("PreparePayTemplate"); export interface ConfirmPayRequest { - proposalId: string; + /** + * @deprecated use transactionId instead + */ + proposalId?: string; + transactionId?: string; sessionId?: string; forcedCoinSel?: ForcedCoinSel; } export const codecForConfirmPayRequest = (): Codec<ConfirmPayRequest> => buildCodecForObject<ConfirmPayRequest>() - .property("proposalId", codecForString()) + .property("proposalId", codecOptional(codecForString())) + .property("transactionId", codecOptional(codecForString())) .property("sessionId", codecOptional(codecForString())) .property("forcedCoinSel", codecForAny()) .build("ConfirmPay"); diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index f972d3cb1..a56a1a100 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -972,6 +972,10 @@ async function processPlanchetExchangeBatchRequest( responses.ev_sigs.push(r); responseCoinIdxs.push(requestCoinIdxs[i]); } catch (e) { + if (e instanceof TalerError) { + logger.warn(`withdrawing planchet failed: ${j2s(e.errorDetail)}`); + logger.warn(`planchet denom pub hash: ${batchReq.planchets[i].denom_pub_hash}`); + } await storeCoinError(e, requestCoinIdxs[i]); } } diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index ca86cbb14..e457ba003 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -1260,7 +1260,20 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( } case WalletApiOperation.ConfirmPay: { const req = codecForConfirmPayRequest().decode(payload); - return await confirmPay(ws, req.proposalId, req.sessionId); + let proposalId; + if (req.proposalId) { + // legacy client support + proposalId = req.proposalId; + } else if (req.transactionId) { + const txIdParsed = parseTransactionIdentifier(req.transactionId); + if (txIdParsed?.tag != TransactionType.Payment) { + throw Error("payment transaction ID required"); + } + proposalId = txIdParsed.proposalId; + } else { + throw Error("transactionId or (deprecated) proposalId required"); + } + return await confirmPay(ws, proposalId, req.sessionId); } case WalletApiOperation.AbortTransaction: { const req = codecForAbortTransaction().decode(payload); |