From 3ce5eb4bd85c98113a1f0a91506e50d2179d5550 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 7 Sep 2022 15:40:03 +0200 Subject: allow age-restricted withdrawal from the CLI --- packages/taler-wallet-cli/src/index.ts | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index 2a594bd61..2ed371420 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -49,6 +49,7 @@ import { AgeRestriction, getRandomBytes, encodeCrock, + j2s, } from "@gnu-taler/taler-util"; import { NodeHttpLib, @@ -381,6 +382,46 @@ walletCli }); }); +walletCli + .subcommand("withdraw", "withdraw", { + help: "Withdraw with a taler://withdraw/ URI", + }) + .requiredArgument("uri", clk.STRING) + .maybeOption("restrictAge", ["--restrict-age"], clk.STRING) + .action(async (args) => { + const uri = args.withdraw.uri; + const restrictAge = + args.withdraw.restrictAge == null + ? undefined + : Number.parseInt(args.withdraw.restrictAge); + console.log(`age restriction requested (${restrictAge})`); + await withWallet(args, async (wallet) => { + const withdrawInfo = await wallet.client.call( + WalletApiOperation.GetWithdrawalDetailsForUri, + { + talerWithdrawUri: uri, + restrictAge, + }, + ); + console.log("withdrawInfo", withdrawInfo); + const selectedExchange = withdrawInfo.defaultExchangeBaseUrl; + if (!selectedExchange) { + console.error("no suggested exchange!"); + process.exit(1); + return; + } + const res = await wallet.client.call( + WalletApiOperation.AcceptBankIntegratedWithdrawal, + { + exchangeBaseUrl: selectedExchange, + talerWithdrawUri: uri, + restrictAge, + }, + ); + console.log(j2s(res)); + }); + }); + walletCli .subcommand("handleUri", "handle-uri", { help: "Handle a taler:// URI.", -- cgit v1.2.3