aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-cli/src/index.ts46
-rw-r--r--packages/taler-wallet-core/src/operations/pay-peer.ts6
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts2
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,