diff options
author | Florian Dold <florian@dold.me> | 2022-08-09 15:00:45 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-08-16 17:55:12 +0200 |
commit | ac8f116780a860c8f4acfdf5553bf90d76afe236 (patch) | |
tree | 38abecb5ad3a3660161909ee9ca229d4ce08eb4a /packages/taler-wallet-core/src/operations/transactions.ts | |
parent | fb8372dfbf27b7b4e8b2fe4f81aa2ba18bfcf638 (diff) | |
download | wallet-core-ac8f116780a860c8f4acfdf5553bf90d76afe236.tar.xz |
implement peer to peer push payments
Diffstat (limited to 'packages/taler-wallet-core/src/operations/transactions.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 88 |
1 files changed, 6 insertions, 82 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index ebc223b23..ae4ce6999 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -36,7 +36,6 @@ import { InternalWalletState } from "../internal-wallet-state.js"; import { AbortStatus, RefundState, - ReserveRecord, ReserveRecordStatus, WalletRefundItem, } from "../db.js"; @@ -44,9 +43,8 @@ import { processDepositGroup } from "./deposits.js"; import { getExchangeDetails } from "./exchanges.js"; import { processPurchasePay } from "./pay.js"; import { processRefreshGroup } from "./refresh.js"; -import { getFundingPaytoUris } from "./reserves.js"; import { processTip } from "./tip.js"; -import { processWithdrawGroup } from "./withdraw.js"; +import { processWithdrawalGroup } from "./withdraw.js"; const logger = new Logger("taler-wallet-core:transactions.ts"); @@ -127,7 +125,6 @@ export async function getTransactions( proposals: x.proposals, purchases: x.purchases, refreshGroups: x.refreshGroups, - reserves: x.reserves, tips: x.tips, withdrawalGroups: x.withdrawalGroups, planchets: x.planchets, @@ -151,24 +148,13 @@ export async function getTransactions( if (shouldSkipSearch(transactionsRequest, [])) { return; } - - const r = await tx.reserves.get(wsr.reservePub); - if (!r) { - return; - } - let amountRaw: AmountJson | undefined = undefined; - if (wsr.withdrawalGroupId === r.initialWithdrawalGroupId) { - amountRaw = r.instructedAmount; - } else { - amountRaw = wsr.denomsSel.totalWithdrawCost; - } let withdrawalDetails: WithdrawalDetails; - if (r.bankInfo) { + if (wsr.bankInfo) { withdrawalDetails = { type: WithdrawalType.TalerBankIntegrationApi, - confirmed: r.timestampBankConfirmed ? true : false, + confirmed: wsr.bankInfo.timestampBankConfirmed ? true : false, reservePub: wsr.reservePub, - bankConfirmationUrl: r.bankInfo.confirmUrl, + bankConfirmationUrl: wsr.bankInfo.confirmUrl, }; } else { const exchangeDetails = await getExchangeDetails( @@ -191,7 +177,7 @@ export async function getTransactions( transactions.push({ type: TransactionType.Withdrawal, amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), - amountRaw: Amounts.stringify(amountRaw), + amountRaw: Amounts.stringify(wsr.rawWithdrawalAmount), withdrawalDetails, exchangeBaseUrl: wsr.exchangeBaseUrl, pending: !wsr.timestampFinish, @@ -205,56 +191,6 @@ export async function getTransactions( }); }); - // Report pending withdrawals based on reserves that - // were created, but where the actual withdrawal group has - // not started yet. - tx.reserves.iter().forEachAsync(async (r) => { - if (shouldSkipCurrency(transactionsRequest, r.currency)) { - return; - } - if (shouldSkipSearch(transactionsRequest, [])) { - return; - } - if (r.initialWithdrawalStarted) { - return; - } - if (r.reserveStatus === ReserveRecordStatus.BankAborted) { - return; - } - let withdrawalDetails: WithdrawalDetails; - if (r.bankInfo) { - withdrawalDetails = { - type: WithdrawalType.TalerBankIntegrationApi, - confirmed: false, - reservePub: r.reservePub, - bankConfirmationUrl: r.bankInfo.confirmUrl, - }; - } else { - withdrawalDetails = { - type: WithdrawalType.ManualTransfer, - reservePub: r.reservePub, - exchangePaytoUris: await getFundingPaytoUris(tx, r.reservePub), - }; - } - transactions.push({ - type: TransactionType.Withdrawal, - amountRaw: Amounts.stringify(r.instructedAmount), - amountEffective: Amounts.stringify( - r.initialDenomSel.totalCoinValue, - ), - exchangeBaseUrl: r.exchangeBaseUrl, - pending: true, - timestamp: r.timestampCreated, - withdrawalDetails: withdrawalDetails, - transactionId: makeEventId( - TransactionType.Withdrawal, - r.initialWithdrawalGroupId, - ), - frozen: false, - ...(r.lastError ? { error: r.lastError } : {}), - }); - }); - tx.depositGroups.iter().forEachAsync(async (dg) => { const amount = Amounts.parseOrThrow(dg.contractTermsRaw.amount); if (shouldSkipCurrency(transactionsRequest, amount.currency)) { @@ -499,7 +435,7 @@ export async function retryTransaction( } case TransactionType.Withdrawal: { const withdrawalGroupId = rest[0]; - await processWithdrawGroup(ws, withdrawalGroupId, { forceNow: true }); + await processWithdrawalGroup(ws, withdrawalGroupId, { forceNow: true }); break; } case TransactionType.Payment: { @@ -536,7 +472,6 @@ export async function deleteTransaction( await ws.db .mktx((x) => ({ withdrawalGroups: x.withdrawalGroups, - reserves: x.reserves, tombstones: x.tombstones, })) .runReadWrite(async (tx) => { @@ -550,17 +485,6 @@ export async function deleteTransaction( }); return; } - const reserveRecord: ReserveRecord | undefined = - await tx.reserves.indexes.byInitialWithdrawalGroupId.get( - withdrawalGroupId, - ); - if (reserveRecord && !reserveRecord.initialWithdrawalStarted) { - const reservePub = reserveRecord.reservePub; - await tx.reserves.delete(reservePub); - await tx.tombstones.put({ - id: TombstoneTag.DeleteReserve + ":" + reservePub, - }); - } }); } else if (type === TransactionType.Payment) { const proposalId = rest[0]; |