summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pay.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2021-12-23 15:17:36 -0300
committerSebastian <sebasjm@gmail.com>2021-12-23 15:17:36 -0300
commit2e71117f59e0ae6106930e705ae6a54a9839281b (patch)
treea39856486a2801f56c65de245c871ce596f8ab16 /packages/taler-wallet-core/src/operations/pay.ts
parentb8200de6f6c5ab9be3ff9f556c8acda013e574c3 (diff)
downloadwallet-core-2e71117f59e0ae6106930e705ae6a54a9839281b.tar.gz
wallet-core-2e71117f59e0ae6106930e705ae6a54a9839281b.tar.bz2
wallet-core-2e71117f59e0ae6106930e705ae6a54a9839281b.zip
deposit from wallet webex: wip
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pay.ts63
1 files changed, 1 insertions, 62 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts
index 63ccc6531..89930120d 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -177,66 +177,6 @@ export async function getTotalPaymentCost(
});
}
-/**
- * Get the amount that will be deposited on the merchant's bank
- * account, not considering aggregation.
- */
-export async function getEffectiveDepositAmount(
- ws: InternalWalletState,
- wireType: string,
- pcs: PayCoinSelection,
-): Promise<AmountJson> {
- const amt: AmountJson[] = [];
- const fees: AmountJson[] = [];
- const exchangeSet: Set<string> = new Set();
-
- await ws.db
- .mktx((x) => ({
- coins: x.coins,
- denominations: x.denominations,
- exchanges: x.exchanges,
- exchangeDetails: x.exchangeDetails,
- }))
- .runReadOnly(async (tx) => {
- for (let i = 0; i < pcs.coinPubs.length; i++) {
- const coin = await tx.coins.get(pcs.coinPubs[i]);
- if (!coin) {
- throw Error("can't calculate deposit amount, coin not found");
- }
- const denom = await tx.denominations.get([
- coin.exchangeBaseUrl,
- coin.denomPubHash,
- ]);
- if (!denom) {
- throw Error("can't find denomination to calculate deposit amount");
- }
- amt.push(pcs.coinContributions[i]);
- fees.push(denom.feeDeposit);
- exchangeSet.add(coin.exchangeBaseUrl);
- }
- for (const exchangeUrl of exchangeSet.values()) {
- const exchangeDetails = await getExchangeDetails(tx, exchangeUrl);
- if (!exchangeDetails) {
- continue;
- }
- // FIXME/NOTE: the line below _likely_ throws exception
- // about "find method not found on undefined" when the wireType
- // is not supported by the Exchange.
- const fee = exchangeDetails.wireInfo.feesForType[wireType].find((x) => {
- return timestampIsBetween(
- getTimestampNow(),
- x.startStamp,
- x.endStamp,
- );
- })?.wireFee;
- if (fee) {
- fees.push(fee);
- }
- }
- });
- return Amounts.sub(Amounts.sum(amt).amount, Amounts.sum(fees).amount).amount;
-}
-
function isSpendableCoin(coin: CoinRecord, denom: DenominationRecord): boolean {
if (coin.suspended) {
return false;
@@ -585,8 +525,7 @@ async function incrementPurchasePayRetry(
pr.payRetryInfo.retryCounter++;
updateRetryInfoTimeout(pr.payRetryInfo);
logger.trace(
- `retrying pay in ${
- getDurationRemaining(pr.payRetryInfo.nextRetry).d_ms
+ `retrying pay in ${getDurationRemaining(pr.payRetryInfo.nextRetry).d_ms
} ms`,
);
pr.lastPayError = err;