wallet-core: implement 'generateDepositGroupTxId' request
This commit is contained in:
parent
4fbeb06d4e
commit
c581cff749
@ -1737,6 +1737,10 @@ export interface CreateDepositGroupResponse {
|
|||||||
transactionId: string;
|
transactionId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TxIdResponse {
|
||||||
|
transactionId: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface WithdrawUriInfoResponse {
|
export interface WithdrawUriInfoResponse {
|
||||||
amount: AmountString;
|
amount: AmountString;
|
||||||
defaultExchangeBaseUrl?: string;
|
defaultExchangeBaseUrl?: string;
|
||||||
|
@ -75,6 +75,7 @@ import {
|
|||||||
getTotalPaymentCost,
|
getTotalPaymentCost,
|
||||||
} from "./pay-merchant.js";
|
} from "./pay-merchant.js";
|
||||||
import { selectPayCoinsNew } from "../util/coinSelection.js";
|
import { selectPayCoinsNew } from "../util/coinSelection.js";
|
||||||
|
import { constructTransactionIdentifier } from "./transactions.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger.
|
* 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(
|
export async function createDepositGroup(
|
||||||
ws: InternalWalletState,
|
ws: InternalWalletState,
|
||||||
req: CreateDepositGroupRequest,
|
req: CreateDepositGroupRequest,
|
||||||
|
@ -109,6 +109,7 @@ import {
|
|||||||
WithdrawUriInfoResponse,
|
WithdrawUriInfoResponse,
|
||||||
ValidateIbanRequest,
|
ValidateIbanRequest,
|
||||||
ValidateIbanResponse,
|
ValidateIbanResponse,
|
||||||
|
TxIdResponse,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { WalletContractData } from "./db.js";
|
import { WalletContractData } from "./db.js";
|
||||||
import {
|
import {
|
||||||
@ -177,6 +178,7 @@ export enum WalletApiOperation {
|
|||||||
DeleteTransaction = "deleteTransaction",
|
DeleteTransaction = "deleteTransaction",
|
||||||
RetryTransaction = "retryTransaction",
|
RetryTransaction = "retryTransaction",
|
||||||
ListCurrencies = "listCurrencies",
|
ListCurrencies = "listCurrencies",
|
||||||
|
GenerateDepositGroupTxId = "generateDepositGroupTxId",
|
||||||
CreateDepositGroup = "createDepositGroup",
|
CreateDepositGroup = "createDepositGroup",
|
||||||
SetWalletDeviceId = "setWalletDeviceId",
|
SetWalletDeviceId = "setWalletDeviceId",
|
||||||
ExportBackupPlain = "exportBackupPlain",
|
ExportBackupPlain = "exportBackupPlain",
|
||||||
@ -495,6 +497,19 @@ export type ListCurrenciesOp = {
|
|||||||
|
|
||||||
// group: Deposits
|
// 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.
|
* Create a new deposit group.
|
||||||
*
|
*
|
||||||
@ -909,6 +924,7 @@ export type WalletOperations = {
|
|||||||
[WalletApiOperation.GetExchangeTos]: GetExchangeTosOp;
|
[WalletApiOperation.GetExchangeTos]: GetExchangeTosOp;
|
||||||
[WalletApiOperation.GetExchangeDetailedInfo]: GetExchangeDetailedInfoOp;
|
[WalletApiOperation.GetExchangeDetailedInfo]: GetExchangeDetailedInfoOp;
|
||||||
[WalletApiOperation.PrepareDeposit]: PrepareDepositOp;
|
[WalletApiOperation.PrepareDeposit]: PrepareDepositOp;
|
||||||
|
[WalletApiOperation.GenerateDepositGroupTxId]: GenerateDepositGroupTxIdOp;
|
||||||
[WalletApiOperation.CreateDepositGroup]: CreateDepositGroupOp;
|
[WalletApiOperation.CreateDepositGroup]: CreateDepositGroupOp;
|
||||||
[WalletApiOperation.SetWalletDeviceId]: SetWalletDeviceIdOp;
|
[WalletApiOperation.SetWalletDeviceId]: SetWalletDeviceIdOp;
|
||||||
[WalletApiOperation.ExportBackupPlain]: ExportBackupPlainOp;
|
[WalletApiOperation.ExportBackupPlain]: ExportBackupPlainOp;
|
||||||
|
@ -1348,6 +1348,8 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
|
|||||||
const req = codecForPrepareDepositRequest().decode(payload);
|
const req = codecForPrepareDepositRequest().decode(payload);
|
||||||
return await prepareDepositGroup(ws, req);
|
return await prepareDepositGroup(ws, req);
|
||||||
}
|
}
|
||||||
|
case WalletApiOperation.GenerateDepositGroupTxId:
|
||||||
|
return generateDepositGroupTxId();
|
||||||
case WalletApiOperation.CreateDepositGroup: {
|
case WalletApiOperation.CreateDepositGroup: {
|
||||||
const req = codecForCreateDepositGroupRequest().decode(payload);
|
const req = codecForCreateDepositGroupRequest().decode(payload);
|
||||||
return await createDepositGroup(ws, req);
|
return await createDepositGroup(ws, req);
|
||||||
|
Loading…
Reference in New Issue
Block a user