aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pending.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-02-19 23:13:44 +0100
committerFlorian Dold <florian@dold.me>2023-02-19 23:13:44 +0100
commite6ed901626a5219a1d091f4f41654365d2c29531 (patch)
tree1dfb2fbc7615ebe6e91621b901bf90968bd98edf /packages/taler-wallet-core/src/operations/pending.ts
parent925ef1f410e01323ee24ab9019afcc1713bf07c2 (diff)
downloadwallet-core-e6ed901626a5219a1d091f4f41654365d2c29531.tar.xz
wallet-core: various p2p payment fixes
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pending.ts29
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;
});
}