[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 02/02: taler-wallet-cli: make purse expiration confi
From: |
gnunet |
Subject: |
[taler-wallet-core] 02/02: taler-wallet-cli: make purse expiration configurable |
Date: |
Tue, 21 Feb 2023 01:15:36 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
commit e56d3ba8ebc29c41e95505f3d3cdd6de62e7ce34
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Feb 21 01:15:27 2023 +0100
taler-wallet-cli: make purse expiration configurable
---
packages/taler-wallet-cli/src/index.ts | 46 +++++++++++++++-------
.../taler-wallet-core/src/operations/pay-peer.ts | 6 ++-
.../taler-wallet-core/src/operations/withdraw.ts | 2 -
3 files changed, 37 insertions(+), 17 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),
},
},
);
diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts
b/packages/taler-wallet-core/src/operations/pay-peer.ts
index 4dcc06076..5178839a4 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer.ts
@@ -97,7 +97,6 @@ import {
runLongpollAsync,
runOperationWithErrorReporting,
spendCoins,
- storeOperationPending,
} from "../operations/common.js";
import {
readSuccessResponseJsonOrErrorCode,
@@ -220,6 +219,11 @@ export async function selectPeerCoins(
ws: InternalWalletState,
instructedAmount: AmountJson,
): Promise<SelectPeerCoinsResult> {
+ if (Amounts.isZero(instructedAmount)) {
+ // Other parts of the code assume that we have at least
+ // one coin to spend.
+ throw new Error("amount of zero not allowed");
+ }
return await ws.db
.mktx((x) => [
x.exchanges,
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts
b/packages/taler-wallet-core/src/operations/withdraw.ts
index aba2948cd..3c3878792 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -118,8 +118,6 @@ import {
} from "../versions.js";
import {
makeTransactionId,
- storeOperationError,
- storeOperationPending,
} from "./common.js";
import {
getExchangeDetails,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.