taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit d42d33e4f231f3a4a09a095539a10b4afde5b706
parent 89b60325e863184e1aac472b5063096be3a37506
Author: Florian Dold <dold@taler.net>
Date:   Fri, 27 Nov 2026 16:49:54 +0100

wallet CLI: submit standalone handle-uri payments before exit

With --no-wait, a standalone CLI could shut down its wallet before the
merchant received the payment. Keep it running through the first attempt.
A daemon can finish the payment after the CLI disconnects.

Issue: https://bugs.taler.net/n/9812

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-payment.ts | 48++++++++++++++++++++++++++++++++++++++++++++----
Mpackages/taler-wallet-cli/src/index.ts | 8++++++++
2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-payment.ts b/packages/taler-harness/src/integrationtests/test-payment.ts @@ -36,6 +36,7 @@ import { harnessLongpollQueue, harnessHttpLib, GlobalTestState, + runCommand, } from "../harness/harness.js"; /** @@ -48,6 +49,7 @@ export async function runPaymentTest(t: GlobalTestState) { bank, bankClient, walletClient, + walletService, exchange, merchant, merchantAdminAccessToken, @@ -98,11 +100,11 @@ export async function runPaymentTest(t: GlobalTestState) { await walletClient.call(WalletApiOperation.TestingWaitTransactionsFinal, {}); + const merchantClient = new TalerMerchantInstanceHttpClient( + merchant.makeInstanceBaseUrl(), + { httpClient: harnessHttpLib, longpollQueue: harnessLongpollQueue }, + ); await t.runSpanAsync("idempotent-payment", async () => { - const merchantClient = new TalerMerchantInstanceHttpClient( - merchant.makeInstanceBaseUrl(), - { httpClient: harnessHttpLib, longpollQueue: harnessLongpollQueue }, - ); const orderResp = succeedOrThrow( await merchantClient.createOrder(merchantAdminAccessToken, { order: { @@ -206,6 +208,44 @@ export async function runPaymentTest(t: GlobalTestState) { t.assertAmountEquals(bal.balances[0].available, "TESTKUDOS:4.54"); t.assertAmountEquals(bal.balances[0].pendingIncoming, "TESTKUDOS:0"); t.assertAmountEquals(bal.balances[0].pendingOutgoing, "TESTKUDOS:0"); + + await t.runSpanAsync("standalone-handle-uri-no-wait", async () => { + await walletService.stop(); + const { order_id } = succeedOrThrow( + await merchantClient.createOrder(merchantAdminAccessToken, { + order: { + summary: "Standalone CLI payment", + amount: "TESTKUDOS:1", + fulfillment_url: "taler://fulfillment-success/standalone", + }, + }), + ); + const getOrder = async () => + succeedOrThrow( + await merchantClient.getOrderDetails( + merchantAdminAccessToken, + order_id, + ), + ); + const order = await getOrder(); + t.assertTrue(order.order_status === "unpaid"); + await runCommand( + t, + "handle-uri", + "taler-wallet-cli", + [ + "--wallet-db", + walletService.dbPath, + "--skip-defaults", + "handle-uri", + "--yes", + "--no-wait", + order.taler_pay_uri, + ], + { ...process.env, TALER_WALLET_CONNECTION: undefined }, + ); + t.assertDeepEqual((await getOrder()).order_status, "paid"); + }); } runPaymentTest.suites = ["wallet"]; diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts @@ -271,6 +271,9 @@ async function doHandlePayTransaction( processExit(res.exitCode); } if (options.noWait) { + if (ctx.isLocal && res.performed) { + await waitForPaymentAttempt(ctx, transactionId); + } return; } diagnosticLog(`Waiting for transaction '${transactionId}' to finish`); @@ -615,6 +618,9 @@ function checkEnvFlag(name: string): boolean { } export interface WalletContext { + /** A local wallet shuts down when the command returns. */ + readonly isLocal: boolean; + /** * High-level client for making API requests to wallet-core. */ @@ -768,6 +774,7 @@ async function withWallet<T>( socketFilename: walletSocketPath, }); const ctx: WalletContext = { + isLocal: false, makeCoreApiRequest(operation, payload) { return w.makeCoreApiRequest(operation, payload); }, @@ -781,6 +788,7 @@ async function withWallet<T>( } else { const wh = await createLocalWallet(walletCliArgs, args, onNotif); const ctx: WalletContext = { + isLocal: true, client: wh.wallet.client, waitForNotificationCond: waiter.waitForNotificationCond, addNotificationListener,