diff options
author | Florian Dold <florian@dold.me> | 2023-05-26 12:19:32 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-05-26 12:19:32 +0200 |
commit | cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854 (patch) | |
tree | 423ed7c6fc42ec5e05f655eb093b3b4bdc885996 /packages/taler-wallet-core/src/operations/deposits.ts | |
parent | 557dcec30db6573c5d11ca26432008ac6621642e (diff) | |
download | wallet-core-cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854.tar.xz |
taler-util,wallet-core: implement TalerPreciseTimestamp
Fixes #7703
Diffstat (limited to 'packages/taler-wallet-core/src/operations/deposits.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/deposits.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index a36091165..de881ddd2 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -51,6 +51,7 @@ import { stringToBytes, TalerErrorCode, TalerProtocolTimestamp, + TalerPreciseTimestamp, TrackTransaction, TransactionMajorState, TransactionMinorState, @@ -779,7 +780,7 @@ export async function processDepositGroup( } } if (allDepositedAndWired) { - dg.timestampFinished = TalerProtocolTimestamp.now(); + dg.timestampFinished = TalerPreciseTimestamp.now(); dg.operationStatus = DepositOperationStatus.Finished; await tx.depositGroups.put(dg); } @@ -858,9 +859,9 @@ async function getExchangeWireFee( } const fee = fees.find((x) => { return AbsoluteTime.isBetween( - AbsoluteTime.fromTimestamp(time), - AbsoluteTime.fromTimestamp(x.startStamp), - AbsoluteTime.fromTimestamp(x.endStamp), + AbsoluteTime.fromProtocolTimestamp(time), + AbsoluteTime.fromProtocolTimestamp(x.startStamp), + AbsoluteTime.fromProtocolTimestamp(x.endStamp), ); }); if (!fee) { @@ -952,7 +953,7 @@ export async function prepareDepositGroup( }); const now = AbsoluteTime.now(); - const nowRounded = AbsoluteTime.toTimestamp(now); + const nowRounded = AbsoluteTime.toProtocolTimestamp(now); const contractTerms: MerchantContractTerms = { exchanges: exchangeInfos, amount: req.amount, @@ -966,7 +967,7 @@ export async function prepareDepositGroup( wire_transfer_deadline: nowRounded, order_id: "", h_wire: "", - pay_deadline: AbsoluteTime.toTimestamp( + pay_deadline: AbsoluteTime.toProtocolTimestamp( AbsoluteTime.addDuration(now, durationFromSpec({ hours: 1 })), ), merchant: { @@ -1066,7 +1067,7 @@ export async function createDepositGroup( }); const now = AbsoluteTime.now(); - const nowRounded = AbsoluteTime.toTimestamp(now); + const nowRounded = AbsoluteTime.toProtocolTimestamp(now); const noncePair = await ws.cryptoApi.createEddsaKeypair({}); const merchantPair = await ws.cryptoApi.createEddsaKeypair({}); const wireSalt = encodeCrock(getRandomBytes(16)); @@ -1084,7 +1085,7 @@ export async function createDepositGroup( wire_transfer_deadline: nowRounded, order_id: "", h_wire: wireHash, - pay_deadline: AbsoluteTime.toTimestamp( + pay_deadline: AbsoluteTime.toProtocolTimestamp( AbsoluteTime.addDuration(now, durationFromSpec({ hours: 1 })), ), merchant: { @@ -1150,7 +1151,7 @@ export async function createDepositGroup( depositGroupId, noncePriv: noncePair.priv, noncePub: noncePair.pub, - timestampCreated: AbsoluteTime.toTimestamp(now), + timestampCreated: AbsoluteTime.toPreciseTimestamp(now), timestampFinished: undefined, transactionPerCoin: payCoinSel.coinSel.coinPubs.map( () => DepositElementStatus.Unknown, @@ -1260,8 +1261,8 @@ export async function getCounterpartyEffectiveDepositAmount( const fee = exchangeDetails.wireInfo.feesForType[wireType].find((x) => { return AbsoluteTime.isBetween( AbsoluteTime.now(), - AbsoluteTime.fromTimestamp(x.startStamp), - AbsoluteTime.fromTimestamp(x.endStamp), + AbsoluteTime.fromProtocolTimestamp(x.startStamp), + AbsoluteTime.fromProtocolTimestamp(x.endStamp), ); })?.wireFee; if (fee) { @@ -1337,8 +1338,8 @@ export async function getTotalFeesForDepositAmount( (x) => { return AbsoluteTime.isBetween( AbsoluteTime.now(), - AbsoluteTime.fromTimestamp(x.startStamp), - AbsoluteTime.fromTimestamp(x.endStamp), + AbsoluteTime.fromProtocolTimestamp(x.startStamp), + AbsoluteTime.fromProtocolTimestamp(x.endStamp), ); }, )?.wireFee; |