allow age-restricted withdrawal from the CLI
This commit is contained in:
parent
dcc1bcee43
commit
3ce5eb4bd8
@ -49,6 +49,7 @@ import {
|
|||||||
AgeRestriction,
|
AgeRestriction,
|
||||||
getRandomBytes,
|
getRandomBytes,
|
||||||
encodeCrock,
|
encodeCrock,
|
||||||
|
j2s,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
NodeHttpLib,
|
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
|
walletCli
|
||||||
.subcommand("handleUri", "handle-uri", {
|
.subcommand("handleUri", "handle-uri", {
|
||||||
help: "Handle a taler:// URI.",
|
help: "Handle a taler:// URI.",
|
||||||
|
Loading…
Reference in New Issue
Block a user