aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pending.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pending.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts
index d1d1bb03a..554766c04 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -30,6 +30,7 @@ import {
OperationStatusRange,
PeerPushPaymentInitiationStatus,
PeerPullPaymentIncomingStatus,
+ PeerPushPaymentIncomingStatus,
} from "../db.js";
import {
PendingOperationsResponse,
@@ -430,6 +431,35 @@ async function gatherPeerPushInitiationPending(
});
}
+async function gatherPeerPushCreditPending(
+ ws: InternalWalletState,
+ tx: GetReadOnlyAccess<{
+ peerPushPaymentIncoming: typeof WalletStoresV1.peerPushPaymentIncoming;
+ operationRetries: typeof WalletStoresV1.operationRetries;
+ }>,
+ now: AbsoluteTime,
+ resp: PendingOperationsResponse,
+): Promise<void> {
+ await tx.peerPushPaymentIncoming.iter().forEachAsync(async (pi) => {
+ switch (pi.status) {
+ case PeerPushPaymentIncomingStatus.Accepted:
+ return;
+ case PeerPushPaymentIncomingStatus.WithdrawalCreated:
+ return;
+ }
+ const opId = RetryTags.forPeerPushCredit(pi);
+ const retryRecord = await tx.operationRetries.get(opId);
+ const timestampDue = retryRecord?.retryInfo.nextRetry ?? AbsoluteTime.now();
+ resp.pendingOperations.push({
+ type: PendingTaskType.PeerPushCredit,
+ ...getPendingCommon(ws, opId, timestampDue),
+ givesLifeness: true,
+ retryInfo: retryRecord?.retryInfo,
+ peerPushPaymentIncomingId: pi.peerPushPaymentIncomingId,
+ });
+ });
+}
+
export async function getPendingOperations(
ws: InternalWalletState,
): Promise<PendingOperationsResponse> {
@@ -451,6 +481,7 @@ export async function getPendingOperations(
x.peerPullPaymentInitiations,
x.peerPushPaymentInitiations,
x.peerPullPaymentIncoming,
+ x.peerPushPaymentIncoming,
])
.runReadWrite(async (tx) => {
const resp: PendingOperationsResponse = {
@@ -467,6 +498,7 @@ export async function getPendingOperations(
await gatherPeerPushInitiationPending(ws, tx, now, resp);
await gatherPeerPullInitiationPending(ws, tx, now, resp);
await gatherPeerPullDebitPending(ws, tx, now, resp);
+ await gatherPeerPushCreditPending(ws, tx, now, resp);
return resp;
});
}