diff options
author | Florian Dold <florian@dold.me> | 2024-06-28 11:48:54 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-06-28 11:48:54 +0200 |
commit | ad98210b79f350de631e593ef520f5a57a44812e (patch) | |
tree | 48bafb0531c709b45dde86213c635fbf14426473 /packages/taler-wallet-core/src | |
parent | 64cb9fcf0da36d5ced33bedc382faa9a64e84719 (diff) |
wallet-core: support externally confirmed bank-integrated withdrawals
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 6 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/transactions.ts | 5 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/withdraw.ts | 36 |
3 files changed, 29 insertions, 18 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 3438cbdc7..d28566910 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -400,6 +400,8 @@ export interface ReserveBankInfo { wireTypes: string[] | undefined; currency: string | undefined; + + externalConfirmation?: boolean; } /** @@ -907,8 +909,8 @@ export interface CoinRecord { /** * History item for a coin. - * - * DB-specific format, + * + * DB-specific format, */ export type DbWalletCoinHistoryItem = | { diff --git a/packages/taler-wallet-core/src/transactions.ts b/packages/taler-wallet-core/src/transactions.ts index 8268828be..0649f9ce2 100644 --- a/packages/taler-wallet-core/src/transactions.ts +++ b/packages/taler-wallet-core/src/transactions.ts @@ -768,7 +768,10 @@ function buildTransactionForBankIntegratedWithdraw( confirmed: wg.wgInfo.bankInfo.timestampBankConfirmed ? true : false, exchangeCreditAccountDetails: wg.wgInfo.exchangeCreditAccounts, reservePub: wg.reservePub, - bankConfirmationUrl: wg.wgInfo.bankInfo.confirmUrl, + bankConfirmationUrl: wg.wgInfo.bankInfo.externalConfirmation + ? undefined + : wg.wgInfo.bankInfo.confirmUrl, + externalConfirmation: wg.wgInfo.bankInfo.externalConfirmation, reserveIsReady: wg.status === WithdrawalGroupStatus.Done || wg.status === WithdrawalGroupStatus.PendingReady, diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts index 087db7938..083fa2a2d 100644 --- a/packages/taler-wallet-core/src/withdraw.ts +++ b/packages/taler-wallet-core/src/withdraw.ts @@ -64,6 +64,7 @@ import { TalerErrorCode, TalerErrorDetail, TalerPreciseTimestamp, + TalerUriAction, Transaction, TransactionAction, TransactionIdStr, @@ -95,6 +96,7 @@ import { getRandomBytes, j2s, makeErrorDetail, + parseTalerUri, parseWithdrawUri, } from "@gnu-taler/taler-util"; import { @@ -3064,6 +3066,17 @@ export async function prepareBankIntegratedWithdrawal( }, ); + const parsedUri = parseTalerUri(req.talerWithdrawUri); + if (parsedUri?.type !== TalerUriAction.Withdraw) { + throw TalerError.fromDetail(TalerErrorCode.WALLET_TALER_URI_MALFORMED, {}); + } + + const externalConfirmation = parsedUri.externalConfirmation; + + logger.info( + `creating withdrawal with externalConfirmation=${externalConfirmation}`, + ); + const withdrawInfo = await getBankWithdrawalInfo( wex.http, req.talerWithdrawUri, @@ -3099,6 +3112,7 @@ export async function prepareBankIntegratedWithdrawal( timestampReserveInfoPosted: undefined, wireTypes: withdrawInfo.wireTypes, currency: withdrawInfo.currency, + externalConfirmation, }, }, reserveStatus: WithdrawalGroupStatus.DialogProposed, @@ -3220,22 +3234,14 @@ export async function confirmWithdrawal( rec.denomsSel = initalDenoms; rec.rawWithdrawalAmount = initalDenoms.totalWithdrawCost; rec.effectiveWithdrawalAmount = initalDenoms.totalCoinValue; - - rec.wgInfo = { - withdrawalType: WithdrawalRecordType.BankIntegrated, - exchangeCreditAccounts: withdrawalAccountList, - bankInfo: { - exchangePaytoUri, - talerWithdrawUri, - confirmUrl: confirmUrl, - timestampBankConfirmed: undefined, - timestampReserveInfoPosted: undefined, - wireTypes: bankWireTypes, - currency: bankCurrency, - }, - }; - pending = true; + checkDbInvariant( + rec.wgInfo.withdrawalType === WithdrawalRecordType.BankIntegrated, + "withdrawal type mismatch", + ); + rec.wgInfo.exchangeCreditAccounts = withdrawalAccountList; + rec.wgInfo.bankInfo.exchangePaytoUri = exchangePaytoUri; rec.status = WithdrawalGroupStatus.PendingRegisteringBank; + pending = true; return TransitionResult.transition(rec); } default: { |