aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/transactions.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-10-07 14:45:25 +0200
committerFlorian Dold <florian@dold.me>2022-10-07 14:45:25 +0200
commitf479ca01390483a8744207bd9b64ea3b7322231c (patch)
tree9cd6c45a0b11b382441e8ab269de1f158eaf76e8 /packages/taler-wallet-core/src/operations/transactions.ts
parenta93a0cae131da4c3dd3f30ac5300f16f759758ff (diff)
downloadwallet-core-f479ca01390483a8744207bd9b64ea3b7322231c.tar.xz
wallet-core: fix/deduplicate funding payto URI generation for withdrawals
Diffstat (limited to 'packages/taler-wallet-core/src/operations/transactions.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts39
1 files changed, 25 insertions, 14 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index be1233d2c..555ba0d8d 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -58,7 +58,10 @@ import { processPurchasePay } from "./pay.js";
import { processRefreshGroup } from "./refresh.js";
import { applyRefundFromPurchaseId } from "./refund.js";
import { processTip } from "./tip.js";
-import { processWithdrawalGroup } from "./withdraw.js";
+import {
+ augmentPaytoUrisForWithdrawal,
+ processWithdrawalGroup,
+} from "./withdraw.js";
const logger = new Logger("taler-wallet-core:transactions.ts");
@@ -473,31 +476,39 @@ function buildTransactionForBankIntegratedWithdraw(
}
function buildTransactionForManualWithdraw(
- wsr: WithdrawalGroupRecord,
+ withdrawalGroup: WithdrawalGroupRecord,
exchangeDetails: ExchangeDetailsRecord,
ort?: OperationRetryRecord,
): Transaction {
- if (wsr.wgInfo.withdrawalType !== WithdrawalRecordType.BankManual)
+ if (withdrawalGroup.wgInfo.withdrawalType !== WithdrawalRecordType.BankManual)
throw Error("");
+ const plainPaytoUris =
+ exchangeDetails.wireInfo?.accounts.map((x) => x.payto_uri) ?? [];
+
+ const exchangePaytoUris = augmentPaytoUrisForWithdrawal(
+ plainPaytoUris,
+ withdrawalGroup.reservePub,
+ withdrawalGroup.instructedAmount,
+ );
+
return {
type: TransactionType.Withdrawal,
- amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
- amountRaw: Amounts.stringify(wsr.rawWithdrawalAmount),
+ amountEffective: Amounts.stringify(
+ withdrawalGroup.denomsSel.totalCoinValue,
+ ),
+ amountRaw: Amounts.stringify(withdrawalGroup.rawWithdrawalAmount),
withdrawalDetails: {
type: WithdrawalType.ManualTransfer,
- reservePub: wsr.reservePub,
- exchangePaytoUris:
- exchangeDetails.wireInfo?.accounts.map((x) =>
- addPaytoQueryParams(x.payto_uri, { subject: wsr.reservePub }),
- ) ?? [],
+ reservePub: withdrawalGroup.reservePub,
+ exchangePaytoUris,
},
- exchangeBaseUrl: wsr.exchangeBaseUrl,
- pending: !wsr.timestampFinish,
- timestamp: wsr.timestampStart,
+ exchangeBaseUrl: withdrawalGroup.exchangeBaseUrl,
+ pending: !withdrawalGroup.timestampFinish,
+ timestamp: withdrawalGroup.timestampStart,
transactionId: makeEventId(
TransactionType.Withdrawal,
- wsr.withdrawalGroupId,
+ withdrawalGroup.withdrawalGroupId,
),
frozen: false,
...(ort?.lastError ? { error: ort.lastError } : {}),