commit 2b115c4d18cd7fe3a920e1c04ba33b2ba3ad42b8
parent 8e34c546742857d8fb9e2443436037f4b6e748be
Author: Florian Dold <florian@dold.me>
Date: Wed, 27 Nov 2024 14:41:49 +0100
wallet-core: allow treating bank accounts as foreign in withdrawal
Foreign bank accounts won't be added to the known bank accounts.
Diffstat:
5 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/packages/taler-harness/src/integrationtests/test-wallettesting.ts b/packages/taler-harness/src/integrationtests/test-wallettesting.ts
@@ -25,12 +25,12 @@
import { AmountString, Amounts, CoinStatus } from "@gnu-taler/taler-util";
import { WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { CoinConfig, defaultCoinConfig } from "../harness/denomStructures.js";
-import { GlobalTestState, setupDb } from "../harness/harness.js";
import {
SimpleTestEnvironmentNg3,
createSimpleTestkudosEnvironmentV3,
createWalletDaemonWithClient,
} from "../harness/environments.js";
+import { GlobalTestState, setupDb } from "../harness/harness.js";
const merchantAuthToken = "secret-token:sandbox";
diff --git a/packages/taler-util/src/types-taler-wallet.ts b/packages/taler-util/src/types-taler-wallet.ts
@@ -2152,13 +2152,33 @@ export interface CoreApiResponseError {
}
export interface WithdrawTestBalanceRequest {
+ /**
+ * Amount to withdraw.
+ */
amount: AmountString;
+
/**
* Corebank API base URL.
*/
corebankApiBaseUrl: string;
+
+ /**
+ * Exchange to use for withdrawal.
+ */
exchangeBaseUrl: string;
+
+ /**
+ * Force the usage of a particular denomination selection.
+ *
+ * Only useful for testing.
+ */
forcedDenomSel?: ForcedDenomSel;
+
+ /**
+ * If set to true, treat the account created during
+ * the withdrawal as a foreign withdrawal account.
+ */
+ useForeignAccount?: boolean;
}
/**
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
@@ -1498,6 +1498,15 @@ export interface WithdrawalGroupRecord {
wgInfo: WgInfo;
+ /**
+ * If set to true, the account used during withdrawal is treated as an
+ * account that does not belong to the user. It won't be shown in
+ * the list of know bank accounts.
+ *
+ * Defaults to false.
+ */
+ isForeignAccount?: boolean;
+
kycPaytoHash?: string;
kycAccessToken?: string;
diff --git a/packages/taler-wallet-core/src/testing.ts b/packages/taler-wallet-core/src/testing.ts
@@ -138,6 +138,7 @@ export async function withdrawTestBalance(
talerWithdrawUri: wresp.taler_withdraw_uri,
selectedExchange: exchangeBaseUrl,
forcedDenomSel: req.forcedDenomSel,
+ isForeignAccount: req.useForeignAccount,
});
await corebankClient.confirmWithdrawalOperation(bankUser.username, {
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
@@ -3071,6 +3071,7 @@ export async function internalPrepareCreateWithdrawalGroup(
reserveKeyPair?: EddsaKeyPairStrings;
restrictAge?: number;
wgInfo: WgInfo;
+ isForeignAccount?: boolean;
},
): Promise<PrepareCreateWithdrawalGroupResult> {
const reserveKeyPair =
@@ -3134,6 +3135,7 @@ export async function internalPrepareCreateWithdrawalGroup(
restrictAge: args.restrictAge,
timestampFinish: undefined,
wgInfo: args.wgInfo,
+ isForeignAccount: args.isForeignAccount,
};
if (exchangeBaseUrl !== undefined) {
@@ -3266,6 +3268,7 @@ export async function internalCreateWithdrawalGroup(
reserveKeyPair?: EddsaKeyPairStrings;
restrictAge?: number;
wgInfo: WgInfo;
+ isForeignAccount?: boolean;
},
): Promise<WithdrawalGroupRecord> {
const prep = await internalPrepareCreateWithdrawalGroup(wex, args);
@@ -3305,6 +3308,7 @@ export async function prepareBankIntegratedWithdrawal(
wex: WalletExecutionContext,
req: {
talerWithdrawUri: string;
+ isForeignAccount?: boolean;
},
): Promise<PrepareBankIntegratedWithdrawalResponse> {
const existingWithdrawalGroup = await wex.db.runReadOnlyTx(
@@ -3366,6 +3370,7 @@ export async function prepareBankIntegratedWithdrawal(
externalConfirmation,
},
},
+ isForeignAccount: req.isForeignAccount,
reserveStatus: WithdrawalGroupStatus.DialogProposed,
});
@@ -3460,7 +3465,7 @@ export async function confirmWithdrawal(
const senderWire = withdrawalGroup.wgInfo.bankInfo.senderWire;
- if (senderWire) {
+ if (senderWire && !withdrawalGroup.isForeignAccount) {
logger.info(`sender wire is ${senderWire}`);
const parsedSenderWire = parsePaytoUri(senderWire);
if (!parsedSenderWire) {
@@ -3623,6 +3628,7 @@ export async function acceptBankIntegratedWithdrawal(
forcedDenomSel?: ForcedDenomSel;
restrictAge?: number;
amount?: AmountLike;
+ isForeignAccount?: boolean;
},
): Promise<AcceptWithdrawalResponse> {
wex.oc.observe({
@@ -3637,6 +3643,7 @@ export async function acceptBankIntegratedWithdrawal(
const p = await prepareBankIntegratedWithdrawal(wex, {
talerWithdrawUri: req.talerWithdrawUri,
+ isForeignAccount: req.isForeignAccount,
});
wex.oc.observe({