commit f774d29f6e6d602a2e21ae9fab05ef668c38e570 parent fdf0d7b8c6d363863760785f50c6d31741633c90 Author: Florian Dold <florian@dold.me> Date: Wed, 18 Mar 2026 20:09:26 +0100 wallet-core: more DB cleanup Diffstat:
14 files changed, 223 insertions(+), 241 deletions(-)
diff --git a/packages/taler-wallet-core/src/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts @@ -1610,7 +1610,7 @@ export async function getExchangesForDeposit( wex: WalletExecutionContext, req: { restrictScope?: ScopeInfo; currency: string }, ): Promise<Exchange[]> { - return await wex.db.runAllStoresReadOnlyTx({}, async (tx) => { + return await wex.runLegacyWalletDbTx(async (tx) => { return await getExchangesForDepositInTx(wex, tx, req); }); } @@ -1699,8 +1699,7 @@ export async function getMaxPeerPushDebitAmount( ): Promise<GetMaxPeerPushDebitAmountResponse> { logger.trace(`getting max deposit amount for: ${j2s(req)}`); - return await wex.db.runAllStoresReadWriteTx( - {}, + return await wex.runLegacyWalletDbTx( async (tx): Promise<GetMaxPeerPushDebitAmountResponse> => { let result: GetMaxDepositAmountResponse | undefined = undefined; const currency = req.currency; diff --git a/packages/taler-wallet-core/src/denominations.ts b/packages/taler-wallet-core/src/denominations.ts @@ -640,7 +640,7 @@ export async function processValidateDenoms( ): Promise<TaskRunResult> { logger.trace("validating denoms in background task"); - const denoms = await wex.db.runAllStoresReadOnlyTx({}, async (tx) => { + const denoms = await wex.runLegacyWalletDbTx(async (tx) => { return tx.denominations.indexes.byVerificationStatus.getAll( DenominationVerificationStatus.Unverified, ); diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts @@ -1518,79 +1518,76 @@ async function doCoinSelection( throw Error("assertion failed"); } - const transitionDone = await wex.db.runAllStoresReadWriteTx( - {}, - async (tx) => { - const dg = await tx.depositGroups.get(depositGroupId); - if (!dg) { - return false; - } - if (dg.statusPerCoin) { - return false; - } + const transitionDone = await wex.runLegacyWalletDbTx(async (tx) => { + const dg = await tx.depositGroups.get(depositGroupId); + if (!dg) { + return false; + } + if (dg.statusPerCoin) { + return false; + } - const contractTermsRec = tx.contractTerms.get( - depositGroup.contractTermsHash, - ); - if (!contractTermsRec) { - throw Error("contract terms for deposit not found in database"); - } + const contractTermsRec = tx.contractTerms.get( + depositGroup.contractTermsHash, + ); + if (!contractTermsRec) { + throw Error("contract terms for deposit not found in database"); + } - const payCoinSel = await selectPayCoinsInTx(wex, tx, { - restrictExchanges: { - auditors: [], - exchanges: contractData.exchanges.map((ex) => ({ - exchangeBaseUrl: ex.url, - exchangePub: ex.master_pub, - })), - }, - restrictWireMethod: contractData.wire_method, - depositPaytoUri: dg.wire.payto_uri, - contractTermsAmount: Amounts.parseOrThrow(contractData.amount), - depositFeeLimit: Amounts.parseOrThrow(contractData.max_fee), - prevPayCoins: [], - }); + const payCoinSel = await selectPayCoinsInTx(wex, tx, { + restrictExchanges: { + auditors: [], + exchanges: contractData.exchanges.map((ex) => ({ + exchangeBaseUrl: ex.url, + exchangePub: ex.master_pub, + })), + }, + restrictWireMethod: contractData.wire_method, + depositPaytoUri: dg.wire.payto_uri, + contractTermsAmount: Amounts.parseOrThrow(contractData.amount), + depositFeeLimit: Amounts.parseOrThrow(contractData.max_fee), + prevPayCoins: [], + }); - switch (payCoinSel.type) { - case "success": - logger.info("coin selection success"); - break; - case "failure": - logger.info("coin selection failure"); - throw TalerError.fromDetail( - TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE, - { - insufficientBalanceDetails: payCoinSel.insufficientBalanceDetails, - }, - ); - case "prospective": - logger.info("coin selection prospective"); - throw Error("insufficient balance (waiting on pending refresh)"); - default: - assertUnreachable(payCoinSel); - } + switch (payCoinSel.type) { + case "success": + logger.info("coin selection success"); + break; + case "failure": + logger.info("coin selection failure"); + throw TalerError.fromDetail( + TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE, + { + insufficientBalanceDetails: payCoinSel.insufficientBalanceDetails, + }, + ); + case "prospective": + logger.info("coin selection prospective"); + throw Error("insufficient balance (waiting on pending refresh)"); + default: + assertUnreachable(payCoinSel); + } - dg.payCoinSelection = { - coinContributions: payCoinSel.coinSel.coins.map((x) => x.contribution), - coinPubs: payCoinSel.coinSel.coins.map((x) => x.coinPub), - }; - dg.payCoinSelectionUid = encodeCrock(getRandomBytes(32)); - dg.statusPerCoin = payCoinSel.coinSel.coins.map( - () => DepositElementStatus.DepositPending, - ); - await tx.depositGroups.put(dg); - await ctx.updateTransactionMeta(tx); - await spendCoins(wex, tx, { - transactionId: ctx.transactionId, - coinPubs: dg.payCoinSelection.coinPubs, - contributions: dg.payCoinSelection.coinContributions.map((x) => - Amounts.parseOrThrow(x), - ), - refreshReason: RefreshReason.PayDeposit, - }); - return true; - }, - ); + dg.payCoinSelection = { + coinContributions: payCoinSel.coinSel.coins.map((x) => x.contribution), + coinPubs: payCoinSel.coinSel.coins.map((x) => x.coinPub), + }; + dg.payCoinSelectionUid = encodeCrock(getRandomBytes(32)); + dg.statusPerCoin = payCoinSel.coinSel.coins.map( + () => DepositElementStatus.DepositPending, + ); + await tx.depositGroups.put(dg); + await ctx.updateTransactionMeta(tx); + await spendCoins(wex, tx, { + transactionId: ctx.transactionId, + coinPubs: dg.payCoinSelection.coinPubs, + contributions: dg.payCoinSelection.coinContributions.map((x) => + Amounts.parseOrThrow(x), + ), + refreshReason: RefreshReason.PayDeposit, + }); + return true; + }); if (transitionDone) { return TaskRunResult.progress(); diff --git a/packages/taler-wallet-core/src/dev-experiments.ts b/packages/taler-wallet-core/src/dev-experiments.ts @@ -234,7 +234,7 @@ export async function applyDevExperiment( return; } case "rebuild-transactions": { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { // Re-build / fix up info about exchanges for purchase transactions. await tx.purchases.iter().forEachAsync(async (rec) => { let exchangeSet = new Set<string>(); @@ -460,7 +460,7 @@ async function addFakeTx( } else { timestamp = AbsoluteTime.now(); } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await tx.withdrawalGroups.add({ reservePriv: reservePair.priv, reservePub: reservePair.pub, @@ -554,7 +554,7 @@ async function addFakeTx( wire_transfer_deadline: AbsoluteTime.toProtocolTimestamp(timestamp), }; const contractTermsHash = ContractTermsUtil.hashContractTerms(ct); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await tx.contractTerms.put({ contractTermsRaw: ct, h: contractTermsHash, @@ -636,7 +636,7 @@ async function addFakeTx( const contractTermsHash = ContractTermsUtil.hashContractTerms(ct); const contractPair = await wex.cryptoApi.createEddsaKeypair({}); const mergePair = await wex.cryptoApi.createEddsaKeypair({}); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await tx.contractTerms.put({ contractTermsRaw: ct, h: contractTermsHash, @@ -699,7 +699,7 @@ async function addFakeTx( const contractTermsHash = ContractTermsUtil.hashContractTerms(ct); const contractPair = await wex.cryptoApi.createEddsaKeypair({}); const mergePair = await wex.cryptoApi.createEddsaKeypair({}); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await tx.contractTerms.put({ contractTermsRaw: ct, h: contractTermsHash, diff --git a/packages/taler-wallet-core/src/donau.ts b/packages/taler-wallet-core/src/donau.ts @@ -131,7 +131,7 @@ async function submitDonationReceipts( }), ); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { let donauSummary = await tx.donationSummaries.get([ group.donauBaseUrl, group.year, @@ -284,8 +284,7 @@ export async function handleSetDonau( idHasher.update(stringToBytes(req.taxPayerId + "\0")); idHasher.update(stringToBytes(encodeCrock(salt) + "\0")); const saltedId = idHasher.finish(); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { - const wtx = new IdbWalletTransaction(tx); + await wex.runLegacyWalletDbTx(async (tx, wtx) => { const oldRec = await wtx.getConfig(ConfigRecordKey.DonauConfig); if ( oldRec && @@ -316,20 +315,16 @@ export async function handleGetDonau( wex: WalletExecutionContext, req: EmptyObject, ): Promise<GetDonauResponse> { - const currentDonauInfo = await wex.db.runAllStoresReadWriteTx( - {}, - async (tx) => { - const wtx = new IdbWalletTransaction(tx); - const res = await wtx.getConfig(ConfigRecordKey.DonauConfig); - if (!res) { - return undefined; - } - return { - donauBaseUrl: res.value.donauBaseUrl, - taxPayerId: res.value.donauTaxId, - }; - }, - ); + const currentDonauInfo = await wex.runLegacyWalletDbTx(async (tx, wtx) => { + const res = await wtx.getConfig(ConfigRecordKey.DonauConfig); + if (!res) { + return undefined; + } + return { + donauBaseUrl: res.value.donauBaseUrl, + taxPayerId: res.value.donauTaxId, + }; + }); return { currentDonauInfo }; } @@ -527,7 +522,7 @@ export async function generateDonauPlanchets( logger.trace(`donau planchets: ${j2s(donauPlanchets)}`); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const rec = await tx.purchases.get(proposalId); if (!rec) { return undefined; @@ -621,7 +616,7 @@ export async function acceptDonauBlindSigs( }); } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { for (let i = 0; i < donauBlindedSigs.length; i++) { const myPlanchet = donauPlanchets[i]; const existingReceipt = await tx.donationReceipts.get( diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts @@ -579,7 +579,7 @@ export async function lookupExchangeByUri( wex: WalletExecutionContext, req: GetExchangeEntryByUrlRequest, ): Promise<ExchangeListItem> { - const res = await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const res = await wex.runLegacyWalletDbTx(async (tx) => { const exchangeRec = await tx.exchanges.get(req.exchangeBaseUrl); if (!exchangeRec) { return undefined; @@ -1817,7 +1817,7 @@ export async function updateExchangeFromUrlHandler( } } - const updated = await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const updated = await wex.runLegacyWalletDbTx(async (tx, wtx) => { const r = await tx.exchanges.get(exchangeBaseUrl); if (!r) { logger.warn(`exchange ${exchangeBaseUrl} no longer present`); @@ -1927,8 +1927,6 @@ export async function updateExchangeFromUrlHandler( r.cachebreakNextUpdate = false; await tx.exchanges.put(r); - const wtx = new IdbWalletTransaction(tx); - if (keysInfo.currency_specification) { // Since this is the per-exchange currency info, // we update it when the exchange changes it. @@ -3228,7 +3226,7 @@ export async function deleteExchange( ): Promise<void> { let inUse: boolean = false; const exchangeBaseUrl = req.exchangeBaseUrl; - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const exchangeRec = await tx.exchanges.get(exchangeBaseUrl); if (!exchangeRec) { // Nothing to delete! @@ -4071,7 +4069,7 @@ export async function migrateExchange( wex: WalletExecutionContext, req: MigrateExchangeRequest, ): Promise<void> { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const migrationRec = await tx.exchangeBaseUrlMigrationLog.get([ req.oldExchangeBaseUrl, req.newExchangeBaseUrl, diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -445,7 +445,7 @@ export class PayMerchantTransactionContext implements TransactionContext { async abortTransaction(reason?: TalerErrorDetail): Promise<void> { const { wex } = this; - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [purchase, h] = await this.getRecordHandle(tx); if (!purchase) { throw Error("purchase not found"); @@ -501,7 +501,7 @@ export class PayMerchantTransactionContext implements TransactionContext { async failTransaction(reason?: TalerErrorDetail): Promise<void> { const { wex } = this; - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [purchase, h] = await this.getRecordHandle(tx); if (!purchase) { throw Error("purchase not found"); @@ -1350,7 +1350,7 @@ async function createOrReusePurchase( // if this transaction was shared and the order is paid then it // means that another wallet already paid the proposal if (paid) { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await oldCtx.getRecordHandle(tx); // The order is only paid by another wallet // if the merchant says it's paid but the local @@ -1453,7 +1453,7 @@ async function storeFirstPaySuccess( ): Promise<void> { const ctx = new PayMerchantTransactionContext(wex, proposalId); const now = AbsoluteTime.toPreciseTimestamp(AbsoluteTime.now()); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [purchase, h] = await ctx.getRecordHandle(tx); if (!purchase) { return; @@ -1506,7 +1506,7 @@ async function storePayReplaySuccess( sessionId: string | undefined, ): Promise<void> { const ctx = new PayMerchantTransactionContext(wex, proposalId); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [purchase, h] = await ctx.getRecordHandle(tx); if (!purchase) { return; @@ -1739,7 +1739,7 @@ async function handleInsufficientFunds( // FIXME: Above code should go into the transaction. // TODO: also do token re-selection. - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await reselectCoinsTx(tx, ctx); }); @@ -1939,7 +1939,7 @@ async function checkPaymentByProposalId( "automatically re-submitting payment with different session ID", ); logger.trace(`last: ${purchaseRec.lastSessionId}, current: ${sessionId}`); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [p, h] = await ctx.getRecordHandle(tx); if (!p) { return; @@ -2779,7 +2779,7 @@ export async function confirmPay( `recording payment on ${proposal.orderId} with session ID ${sessionId}`, ); - await wex.runLegacyWalletDbTx(async (tx) => { + await wex.runLegacyWalletDbTx(async (tx, wtx) => { const [p, h] = await ctx.getRecordHandle(tx); if (!p) { return; @@ -2855,8 +2855,6 @@ export async function confirmPay( p.download.currency = Amounts.currencyOf(amount); } - const wtx = new IdbWalletTransaction(tx); - const confRes = await wtx.getConfig(ConfigRecordKey.DonauConfig); logger.info( @@ -3093,7 +3091,7 @@ async function processPurchasePay( const paid = await checkIfOrderIsAlreadyPaid(wex, download, false); if (paid) { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [p, h] = await ctx.getRecordHandle(tx); if (!p) { return; @@ -3163,49 +3161,46 @@ async function processPurchasePay( selectCoinsResult.coinSel.coins, ); - const transitionDone = await wex.db.runAllStoresReadWriteTx( - {}, - async (tx) => { - const p = await tx.purchases.get(proposalId); - if (!p) { - return false; - } - if (p.payInfo?.payCoinSelection) { - return false; - } - switch (p.purchaseStatus) { - case PurchaseStatus.DialogShared: - case PurchaseStatus.DialogProposed: - case PurchaseStatus.PendingPaying: - p.payInfo = { - totalPayCost: Amounts.stringify(payCostInfo), - payCoinSelection: { - coinContributions: selectCoinsResult.coinSel.coins.map( - (x) => x.contribution, - ), - coinPubs: selectCoinsResult.coinSel.coins.map((x) => x.coinPub), - }, - }; - p.payInfo.payCoinSelectionUid = encodeCrock(getRandomBytes(16)); - p.purchaseStatus = PurchaseStatus.PendingPaying; - await tx.purchases.put(p); - await ctx.updateTransactionMeta(tx); - await spendCoins(wex, tx, { - transactionId: ctx.transactionId, - coinPubs: selectCoinsResult.coinSel.coins.map((x) => x.coinPub), - contributions: selectCoinsResult.coinSel.coins.map((x) => - Amounts.parseOrThrow(x.contribution), - ), - refreshReason: RefreshReason.PayMerchant, - }); - return true; - case PurchaseStatus.Done: - default: - break; - } + const transitionDone = await wex.runLegacyWalletDbTx(async (tx) => { + const p = await tx.purchases.get(proposalId); + if (!p) { return false; - }, - ); + } + if (p.payInfo?.payCoinSelection) { + return false; + } + switch (p.purchaseStatus) { + case PurchaseStatus.DialogShared: + case PurchaseStatus.DialogProposed: + case PurchaseStatus.PendingPaying: + p.payInfo = { + totalPayCost: Amounts.stringify(payCostInfo), + payCoinSelection: { + coinContributions: selectCoinsResult.coinSel.coins.map( + (x) => x.contribution, + ), + coinPubs: selectCoinsResult.coinSel.coins.map((x) => x.coinPub), + }, + }; + p.payInfo.payCoinSelectionUid = encodeCrock(getRandomBytes(16)); + p.purchaseStatus = PurchaseStatus.PendingPaying; + await tx.purchases.put(p); + await ctx.updateTransactionMeta(tx); + await spendCoins(wex, tx, { + transactionId: ctx.transactionId, + coinPubs: selectCoinsResult.coinSel.coins.map((x) => x.coinPub), + contributions: selectCoinsResult.coinSel.coins.map((x) => + Amounts.parseOrThrow(x.contribution), + ), + refreshReason: RefreshReason.PayMerchant, + }); + return true; + case PurchaseStatus.Done: + default: + break; + } + return false; + }); if (transitionDone) { return TaskRunResult.progress(); @@ -3641,7 +3636,7 @@ export async function refuseProposal( proposalId: string, ): Promise<void> { const ctx = new PayMerchantTransactionContext(wex, proposalId); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [proposal, h] = await ctx.getRecordHandle(tx); switch (proposal?.purchaseStatus) { case PurchaseStatus.DialogProposed: @@ -4116,7 +4111,7 @@ async function processPurchaseDialogShared( return TaskRunResult.backoff(); } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [p, h] = await ctx.getRecordHandle(tx); switch (p?.purchaseStatus) { case PurchaseStatus.DialogShared: @@ -4178,7 +4173,7 @@ async function processPurchaseAutoRefund( // is over or the product is already fully refunded. if (noAutoRefundOrExpired || fullyRefunded) { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [p, h] = await ctx.getRecordHandle(tx); switch (p?.purchaseStatus) { case PurchaseStatus.PendingQueryingAutoRefund: @@ -4215,7 +4210,7 @@ async function processPurchaseAutoRefund( return TaskRunResult.longpollReturnedPending(); } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); switch (rec?.purchaseStatus) { case PurchaseStatus.PendingQueryingAutoRefund: @@ -4247,7 +4242,7 @@ async function processPurchaseAbortingRefund( const payCoinSelection = purchase.payInfo?.payCoinSelection; if (!payCoinSelection) { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (rec?.purchaseStatus !== PurchaseStatus.AbortingWithRefund) { return; @@ -4261,7 +4256,7 @@ async function processPurchaseAbortingRefund( return TaskRunResult.finished(); } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -4319,7 +4314,7 @@ async function processPurchaseAbortingRefund( err.code === TalerErrorCode.MERCHANT_POST_ORDERS_ID_ABORT_CONTRACT_NOT_FOUND ) { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (rec?.purchaseStatus !== PurchaseStatus.AbortingWithRefund) { return; @@ -4391,7 +4386,7 @@ async function processPurchaseQueryRefund( const ctx = new PayMerchantTransactionContext(wex, proposalId); if (!orderStatus.refund_pending) { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [p, h] = await ctx.getRecordHandle(tx); if (p?.purchaseStatus !== PurchaseStatus.PendingQueryingRefund) { return; @@ -4406,7 +4401,7 @@ async function processPurchaseQueryRefund( Amounts.parseOrThrow(orderStatus.refund_taken), ).amount; - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [p, h] = await ctx.getRecordHandle(tx); if (p?.purchaseStatus !== PurchaseStatus.PendingQueryingRefund) { return; @@ -4581,7 +4576,7 @@ async function storeRefunds( const currency = Amounts.currencyOf(amountRaw); - const result = await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const result = await wex.runLegacyWalletDbTx(async (tx) => { const [myPurchase, h] = await ctx.getRecordHandle(tx); if (!myPurchase) { logger.warn("purchase group not found anymore"); diff --git a/packages/taler-wallet-core/src/pay-peer-pull-credit.ts b/packages/taler-wallet-core/src/pay-peer-pull-credit.ts @@ -323,7 +323,7 @@ export class PeerPullCreditTransactionContext implements TransactionContext { } async suspendTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -371,7 +371,7 @@ export class PeerPullCreditTransactionContext implements TransactionContext { } async failTransaction(reason?: TalerErrorDetail): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -408,7 +408,7 @@ export class PeerPullCreditTransactionContext implements TransactionContext { } async resumeTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -456,7 +456,7 @@ export class PeerPullCreditTransactionContext implements TransactionContext { } async abortTransaction(reason?: TalerErrorDetail): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -514,7 +514,7 @@ async function queryPurseForPeerPullCredit( break; case HttpStatusCode.Gone: // Exchange says that purse doesn't exist anymore => expired! - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -563,7 +563,7 @@ async function queryPurseForPeerPullCredit( pub: reserve.reservePub, }, }); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -629,7 +629,7 @@ async function processPendingMergeKycRequired( checkProtocolInvariant(algoRes.requiresAuth != true); - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -660,7 +660,7 @@ async function processPeerPullCreditAbortingDeletePurse( switch (resp.case) { case "ok": case HttpStatusCode.NotFound: - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -697,7 +697,7 @@ async function processPeerPullCreditWithdrawing( const ctx = new PeerPullCreditTransactionContext(wex, pullIni.pursePub); const wgId = pullIni.withdrawalGroupId; - return await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + return await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (rec?.status !== PeerPullPaymentCreditStatus.PendingWithdrawing) { return TaskRunResult.backoff(); @@ -762,7 +762,7 @@ async function processPeerPullCreditCreatePurse( amount: kycCheckRes.nextThreshold, exchangeBaseUrl: pullIni.exchangeBaseUrl, }); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -872,7 +872,7 @@ async function processPeerPullCreditCreatePurse( assertUnreachable(resp); } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -977,7 +977,7 @@ async function processPeerPullCreditBalanceKyc( }); if (ret.result === "ok") { - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -997,7 +997,7 @@ async function processPeerPullCreditBalanceKyc( peerInc.status === PeerPullPaymentCreditStatus.PendingBalanceKycInit && ret.walletKycStatus === ExchangeWalletKycStatus.Legi ) { - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -1025,7 +1025,7 @@ async function handlePeerPullCreditKycRequired( ): Promise<TaskRunResult> { const ctx = new PeerPullCreditTransactionContext(wex, peerIni.pursePub); - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -1197,7 +1197,7 @@ export async function initiatePeerPullPayment( const ctx = new PeerPullCreditTransactionContext(wex, pursePair.pub); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await tx.contractTerms.put({ contractTermsRaw: contractTerms, h: hContractTerms, diff --git a/packages/taler-wallet-core/src/pay-peer-pull-debit.ts b/packages/taler-wallet-core/src/pay-peer-pull-debit.ts @@ -223,7 +223,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext { } async suspendTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -251,7 +251,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext { } async resumeTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -277,7 +277,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext { } async failTransaction(reason?: TalerErrorDetail): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -300,7 +300,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext { } async abortTransaction(reason?: TalerErrorDetail): Promise<void> { - const oldRec = await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const oldRec = await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, _] = await this.getRecordHandle(tx); return rec; }); @@ -310,7 +310,7 @@ export class PeerPullDebitTransactionContext implements TransactionContext { const currency = Amounts.currencyOf(oldRec.amount); await updateWithdrawalDenomsForCurrency(this.wex, currency); - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [pi, h] = await this.getRecordHandle(tx); if (!pi) { return; @@ -419,7 +419,7 @@ async function handlePurseCreationConflict( coinSelRes.result.coins, ); - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -459,7 +459,7 @@ async function processPeerPullDebitDialogProposed( break; case HttpStatusCode.Gone: // Exchange says that purse doesn't exist anymore => expired! - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -483,7 +483,7 @@ async function processPeerPullDebitDialogProposed( if (isPurseDeposited(resp.body)) { logger.info("purse completed by another wallet"); - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); switch (rec?.status) { case PeerPullDebitRecordStatus.DialogProposed: @@ -551,7 +551,7 @@ async function processPeerPullDebitPendingDeposit( } const totalAmount = await getTotalPeerPaymentCost(wex, coins); - return await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + return await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return TaskRunResult.finished(); @@ -636,7 +636,7 @@ async function processPeerPullDebitPendingDeposit( } } // All batches succeeded, we can transition! - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); switch (rec?.status) { case PeerPullDebitRecordStatus.PendingDeposit: @@ -658,7 +658,7 @@ async function processPeerPullDebitAbortingRefresh( const abortRefreshGroupId = peerPullInc.abortRefreshGroupId; checkLogicInvariant(!!abortRefreshGroupId); const ctx = new PeerPullDebitTransactionContext(wex, peerPullDebitId); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const refreshGroup = await tx.refreshGroups.get(abortRefreshGroupId); const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { @@ -781,7 +781,7 @@ export async function confirmPeerPullDebit( const totalAmount = await getTotalPeerPaymentCost(wex, coins); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -1001,7 +1001,7 @@ export async function preparePeerPullDebit( const ctx = new PeerPullDebitTransactionContext(wex, peerPullDebitId); - const ret = await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const ret = await wex.runLegacyWalletDbTx(async (tx) => { await tx.contractTerms.put({ h: contractTermsHash, contractTermsRaw: contractTerms, diff --git a/packages/taler-wallet-core/src/pay-peer-push-credit.ts b/packages/taler-wallet-core/src/pay-peer-push-credit.ts @@ -311,7 +311,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { } async suspendTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -353,7 +353,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { } async abortTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -386,7 +386,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { } async resumeTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -428,7 +428,7 @@ export class PeerPushCreditTransactionContext implements TransactionContext { } async failTransaction(reason?: TalerErrorDetail): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -621,7 +621,7 @@ export async function preparePeerPushCredit( const ctx = new PeerPushCreditTransactionContext(wex, peerPushCreditId); - const res = await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const res = await wex.runLegacyWalletDbTx(async (tx) => { await tx.contractTerms.put({ h: contractTermsHash, contractTermsRaw: dec.contractTerms, @@ -718,7 +718,7 @@ async function processPeerPushDebitMergeKyc( checkProtocolInvariant(algoRes.requiresAuth != true); - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -778,7 +778,7 @@ async function processPendingMerge( amount: kycCheckRes.nextThreshold, exchangeBaseUrl: peerInc.exchangeBaseUrl, }); - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -857,7 +857,7 @@ async function processPendingMerge( ); case HttpStatusCode.Conflict: // FIXME: Check signature. - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -876,7 +876,7 @@ async function processPendingMerge( }); return TaskRunResult.finished(); case HttpStatusCode.Gone: - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -918,7 +918,7 @@ async function processPendingMerge( }, }); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [peerInc, h] = await ctx.getRecordHandle(tx); if (!peerInc) { return undefined; @@ -956,7 +956,7 @@ async function processPendingWithdrawing( peerInc.peerPushCreditId, ); const wgId = peerInc.withdrawalGroupId; - return await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + return await wex.runLegacyWalletDbTx(async (tx) => { const [ppi, h] = await ctx.getRecordHandle(tx); if (!ppi) { return TaskRunResult.finished(); @@ -1032,7 +1032,7 @@ async function processPeerPushDebitDialogProposed( break; case HttpStatusCode.Gone: // Exchange says that purse doesn't exist anymore => expired! - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -1057,7 +1057,7 @@ async function processPeerPushDebitDialogProposed( if (isPurseMerged(resp.body)) { logger.info("purse completed by another wallet"); - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -1087,8 +1087,7 @@ export async function processPeerPushCredit( } const ctx = new PeerPushCreditTransactionContext(wex, peerPushCreditId); - const { peerInc, contractTerms } = await wex.db.runAllStoresReadWriteTx( - {}, + const { peerInc, contractTerms } = await wex.runLegacyWalletDbTx( async (tx) => { const rec = await tx.peerPushCredit.get(peerPushCreditId); let contractTerms = null; @@ -1184,7 +1183,7 @@ async function processPeerPushCreditBalanceKyc( }); if (ret.result === "ok") { - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -1202,7 +1201,7 @@ async function processPeerPushCreditBalanceKyc( peerInc.status === PeerPushCreditStatus.PendingBalanceKycInit && ret.walletKycStatus === ExchangeWalletKycStatus.Legi ) { - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -1269,7 +1268,7 @@ export async function confirmPeerPushCredit( throw Error("peer credit would exceed hard KYC limit"); } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; diff --git a/packages/taler-wallet-core/src/pay-peer-push-debit.ts b/packages/taler-wallet-core/src/pay-peer-push-debit.ts @@ -231,7 +231,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext { } async suspendTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -264,7 +264,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext { } async abortTransaction(reason?: TalerErrorDetail): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -299,7 +299,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext { } async resumeTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -332,7 +332,7 @@ export class PeerPushDebitTransactionContext implements TransactionContext { } async failTransaction(reason?: TalerErrorDetail): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -533,7 +533,7 @@ async function handlePurseCreationConflict( assertUnreachable(coinSelRes); } - await ctx.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await ctx.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -603,7 +603,7 @@ async function processPeerPushDebitCreateReserve( assertUnreachable(coinSelRes); } - return await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + return await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return TaskRunResult.backoff(); @@ -728,7 +728,7 @@ async function processPeerPushDebitCreateReserve( continue; case HttpStatusCode.Gone: // FIXME we need PeerPushDebitStatus.ExpiredDeletePurse - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -765,7 +765,7 @@ async function processPeerPushDebitCreateReserve( const resp = await exchangeClient.getPurseStatusAtDeposit(pursePub); switch (resp.case) { case "ok": - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -783,7 +783,7 @@ async function processPeerPushDebitCreateReserve( return TaskRunResult.progress(); case HttpStatusCode.Gone: // FIXME we need PeerPushDebitStatus.ExpiredDeletePurse - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -834,7 +834,7 @@ async function processPeerPushDebitAbortingDeletePurse( await updateWithdrawalDenomsForCurrency(wex, currency); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -896,7 +896,7 @@ async function processPeerPushDebitReady( if (!isPurseMerged(resp.body)) { return TaskRunResult.longpollReturnedPending(); } else { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; @@ -916,7 +916,7 @@ async function processPeerPushDebitReady( } case HttpStatusCode.Gone: logger.info(`purse ${pursePub} is gone, aborting peer-push-debit`); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await ctx.getRecordHandle(tx); if (!rec) { return; diff --git a/packages/taler-wallet-core/src/refresh.ts b/packages/taler-wallet-core/src/refresh.ts @@ -237,7 +237,7 @@ export class RefreshTransactionContext implements TransactionContext { } async deleteTransaction(): Promise<void> { - const res = await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const res = await this.wex.runLegacyWalletDbTx(async (tx) => { return this.deleteTransactionInTx(tx); }); } @@ -265,7 +265,7 @@ export class RefreshTransactionContext implements TransactionContext { } async suspendTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -298,7 +298,7 @@ export class RefreshTransactionContext implements TransactionContext { } async resumeTransaction(): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -326,7 +326,7 @@ export class RefreshTransactionContext implements TransactionContext { } async failTransaction(reason?: TalerErrorDetail): Promise<void> { - await this.wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await this.wex.runLegacyWalletDbTx(async (tx) => { const [rec, h] = await this.getRecordHandle(tx); if (!rec) { return; @@ -1434,8 +1434,7 @@ async function processRefreshSession( logger.trace( `processing refresh session for coin ${coinIndex} of group ${refreshGroupId}`, ); - let { refreshGroup, refreshSession } = await wex.db.runAllStoresReadWriteTx( - {}, + let { refreshGroup, refreshSession } = await wex.runLegacyWalletDbTx( async (tx) => { const rg = await tx.refreshGroups.get(refreshGroupId); const rs = await tx.refreshSessions.get([refreshGroupId, coinIndex]); @@ -1747,7 +1746,7 @@ async function redenominateRefresh( const ctx = new RefreshTransactionContext(wex, refreshGroupId); logger.info(`re-denominating refresh group ${refreshGroupId}`); - const exchanges = await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const exchanges = await wex.runLegacyWalletDbTx(async (tx) => { const [rg, _] = await ctx.getRecordHandle(tx); if (rg?.infoPerExchange) { return Object.keys(rg.infoPerExchange); @@ -1760,7 +1759,7 @@ async function redenominateRefresh( await updateWithdrawalDenomsForExchange(wex, e); } - return await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + return await wex.runLegacyWalletDbTx(async (tx) => { const [refreshGroup, h] = await ctx.getRecordHandle(tx); if (!refreshGroup) { return TaskRunResult.finished(); @@ -1889,7 +1888,7 @@ export async function forceRefresh( if (req.refreshCoinSpecs.length == 0) { throw Error("refusing to create empty refresh group"); } - const res = await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const res = await wex.runLegacyWalletDbTx(async (tx) => { const coinPubs: CoinRefreshRequest[] = []; for (const c of req.refreshCoinSpecs) { const coin = await tx.coins.get(c.coinPub); diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -571,7 +571,7 @@ const MATERIALIZED_TRANSACTIONS_VERSION = 2; async function migrateMaterializedTransactions( wex: WalletExecutionContext, ): Promise<void> { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const ver = await tx.config.get("materializedTransactionsVersion"); if (ver) { if (ver.key !== ConfigRecordKey.MaterializedTransactionsVersion) { @@ -869,7 +869,7 @@ async function recoverStoredBackup( }); logger.info(`backup found, now importing`); await importDb(wex.db.idbHandle(), bd); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await rematerializeTransactions(wex, tx); // Clear fixups. Okay since they are idempotent. const fixups = await tx.fixups.getAll(); @@ -1101,7 +1101,7 @@ async function handleAddExchange( // Exchange has been explicitly added upon user request. // Thus, we mark it as "used". if (!req.ephemeral) { - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await markExchangeUsed(tx, exchangeBaseUrl); }); } @@ -1769,7 +1769,7 @@ async function handleImportDb( ): Promise<EmptyObject> { // FIXME: This should atomically re-materialize transactions! await importDb(wex.db.idbHandle(), req.dump); - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await rematerializeTransactions(wex, tx); // Clear fixups. Okay since they are idempotent. const fixups = await tx.fixups.getAll(); @@ -1886,7 +1886,7 @@ export async function handleTestingRunFixup( if (fixup.name != req.id) { continue; } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await fixup.fn(tx); await rematerializeTransactions(wex, tx); }); @@ -2044,7 +2044,7 @@ export async function handleTestingCorruptWithdrawalCoinSel( if (txId?.tag !== TransactionType.Withdrawal) { throw Error("expected withdrawal transaction ID"); } - await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { const wg = await tx.withdrawalGroups.get(txId.withdrawalGroupId); if (!wg) { return; @@ -3458,7 +3458,7 @@ export class InternalWalletState { undefined, oc, ); - await dbAccess.runAllStoresReadWriteTx({}, async (tx) => { + await wex.runLegacyWalletDbTx(async (tx) => { await rematerializeTransactions(wex, tx); }); } diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts @@ -2077,7 +2077,7 @@ async function getWithdrawalCandidateDenoms( amount: AmountString, ): Promise<DenominationRecord[]> { await updateWithdrawalDenomsForExchange(wex, exchangeBaseUrl); - return await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + return await wex.runLegacyWalletDbTx(async (tx) => { return await getWithdrawableDenomsTx( wex, tx,