diff options
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r-- | packages/taler-wallet-cli/src/index.ts | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index 30959d9ed..93cd5457a 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -1043,8 +1043,23 @@ peerCli .maybeOption("summary", ["--summary"], clk.STRING, { help: "Summary to use in the contract terms.", }) + .maybeOption("purseExpiration", ["--purse-expiration"], clk.STRING) .maybeOption("exchangeBaseUrl", ["--exchange"], clk.STRING) .action(async (args) => { + let purseExpiration: AbsoluteTime; + + if (args.initiatePayPull.purseExpiration) { + purseExpiration = AbsoluteTime.addDuration( + AbsoluteTime.now(), + Duration.fromPrettyString(args.initiatePayPull.purseExpiration), + ); + } else { + purseExpiration = AbsoluteTime.addDuration( + AbsoluteTime.now(), + Duration.fromSpec({ hours: 1 }), + ); + } + await withWallet(args, async (wallet) => { const resp = await wallet.client.call( WalletApiOperation.InitiatePeerPullCredit, @@ -1053,13 +1068,7 @@ peerCli 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 }), - ), - ), + purse_expiration: AbsoluteTime.toTimestamp(purseExpiration), }, }, ); @@ -1092,7 +1101,22 @@ peerCli .maybeOption("summary", ["--summary"], clk.STRING, { help: "Summary to use in the contract terms.", }) + .maybeOption("purseExpiration", ["--purse-expiration"], clk.STRING) .action(async (args) => { + let purseExpiration: AbsoluteTime; + + if (args.payPush.purseExpiration) { + purseExpiration = AbsoluteTime.addDuration( + AbsoluteTime.now(), + Duration.fromPrettyString(args.payPush.purseExpiration), + ); + } else { + purseExpiration = AbsoluteTime.addDuration( + AbsoluteTime.now(), + Duration.fromSpec({ hours: 1 }), + ); + } + await withWallet(args, async (wallet) => { const resp = await wallet.client.call( WalletApiOperation.InitiatePeerPushDebit, @@ -1100,13 +1124,7 @@ peerCli 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 }), - ), - ), + purse_expiration: AbsoluteTime.toTimestamp(purseExpiration), }, }, ); |