aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-cli/src/index.ts')
-rw-r--r--packages/taler-wallet-cli/src/index.ts150
1 files changed, 147 insertions, 3 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts
index aed9a24c0..dbd5ce956 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -18,12 +18,14 @@
* Imports.
*/
import {
+ AbsoluteTime,
addPaytoQueryParams,
AgeRestriction,
classifyTalerUri,
codecForList,
codecForString,
CoreApiResponse,
+ Duration,
encodeCrock,
getErrorDetailFromException,
getRandomBytes,
@@ -35,6 +37,7 @@ import {
setDangerousTimetravel,
setGlobalLogLevelFromString,
summarizeTalerErrorDetail,
+ TalerProtocolTimestamp,
TalerUriType,
WalletNotification,
} from "@gnu-taler/taler-util";
@@ -43,6 +46,7 @@ import {
getenv,
pathHomedir,
processExit,
+ readlinePrompt,
setUnhandledRejectionHandler,
} from "@gnu-taler/taler-util/compat";
import { createPlatformHttpLib } from "@gnu-taler/taler-util/http";
@@ -416,7 +420,7 @@ transactionsCli
});
transactionsCli
- .subcommand("abortTransaction", "delete", {
+ .subcommand("abortTransaction", "abort", {
help: "Abort a transaction.",
})
.requiredArgument("transactionId", clk.STRING, {
@@ -552,11 +556,16 @@ walletCli
.subcommand("handleUri", "handle-uri", {
help: "Handle a taler:// URI.",
})
- .requiredArgument("uri", clk.STRING)
+ .maybeArgument("uri", clk.STRING)
.flag("autoYes", ["-y", "--yes"])
.action(async (args) => {
await withWallet(args, async (wallet) => {
- const uri: string = args.handleUri.uri;
+ let uri;
+ if (args.handleUri.uri) {
+ uri = args.handleUri.uri;
+ } else {
+ uri = await readlinePrompt("Taler URI: ");
+ }
const uriType = classifyTalerUri(uri);
switch (uriType) {
case TalerUriType.TalerPay:
@@ -921,6 +930,141 @@ const advancedCli = walletCli.subcommand("advancedArgs", "advanced", {
});
advancedCli
+ .subcommand("checkPayPull", "check-pay-pull", {
+ help: "Check fees for a peer-pull payment initiation.",
+ })
+ .requiredArgument("amount", clk.STRING, {
+ help: "Amount to request",
+ })
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const resp = await wallet.client.call(
+ WalletApiOperation.PreparePeerPullPayment,
+ {
+ amount: args.checkPayPull.amount,
+ },
+ );
+ console.log(JSON.stringify(resp, undefined, 2));
+ });
+ });
+
+advancedCli
+ .subcommand("prepareIncomingPayPull", "prepare-incoming-pay-pull")
+ .requiredArgument("talerUri", clk.STRING)
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const resp = await wallet.client.call(
+ WalletApiOperation.CheckPeerPullPayment,
+ {
+ talerUri: args.prepareIncomingPayPull.talerUri,
+ },
+ );
+ console.log(JSON.stringify(resp, undefined, 2));
+ });
+ });
+
+advancedCli
+ .subcommand("confirmIncomingPayPull", "confirm-incoming-pay-pull")
+ .requiredArgument("peerPullPaymentIncomingId", clk.STRING)
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const resp = await wallet.client.call(
+ WalletApiOperation.AcceptPeerPullPayment,
+ {
+ peerPullPaymentIncomingId:
+ args.confirmIncomingPayPull.peerPullPaymentIncomingId,
+ },
+ );
+ console.log(JSON.stringify(resp, undefined, 2));
+ });
+ });
+
+advancedCli
+ .subcommand("initiatePayPull", "initiate-pay-pull", {
+ help: "Initiate a peer-pull payment.",
+ })
+ .requiredArgument("amount", clk.STRING, {
+ help: "Amount to request",
+ })
+ .maybeOption("summary", ["--summary"], clk.STRING, {
+ help: "Summary to use in the contract terms.",
+ })
+ .maybeOption("exchangeBaseUrl", ["--exchange"], clk.STRING)
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const resp = await wallet.client.call(
+ WalletApiOperation.InitiatePeerPullPayment,
+ {
+ exchangeBaseUrl: args.initiatePayPull.exchangeBaseUrl,
+ partialContractTerms: {
+ amount: args.initiatePayPull.amount,
+ summary: args.initiatePayPull.summary ?? "Invoice",
+ // FIXME: Make the expiration configurable
+ purse_expiration: AbsoluteTime.toTimestamp(
+ AbsoluteTime.addDuration(
+ AbsoluteTime.now(),
+ Duration.fromSpec({ hours: 1 }),
+ ),
+ ),
+ },
+ },
+ );
+ console.log(JSON.stringify(resp, undefined, 2));
+ });
+ });
+
+advancedCli
+ .subcommand("checkPayPush", "check-pay-push", {
+ help: "Check fees for a peer-push payment.",
+ })
+ .requiredArgument("amount", clk.STRING, {
+ help: "Amount to pay",
+ })
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const resp = await wallet.client.call(
+ WalletApiOperation.PreparePeerPushPayment,
+ {
+ amount: args.checkPayPush.amount,
+ },
+ );
+ console.log(JSON.stringify(resp, undefined, 2));
+ });
+ });
+
+advancedCli
+ .subcommand("payPush", "initiate-pay-push", {
+ help: "Initiate a peer-push payment.",
+ })
+ .requiredArgument("amount", clk.STRING, {
+ help: "Amount to pay",
+ })
+ .maybeOption("summary", ["--summary"], clk.STRING, {
+ help: "Summary to use in the contract terms.",
+ })
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const resp = await wallet.client.call(
+ WalletApiOperation.InitiatePeerPushPayment,
+ {
+ partialContractTerms: {
+ amount: args.payPush.amount,
+ summary: args.payPush.summary ?? "Payment",
+ // FIXME: Make the expiration configurable
+ purse_expiration: AbsoluteTime.toTimestamp(
+ AbsoluteTime.addDuration(
+ AbsoluteTime.now(),
+ Duration.fromSpec({ hours: 1 }),
+ ),
+ ),
+ },
+ },
+ );
+ console.log(JSON.stringify(resp, undefined, 2));
+ });
+ });
+
+advancedCli
.subcommand("serve", "serve", {
help: "Serve the wallet API via a unix domain socket.",
})