taler-typescript-core

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

commit 3ce5eb4bd85c98113a1f0a91506e50d2179d5550
parent dcc1bcee4337e257b10b64a562cba8ac2717db41
Author: Florian Dold <florian@dold.me>
Date:   Wed,  7 Sep 2022 15:40:03 +0200

allow age-restricted withdrawal from the CLI

Diffstat:
Mpackages/taler-wallet-cli/src/index.ts | 41+++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+), 0 deletions(-)

diff --git 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, @@ -382,6 +383,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.", })