diff options
author | Florian Dold <florian@dold.me> | 2021-03-15 13:43:53 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-03-15 13:44:25 +0100 |
commit | 44b1896b9ec8af72aa0eb25e8c89a4cc0c841766 (patch) | |
tree | 5a1b60cfd7334a64bb9cf6e465b3d62ee9dacde0 /packages/taler-wallet-core/src/operations/deposits.ts | |
parent | fb3da3a28d6ed6a16ca7d0fa8ec775de51c7df6b (diff) | |
download | wallet-core-44b1896b9ec8af72aa0eb25e8c89a4cc0c841766.tar.xz |
improved pay coin selection
support for multiple exchanges and healing a previous selection
Diffstat (limited to 'packages/taler-wallet-core/src/operations/deposits.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/deposits.ts | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts index 50921a170..53f2529b2 100644 --- a/packages/taler-wallet-core/src/operations/deposits.ts +++ b/packages/taler-wallet-core/src/operations/deposits.ts @@ -37,6 +37,7 @@ import { codecForString, codecOptional, } from "../util/codec"; +import { selectPayCoins } from "../util/coinSelection"; import { canonicalJson } from "../util/helpers"; import { readSuccessResponseJsonOrThrow } from "../util/http"; import { parsePaytoUri } from "../util/payto"; @@ -54,7 +55,7 @@ import { applyCoinSpend, extractContractData, generateDepositPermissions, - getCoinsForPayment, + getCandidatePayCoins, getEffectiveDepositAmount, getTotalPaymentCost, } from "./pay"; @@ -363,7 +364,26 @@ export async function createDepositGroup( "", ); - const payCoinSel = await getCoinsForPayment(ws, contractData); + const candidates = await getCandidatePayCoins(ws, { + allowedAuditors: contractData.allowedAuditors, + allowedExchanges: contractData.allowedExchanges, + amount: contractData.amount, + maxDepositFee: contractData.maxDepositFee, + maxWireFee: contractData.maxWireFee, + timestamp: contractData.timestamp, + wireFeeAmortization: contractData.wireFeeAmortization, + wireMethod: contractData.wireMethod, + }); + + const payCoinSel = selectPayCoins({ + candidates, + contractTermsAmount: contractData.amount, + depositFeeLimit: contractData.maxDepositFee, + wireFeeAmortization: contractData.wireFeeAmortization ?? 1, + wireFeeLimit: contractData.maxWireFee, + prevPayCoins: [], + }); + if (!payCoinSel) { throw Error("insufficient funds"); |