aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/refresh.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-12-12 21:24:21 +0100
committerFlorian Dold <florian@dold.me>2023-12-12 21:24:28 +0100
commit387416f02dec4a7f948ba96e918e3cacaf92639e (patch)
tree959fde0a7f8c51c2749251ddff32588907e44f4b /packages/taler-wallet-core/src/operations/refresh.ts
parentf7e01690b44e42b7088457374a2a8606fd94f84e (diff)
downloadwallet-core-387416f02dec4a7f948ba96e918e3cacaf92639e.tar.xz
wallet-core: implement maxExpirationDate for checkPeerPushDebit
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts21
1 files changed, 17 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index 51dd9adac..e5bc3277d 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -50,6 +50,7 @@ import {
TalerErrorCode,
TalerErrorDetail,
TalerPreciseTimestamp,
+ TalerProtocolTimestamp,
TransactionAction,
TransactionMajorState,
TransactionState,
@@ -1141,18 +1142,30 @@ function getAutoRefreshCheckThreshold(d: DenominationRecord): AbsoluteTime {
/**
* Timestamp after which the wallet would do an auto-refresh.
*/
-function getAutoRefreshExecuteThreshold(d: DenominationRecord): AbsoluteTime {
+export function getAutoRefreshExecuteThreshold(d: {
+ stampExpireWithdraw: TalerProtocolTimestamp;
+ stampExpireDeposit: TalerProtocolTimestamp;
+}): AbsoluteTime {
const expireWithdraw = AbsoluteTime.fromProtocolTimestamp(
- timestampProtocolFromDb(d.stampExpireWithdraw),
+ d.stampExpireWithdraw,
);
const expireDeposit = AbsoluteTime.fromProtocolTimestamp(
- timestampProtocolFromDb(d.stampExpireDeposit),
+ d.stampExpireDeposit,
);
const delta = AbsoluteTime.difference(expireWithdraw, expireDeposit);
const deltaDiv = durationMul(delta, 0.5);
return AbsoluteTime.addDuration(expireWithdraw, deltaDiv);
}
+function getAutoRefreshExecuteThresholdForDenom(
+ d: DenominationRecord,
+): AbsoluteTime {
+ return getAutoRefreshExecuteThreshold({
+ stampExpireWithdraw: timestampProtocolFromDb(d.stampExpireWithdraw),
+ stampExpireDeposit: timestampProtocolFromDb(d.stampExpireDeposit),
+ });
+}
+
export async function autoRefresh(
ws: InternalWalletState,
exchangeBaseUrl: string,
@@ -1196,7 +1209,7 @@ export async function autoRefresh(
logger.warn("denomination not in database");
continue;
}
- const executeThreshold = getAutoRefreshExecuteThreshold(denom);
+ const executeThreshold = getAutoRefreshExecuteThresholdForDenom(denom);
if (AbsoluteTime.isExpired(executeThreshold)) {
refreshCoins.push({
coinPub: coin.coinPub,