allow age-restricted withdrawal from the CLI

This commit is contained in:
Florian Dold 2022-09-07 15:40:03 +02:00
parent dcc1bcee43
commit 3ce5eb4bd8
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -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.",