commit e0a7ee78ddd482faa213c2e126cbda5efd14a23d
parent 6f081533c8c7c108cd13e7314a49f6cf740115d4
Author: Florian Dold <dold@taler.net>
Date: Fri, 27 Nov 2026 12:41:47 +0100
wallet web UI: explain when another wallet received a peer payment
Issue: https://bugs.taler.net/n/10923
Diffstat:
3 files changed, 113 insertions(+), 1 deletion(-)
diff --git a/packages/taler-harness/src/integrationtests/test-kyc-peer-push.ts b/packages/taler-harness/src/integrationtests/test-kyc-peer-push.ts
@@ -19,6 +19,7 @@
*/
import {
j2s,
+ TalerErrorCode,
TransactionMajorState,
TransactionMinorState,
} from "@gnu-taler/taler-util";
@@ -112,6 +113,78 @@ export async function runKycPeerPushTest(t: GlobalTestState) {
major: TransactionMajorState.Done,
},
});
+
+ t.logStep(
+ "Another wallet receives the payment while the first waits for KYC",
+ );
+ const { walletClient: firstReceiver } = await createWalletDaemonWithClient(
+ t,
+ {
+ name: "first-receiver",
+ },
+ );
+ const secondPayment = await doPeerPushDebit(t, {
+ walletClient: w0.walletClient,
+ amount: "TESTKUDOS:6",
+ });
+ const { transactionId } = await firstReceiver.call(
+ WalletApiOperation.PreparePeerPushCredit,
+ { talerUri: secondPayment.talerUri },
+ );
+ await firstReceiver.call(WalletApiOperation.ConfirmPeerPushCredit, {
+ transactionId,
+ });
+ await firstReceiver.call(WalletApiOperation.TestingWaitTransactionState, {
+ transactionId,
+ txState: {
+ major: TransactionMajorState.Pending,
+ minor: TransactionMinorState.KycRequired,
+ },
+ });
+ const blocked = await firstReceiver.call(
+ WalletApiOperation.GetTransactionById,
+ {
+ transactionId,
+ },
+ );
+ t.assertTrue(!!blocked.kycUrl && !!blocked.kycPaytoHash);
+
+ const received = await walletClient.call(
+ WalletApiOperation.PreparePeerPushCredit,
+ {
+ talerUri: secondPayment.talerUri,
+ },
+ );
+ await walletClient.call(WalletApiOperation.ConfirmPeerPushCredit, {
+ transactionId: received.transactionId,
+ });
+ await walletClient.call(WalletApiOperation.TestingWaitTransactionState, {
+ transactionId: received.transactionId,
+ txState: { major: TransactionMajorState.Done },
+ });
+
+ await postAmlDecisionNoRules(t, {
+ amlPriv: amlKeypair.priv,
+ amlPub: amlKeypair.pub,
+ exchangeBaseUrl: exchange.baseUrl,
+ paytoHash: blocked.kycPaytoHash,
+ });
+ await firstReceiver.call(WalletApiOperation.TestingWaitTransactionState, {
+ transactionId,
+ txState: { major: TransactionMajorState.Failed },
+ });
+ const failed = await firstReceiver.call(
+ WalletApiOperation.GetTransactionById,
+ {
+ transactionId,
+ },
+ );
+ t.assertDeepEqual(
+ failed.failReason?.code,
+ TalerErrorCode.WALLET_TRANSACTION_COMPLETED_BY_OTHER_WALLET,
+ );
+ t.assertDeepEqual(failed.kycUrl, undefined);
+ t.assertDeepEqual(failed.amountEffectiveFinal, "TESTKUDOS:0");
}
/**
diff --git a/packages/wallet-webui/src/routes/transaction-model.ts b/packages/wallet-webui/src/routes/transaction-model.ts
@@ -1,5 +1,6 @@
import {
Amounts,
+ TalerErrorCode,
TransactionAction,
TransactionMajorState,
TransactionMinorState,
@@ -397,7 +398,11 @@ export function transactionErrorPresentation(
if (!detail) return undefined;
return walletCoreError(
detail,
- fallback ?? i18n.str`Wallet error ${detail.code}`,
+ transaction.type === TransactionType.PeerPushCredit &&
+ detail.code ===
+ TalerErrorCode.WALLET_TRANSACTION_COMPLETED_BY_OTHER_WALLET
+ ? i18n.str`Another wallet already received this payment.`
+ : (fallback ?? i18n.str`Wallet error ${detail.code}`),
);
}
diff --git a/packages/wallet-webui/test/transaction-model.test.ts b/packages/wallet-webui/test/transaction-model.test.ts
@@ -322,6 +322,40 @@ test("transaction errors preserve every wallet-core terminal reason", () => {
assert.equal(transactionErrorPresentation(payment()), undefined);
});
+test("a failed peer receipt explains that another wallet received the payment", () => {
+ const reason = {
+ code: TalerErrorCode.WALLET_TRANSACTION_COMPLETED_BY_OTHER_WALLET,
+ };
+ const view = transactionDetailView({
+ type: TransactionType.PeerPushCredit,
+ transactionId: "txn:peer-push-credit:lunch" as TransactionIdStr,
+ timestamp: { t_s: 1_700_000_000 },
+ scopes: [],
+ txState: { major: TransactionMajorState.Failed },
+ txActions: [TransactionAction.Delete],
+ amountRaw: "CHF:5",
+ amountEffective: "CHF:4.90",
+ amountEffectiveFinal: "CHF:0",
+ exchangeBaseUrl: "https://exchange.example/",
+ info: { summary: "Lunch", expiration: undefined, iconId: undefined },
+ failReason: reason,
+ });
+ assert.deepEqual(view.error, {
+ message: "Another wallet already received this payment.",
+ detail: reason,
+ });
+ assert.equal(view.externalAction, undefined);
+
+ // Withdrawals can report the same code when a different wallet takes over.
+ assert.equal(
+ transactionErrorPresentation(
+ withdrawal({ abortReason: reason }),
+ "Withdrawal stopped",
+ )?.message,
+ "Withdrawal stopped",
+ );
+});
+
test("contract-less payment failures omit unknown price fields", () => {
const failReason = {
code: TalerErrorCode.WALLET_ORDER_ALREADY_CLAIMED,