wallet: round timestamps in db-less requests to the exchange
This commit is contained in:
parent
151aa904e0
commit
05838080f5
@ -87,6 +87,7 @@ export namespace Timestamp {
|
|||||||
export const now = getTimestampNow;
|
export const now = getTimestampNow;
|
||||||
export const min = timestampMin;
|
export const min = timestampMin;
|
||||||
export const isExpired = isTimestampExpired;
|
export const isExpired = isTimestampExpired;
|
||||||
|
export const truncateToSecond = timestampTruncateToSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function timestampMin(t1: Timestamp, t2: Timestamp): Timestamp {
|
export function timestampMin(t1: Timestamp, t2: Timestamp): Timestamp {
|
||||||
|
@ -41,10 +41,10 @@ import {
|
|||||||
ExchangeProtocolVersion,
|
ExchangeProtocolVersion,
|
||||||
ExchangeWithdrawRequest,
|
ExchangeWithdrawRequest,
|
||||||
getRandomBytes,
|
getRandomBytes,
|
||||||
getTimestampNow,
|
|
||||||
hashWire,
|
hashWire,
|
||||||
Logger,
|
Logger,
|
||||||
parsePaytoUri,
|
parsePaytoUri,
|
||||||
|
Timestamp,
|
||||||
UnblindedSignature,
|
UnblindedSignature,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { DenominationRecord } from "./db.js";
|
import { DenominationRecord } from "./db.js";
|
||||||
@ -223,8 +223,9 @@ export async function depositCoin(args: {
|
|||||||
args.depositPayto ?? "payto://x-taler-bank/localhost/foo";
|
args.depositPayto ?? "payto://x-taler-bank/localhost/foo";
|
||||||
const wireSalt = encodeCrock(getRandomBytes(16));
|
const wireSalt = encodeCrock(getRandomBytes(16));
|
||||||
const contractTermsHash = encodeCrock(getRandomBytes(64));
|
const contractTermsHash = encodeCrock(getRandomBytes(64));
|
||||||
const depositTimestamp = getTimestampNow();
|
const depositTimestamp = Timestamp.truncateToSecond(Timestamp.now());
|
||||||
const refundDeadline = getTimestampNow();
|
const refundDeadline = Timestamp.truncateToSecond(Timestamp.now());
|
||||||
|
const wireTransferDeadline = Timestamp.truncateToSecond(Timestamp.now());
|
||||||
const merchantPub = encodeCrock(getRandomBytes(32));
|
const merchantPub = encodeCrock(getRandomBytes(32));
|
||||||
const dp = await cryptoApi.signDepositPermission({
|
const dp = await cryptoApi.signDepositPermission({
|
||||||
coinPriv: coin.coinPriv,
|
coinPriv: coin.coinPriv,
|
||||||
@ -248,7 +249,7 @@ export async function depositCoin(args: {
|
|||||||
h_contract_terms: contractTermsHash,
|
h_contract_terms: contractTermsHash,
|
||||||
ub_sig: coin.denomSig,
|
ub_sig: coin.denomSig,
|
||||||
timestamp: depositTimestamp,
|
timestamp: depositTimestamp,
|
||||||
wire_transfer_deadline: getTimestampNow(),
|
wire_transfer_deadline: wireTransferDeadline,
|
||||||
refund_deadline: refundDeadline,
|
refund_deadline: refundDeadline,
|
||||||
coin_sig: dp.coin_sig,
|
coin_sig: dp.coin_sig,
|
||||||
denom_pub_hash: dp.h_denom,
|
denom_pub_hash: dp.h_denom,
|
||||||
|
Loading…
Reference in New Issue
Block a user