diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pending.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index a73af528c..d1d1bb03a 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -29,6 +29,7 @@ import { OperationStatus, OperationStatusRange, PeerPushPaymentInitiationStatus, + PeerPullPaymentIncomingStatus, } from "../db.js"; import { PendingOperationsResponse, @@ -377,6 +378,32 @@ async function gatherPeerPullInitiationPending( }); } +async function gatherPeerPullDebitPending( + ws: InternalWalletState, + tx: GetReadOnlyAccess<{ + peerPullPaymentIncoming: typeof WalletStoresV1.peerPullPaymentIncoming; + operationRetries: typeof WalletStoresV1.operationRetries; + }>, + now: AbsoluteTime, + resp: PendingOperationsResponse, +): Promise<void> { + await tx.peerPullPaymentIncoming.iter().forEachAsync(async (pi) => { + if (pi.status === PeerPullPaymentIncomingStatus.Paid) { + return; + } + const opId = RetryTags.forPeerPullPaymentDebit(pi); + const retryRecord = await tx.operationRetries.get(opId); + const timestampDue = retryRecord?.retryInfo.nextRetry ?? AbsoluteTime.now(); + resp.pendingOperations.push({ + type: PendingTaskType.PeerPullDebit, + ...getPendingCommon(ws, opId, timestampDue), + givesLifeness: true, + retryInfo: retryRecord?.retryInfo, + peerPullPaymentIncomingId: pi.peerPullPaymentIncomingId, + }); + }); +} + async function gatherPeerPushInitiationPending( ws: InternalWalletState, tx: GetReadOnlyAccess<{ @@ -423,6 +450,7 @@ export async function getPendingOperations( x.operationRetries, x.peerPullPaymentInitiations, x.peerPushPaymentInitiations, + x.peerPullPaymentIncoming, ]) .runReadWrite(async (tx) => { const resp: PendingOperationsResponse = { @@ -438,6 +466,7 @@ export async function getPendingOperations( await gatherBackupPending(ws, tx, now, resp); await gatherPeerPushInitiationPending(ws, tx, now, resp); await gatherPeerPullInitiationPending(ws, tx, now, resp); + await gatherPeerPullDebitPending(ws, tx, now, resp); return resp; }); } |