From 666b767766ef299bd58655c55ece6d4a82c3e947 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 23 Apr 2024 12:49:42 +0200 Subject: wallet-core: support for withdrawals with forced reserve key --- packages/taler-wallet-cli/src/index.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'packages/taler-wallet-cli/src/index.ts') diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index b85995052..b915de538 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -57,6 +57,7 @@ import { JsonMessage, runRpcServer } from "@gnu-taler/taler-util/twrpc"; import { AccessStats, createNativeWalletHost2, + nativeCrypto, Wallet, WalletApiOperation, WalletCoreApiClient, @@ -349,7 +350,7 @@ async function withWallet( }, }; const result = await f(ctx); - wh.wallet.stop(); + await wh.wallet.client.call(WalletApiOperation.Shutdown, {}); if (process.env.TALER_WALLET_DBSTATS) { console.log("database stats:"); console.log(j2s(wh.getStats())); @@ -723,6 +724,7 @@ withdrawCli .requiredOption("amount", ["--amount"], clk.AMOUNT, { help: "Amount to withdraw", }) + .maybeOption("forcedReservePriv", ["--forced-reserve-priv"], clk.STRING, {}) .maybeOption("restrictAge", ["--restrict-age"], clk.INT) .action(async (args) => { await withWallet(args, async (wallet) => { @@ -735,7 +737,7 @@ withdrawCli exchangeBaseUrl: exchangeBaseUrl, }, ); - const acct = d.paytoUris[0]; + const acct = d.withdrawalAccountsList[0]; if (!acct) { console.log("exchange has no accounts"); return; @@ -746,10 +748,11 @@ withdrawCli amount, exchangeBaseUrl, restrictAge: parseInt(String(args.withdrawManually.restrictAge), 10), + forceReservePriv: args.withdrawManually.forcedReservePriv, }, ); const reservePub = resp.reservePub; - const completePaytoUri = addPaytoQueryParams(acct, { + const completePaytoUri = addPaytoQueryParams(acct.paytoUri, { amount: args.withdrawManually.amount, message: `Taler top-up ${reservePub}`, }); @@ -1171,6 +1174,20 @@ const advancedCli = walletCli.subcommand("advancedArgs", "advanced", { help: "Subcommands for advanced operations (only use if you know what you're doing!).", }); +advancedCli + .subcommand("genReserve", "gen-reserve", { + help: "Generate a reserve key pair (not stored in the DB).", + }) + .action(async (args) => { + const pair = await nativeCrypto.createEddsaKeypair({}); + console.log( + j2s({ + reservePub: pair.pub, + reservePriv: pair.priv, + }), + ); + }); + advancedCli .subcommand("tasks", "tasks", { help: "Show active wallet-core tasks.", @@ -1322,7 +1339,7 @@ advancedCli merchantBaseUrl: "http://localhost:8083/", }); await wallet.client.call(WalletApiOperation.TestingWaitTasksDone, {}); - wallet.stop(); + await wallet.client.call(WalletApiOperation.Shutdown, {}); }); advancedCli -- cgit v1.2.3