diff options
author | Florian Dold <florian@dold.me> | 2022-09-07 15:40:03 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-09-07 15:40:03 +0200 |
commit | 3ce5eb4bd85c98113a1f0a91506e50d2179d5550 (patch) | |
tree | c2c5c6a34bf8eb3213fc52bfc27356697cb9e966 | |
parent | dcc1bcee4337e257b10b64a562cba8ac2717db41 (diff) |
allow age-restricted withdrawal from the CLI
-rw-r--r-- | packages/taler-wallet-cli/src/index.ts | 41 |
1 files changed, 41 insertions, 0 deletions
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, @@ -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.", }) |