diff options
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 4 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/deposits.ts | 9 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet-api-types.ts | 16 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/wallet.ts | 2 |
4 files changed, 31 insertions, 0 deletions
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index c75ca7fdd..7a2442e2d 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -1737,6 +1737,10 @@ export interface CreateDepositGroupResponse { transactionId: string; } +export interface TxIdResponse { + transactionId: string; +} + export interface WithdrawUriInfoResponse { amount: AmountString; defaultExchangeBaseUrl?: string; diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index 9abec89bf..d1dbf5f53 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -75,6 +75,7 @@ import { getTotalPaymentCost, } from "./pay-merchant.js"; import { selectPayCoinsNew } from "../util/coinSelection.js"; +import { constructTransactionIdentifier } from "./transactions.js"; /** * Logger. @@ -571,6 +572,14 @@ export async function prepareDepositGroup( }; } +export function generateDepositGroupTxId(): string { + const depositGroupId = encodeCrock(getRandomBytes(32)); + return constructTransactionIdentifier({ + tag: TransactionType.Deposit, + depositGroupId: depositGroupId, + }); +} + export async function createDepositGroup( ws: InternalWalletState, req: CreateDepositGroupRequest, diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 93c8b136c..2ac649f59 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -109,6 +109,7 @@ import { WithdrawUriInfoResponse, ValidateIbanRequest, ValidateIbanResponse, + TxIdResponse, } from "@gnu-taler/taler-util"; import { WalletContractData } from "./db.js"; import { @@ -177,6 +178,7 @@ export enum WalletApiOperation { DeleteTransaction = "deleteTransaction", RetryTransaction = "retryTransaction", ListCurrencies = "listCurrencies", + GenerateDepositGroupTxId = "generateDepositGroupTxId", CreateDepositGroup = "createDepositGroup", SetWalletDeviceId = "setWalletDeviceId", ExportBackupPlain = "exportBackupPlain", @@ -496,6 +498,19 @@ export type ListCurrenciesOp = { // group: Deposits /** + * Generate a fresh transaction ID for a deposit group. + * + * The resulting transaction ID can be specified when creating + * a deposit group, so that the client can already start waiting for notifications + * on that specific deposit group before the GreateDepositGroup request returns. + */ +export type GenerateDepositGroupTxIdOp = { + op: WalletApiOperation.GenerateDepositGroupTxId; + request: EmptyObject; + response: TxIdResponse; +}; + +/** * Create a new deposit group. * * Deposit groups are used to deposit multiple coins to a bank @@ -909,6 +924,7 @@ export type WalletOperations = { [WalletApiOperation.GetExchangeTos]: GetExchangeTosOp; [WalletApiOperation.GetExchangeDetailedInfo]: GetExchangeDetailedInfoOp; [WalletApiOperation.PrepareDeposit]: PrepareDepositOp; + [WalletApiOperation.GenerateDepositGroupTxId]: GenerateDepositGroupTxIdOp; [WalletApiOperation.CreateDepositGroup]: CreateDepositGroupOp; [WalletApiOperation.SetWalletDeviceId]: SetWalletDeviceIdOp; [WalletApiOperation.ExportBackupPlain]: ExportBackupPlainOp; diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index a7fbbb6b5..5a0a8fe77 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -1348,6 +1348,8 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>( const req = codecForPrepareDepositRequest().decode(payload); return await prepareDepositGroup(ws, req); } + case WalletApiOperation.GenerateDepositGroupTxId: + return generateDepositGroupTxId(); case WalletApiOperation.CreateDepositGroup: { const req = codecForCreateDepositGroupRequest().decode(payload); return await createDepositGroup(ws, req); |