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/withdraw.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/withdraw.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/withdraw.ts | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index c0566bf4d..586aa50f5 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -66,6 +66,7 @@ import { TransactionState, TransactionMajorState, TransactionMinorState, + TalerPreciseTimestamp, } from "@gnu-taler/taler-util"; import { EddsaKeypair } from "../crypto/cryptoImplementation.js"; import { @@ -1327,7 +1328,7 @@ export async function processWithdrawalGroup( } const txStatusOld = computeWithdrawalTransactionStatus(wg); wg.status = WithdrawalGroupStatus.Finished; - wg.timestampFinish = TalerProtocolTimestamp.now(); + wg.timestampFinish = TalerPreciseTimestamp.now(); const txStatusNew = computeWithdrawalTransactionStatus(wg); await tx.withdrawalGroups.put(wg); return { @@ -1428,7 +1429,7 @@ export async function processWithdrawalGroup( logger.info(`now withdrawn ${numFinished} of ${numTotalCoins} coins`); if (wg.timestampFinish === undefined && numFinished === numTotalCoins) { finishedForFirstTime = true; - wg.timestampFinish = TalerProtocolTimestamp.now(); + wg.timestampFinish = TalerPreciseTimestamp.now(); wg.status = WithdrawalGroupStatus.Finished; } @@ -1613,8 +1614,8 @@ export async function getExchangeWithdrawalInfo( } if ( AbsoluteTime.cmp( - AbsoluteTime.fromTimestamp(expireDeposit), - AbsoluteTime.fromTimestamp(earliestDepositExpiration), + AbsoluteTime.fromProtocolTimestamp(expireDeposit), + AbsoluteTime.fromProtocolTimestamp(earliestDepositExpiration), ) < 0 ) { earliestDepositExpiration = expireDeposit; @@ -1910,7 +1911,7 @@ async function registerReserveWithBank( if (r.wgInfo.withdrawalType !== WithdrawalRecordType.BankIntegrated) { throw Error("invariant failed"); } - r.wgInfo.bankInfo.timestampReserveInfoPosted = AbsoluteTime.toTimestamp( + r.wgInfo.bankInfo.timestampReserveInfoPosted = AbsoluteTime.toPreciseTimestamp( AbsoluteTime.now(), ); const oldTxState = computeWithdrawalTransactionStatus(r); @@ -1994,7 +1995,7 @@ async function processReserveBankStatus( if (r.wgInfo.withdrawalType !== WithdrawalRecordType.BankIntegrated) { throw Error("invariant failed"); } - const now = AbsoluteTime.toTimestamp(AbsoluteTime.now()); + const now = AbsoluteTime.toPreciseTimestamp(AbsoluteTime.now()); const oldTxState = computeWithdrawalTransactionStatus(r); r.wgInfo.bankInfo.timestampBankConfirmed = now; r.status = WithdrawalGroupStatus.FailedBankAborted; @@ -2044,7 +2045,7 @@ async function processReserveBankStatus( const oldTxState = computeWithdrawalTransactionStatus(r); if (status.transfer_done) { logger.info("withdrawal: transfer confirmed by bank."); - const now = AbsoluteTime.toTimestamp(AbsoluteTime.now()); + const now = AbsoluteTime.toPreciseTimestamp(AbsoluteTime.now()); r.wgInfo.bankInfo.timestampBankConfirmed = now; r.status = WithdrawalGroupStatus.PendingQueryingStatus; // FIXME: Notification is deprecated with DD37. @@ -2105,7 +2106,7 @@ export async function internalCreateWithdrawalGroup( ): Promise<WithdrawalGroupRecord> { const reserveKeyPair = args.reserveKeyPair ?? (await ws.cryptoApi.createEddsaKeypair({})); - const now = AbsoluteTime.toTimestamp(AbsoluteTime.now()); + const now = AbsoluteTime.toPreciseTimestamp(AbsoluteTime.now()); const secretSeed = encodeCrock(getRandomBytes(32)); const canonExchange = canonicalizeBaseUrl(args.exchangeBaseUrl); const amount = args.amount; @@ -2200,7 +2201,7 @@ export async function internalCreateWithdrawalGroup( const exchange = await tx.exchanges.get(withdrawalGroup.exchangeBaseUrl); if (exchange) { - exchange.lastWithdrawal = TalerProtocolTimestamp.now(); + exchange.lastWithdrawal = TalerPreciseTimestamp.now(); await tx.exchanges.put(exchange); } |