summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pay-merchant.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-05-26 12:19:32 +0200
committerFlorian Dold <florian@dold.me>2023-05-26 12:19:32 +0200
commitcd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854 (patch)
tree423ed7c6fc42ec5e05f655eb093b3b4bdc885996 /packages/taler-wallet-core/src/operations/pay-merchant.ts
parent557dcec30db6573c5d11ca26432008ac6621642e (diff)
downloadwallet-core-cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854.tar.gz
wallet-core-cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854.tar.bz2
wallet-core-cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854.zip
taler-util,wallet-core: implement TalerPreciseTimestamp
Fixes #7703
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-merchant.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index 854202b6a..4ea41c695 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -66,6 +66,7 @@ import {
TalerError,
TalerErrorCode,
TalerErrorDetail,
+ TalerPreciseTimestamp,
TalerProtocolTimestamp,
TalerProtocolViolationError,
TalerUriAction,
@@ -621,7 +622,7 @@ async function createPurchase(
noncePriv: priv,
noncePub: pub,
claimToken,
- timestamp: AbsoluteTime.toTimestamp(AbsoluteTime.now()),
+ timestamp: TalerPreciseTimestamp.now(),
merchantBaseUrl,
orderId,
proposalId: proposalId,
@@ -682,7 +683,7 @@ async function storeFirstPaySuccess(
tag: TransactionType.Payment,
proposalId,
});
- const now = AbsoluteTime.toTimestamp(AbsoluteTime.now());
+ const now = AbsoluteTime.toPreciseTimestamp(AbsoluteTime.now());
const transitionInfo = await ws.db
.mktx((x) => [x.purchases, x.contractTerms])
.runReadWrite(async (tx) => {
@@ -721,7 +722,7 @@ async function storeFirstPaySuccess(
const ar = Duration.fromTalerProtocolDuration(protoAr);
logger.info("auto_refund present");
purchase.purchaseStatus = PurchaseStatus.QueryingAutoRefund;
- purchase.autoRefundDeadline = AbsoluteTime.toTimestamp(
+ purchase.autoRefundDeadline = AbsoluteTime.toProtocolTimestamp(
AbsoluteTime.addDuration(AbsoluteTime.now(), ar),
);
}
@@ -923,7 +924,7 @@ async function unblockBackup(
.forEachAsync(async (bp) => {
bp.state = {
tag: BackupProviderStateTag.Ready,
- nextBackupTimestamp: TalerProtocolTimestamp.now(),
+ nextBackupTimestamp: TalerPreciseTimestamp.now(),
};
tx.backupProviders.put(bp);
});
@@ -1422,7 +1423,7 @@ export async function confirmPay(
totalPayCost: Amounts.stringify(payCostInfo),
};
p.lastSessionId = sessionId;
- p.timestampAccept = TalerProtocolTimestamp.now();
+ p.timestampAccept = TalerPreciseTimestamp.now();
p.purchaseStatus = PurchaseStatus.Paying;
await tx.purchases.put(p);
await spendCoins(ws, tx, {
@@ -1925,7 +1926,7 @@ async function processPurchaseAutoRefund(
if (
!purchase.autoRefundDeadline ||
AbsoluteTime.isExpired(
- AbsoluteTime.fromTimestamp(purchase.autoRefundDeadline),
+ AbsoluteTime.fromProtocolTimestamp(purchase.autoRefundDeadline),
)
) {
const transitionInfo = await ws.db
@@ -2068,9 +2069,9 @@ async function processPurchaseAbortingRefund(
coin_pub: payCoinSelection.coinPubs[i],
refund_amount: Amounts.stringify(payCoinSelection.coinContributions[i]),
rtransaction_id: 0,
- execution_time: AbsoluteTime.toTimestamp(
+ execution_time: AbsoluteTime.toProtocolTimestamp(
AbsoluteTime.addDuration(
- AbsoluteTime.fromTimestamp(download.contractData.timestamp),
+ AbsoluteTime.fromProtocolTimestamp(download.contractData.timestamp),
Duration.fromSpec({ seconds: 1 }),
),
),
@@ -2267,7 +2268,7 @@ async function storeRefunds(
});
const newRefundGroupId = encodeCrock(randomBytes(32));
- const now = TalerProtocolTimestamp.now();
+ const now = TalerPreciseTimestamp.now();
const download = await expectProposalDownload(ws, purchase);
const currency = Amounts.currencyOf(download.contractData.amount);