diff options
author | Florian Dold <florian@dold.me> | 2022-03-17 11:08:53 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-03-17 11:08:53 +0100 |
commit | 05838080f51f0405bde846703b28310a70e82b5f (patch) | |
tree | bdb82b8b5f42a13c789828d0888f8fe3b99c6b16 | |
parent | 151aa904e054a5e81e80a9eff95889b6e7ab8fa2 (diff) |
wallet: round timestamps in db-less requests to the exchange
-rw-r--r-- | packages/taler-util/src/time.ts | 1 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/dbless.ts | 9 |
2 files changed, 6 insertions, 4 deletions
diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts index 3b80b4ee0..9f9571019 100644 --- a/packages/taler-util/src/time.ts +++ b/packages/taler-util/src/time.ts @@ -87,6 +87,7 @@ export namespace Timestamp { export const now = getTimestampNow; export const min = timestampMin; export const isExpired = isTimestampExpired; + export const truncateToSecond = timestampTruncateToSecond; } export function timestampMin(t1: Timestamp, t2: Timestamp): Timestamp { diff --git a/packages/taler-wallet-core/src/dbless.ts b/packages/taler-wallet-core/src/dbless.ts index 85a72e28d..169b6ae0a 100644 --- a/packages/taler-wallet-core/src/dbless.ts +++ b/packages/taler-wallet-core/src/dbless.ts @@ -41,10 +41,10 @@ import { ExchangeProtocolVersion, ExchangeWithdrawRequest, getRandomBytes, - getTimestampNow, hashWire, Logger, parsePaytoUri, + Timestamp, UnblindedSignature, } from "@gnu-taler/taler-util"; import { DenominationRecord } from "./db.js"; @@ -223,8 +223,9 @@ export async function depositCoin(args: { args.depositPayto ?? "payto://x-taler-bank/localhost/foo"; const wireSalt = encodeCrock(getRandomBytes(16)); const contractTermsHash = encodeCrock(getRandomBytes(64)); - const depositTimestamp = getTimestampNow(); - const refundDeadline = getTimestampNow(); + const depositTimestamp = Timestamp.truncateToSecond(Timestamp.now()); + const refundDeadline = Timestamp.truncateToSecond(Timestamp.now()); + const wireTransferDeadline = Timestamp.truncateToSecond(Timestamp.now()); const merchantPub = encodeCrock(getRandomBytes(32)); const dp = await cryptoApi.signDepositPermission({ coinPriv: coin.coinPriv, @@ -248,7 +249,7 @@ export async function depositCoin(args: { h_contract_terms: contractTermsHash, ub_sig: coin.denomSig, timestamp: depositTimestamp, - wire_transfer_deadline: getTimestampNow(), + wire_transfer_deadline: wireTransferDeadline, refund_deadline: refundDeadline, coin_sig: dp.coin_sig, denom_pub_hash: dp.h_denom, |