taler-wallet-cli: make purse expiration configurable
This commit is contained in:
parent
b9b1dd73f5
commit
e56d3ba8eb
@ -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),
|
||||
},
|
||||
},
|
||||
);
|
||||
|
@ -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,
|
||||
|
@ -118,8 +118,6 @@ import {
|
||||
} from "../versions.js";
|
||||
import {
|
||||
makeTransactionId,
|
||||
storeOperationError,
|
||||
storeOperationPending,
|
||||
} from "./common.js";
|
||||
import {
|
||||
getExchangeDetails,
|
||||
|
Loading…
Reference in New Issue
Block a user