wallet-core: implement 'generateDepositGroupTxId' request
This commit is contained in:
parent
4fbeb06d4e
commit
c581cff749
@ -1737,6 +1737,10 @@ export interface CreateDepositGroupResponse {
|
||||
transactionId: string;
|
||||
}
|
||||
|
||||
export interface TxIdResponse {
|
||||
transactionId: string;
|
||||
}
|
||||
|
||||
export interface WithdrawUriInfoResponse {
|
||||
amount: AmountString;
|
||||
defaultExchangeBaseUrl?: string;
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
@ -495,6 +497,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.
|
||||
*
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user