diff options
author | Florian Dold <florian@dold.me> | 2021-03-27 19:35:44 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-03-27 19:35:44 +0100 |
commit | 93128f935817c86172406c9de41677db125d0273 (patch) | |
tree | 12edbc6d39cb365bf75797f552fa8b690556dc19 /packages/taler-wallet-core/src/operations | |
parent | d44740b787c974c5388811a2989557d93923c49a (diff) | |
download | wallet-core-93128f935817c86172406c9de41677db125d0273.tar.gz wallet-core-93128f935817c86172406c9de41677db125d0273.tar.bz2 wallet-core-93128f935817c86172406c9de41677db125d0273.zip |
fix coin selection
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay.ts | 70 |
1 files changed, 64 insertions, 6 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index 168a0f965..da3980565 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -24,12 +24,72 @@ /** * Imports. */ -import { AmountJson, Amounts, timestampIsBetween, getTimestampNow, isTimestampExpired, Timestamp, RefreshReason, CoinDepositPermission, NotificationType, TalerErrorDetails, Duration, durationMax, durationMin, durationMul, ContractTerms, codecForProposal, TalerErrorCode, codecForContractTerms, timestampAddDuration, ConfirmPayResult, ConfirmPayResultType, codecForMerchantPayResponse, PreparePayResult, PreparePayResultType, parsePayUri } from "@gnu-taler/taler-util"; +import { + AmountJson, + Amounts, + timestampIsBetween, + getTimestampNow, + isTimestampExpired, + Timestamp, + RefreshReason, + CoinDepositPermission, + NotificationType, + TalerErrorDetails, + Duration, + durationMax, + durationMin, + durationMul, + ContractTerms, + codecForProposal, + TalerErrorCode, + codecForContractTerms, + timestampAddDuration, + ConfirmPayResult, + ConfirmPayResultType, + codecForMerchantPayResponse, + PreparePayResult, + PreparePayResultType, + parsePayUri, +} from "@gnu-taler/taler-util"; import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto"; -import { AbortStatus, AllowedAuditorInfo, AllowedExchangeInfo, CoinRecord, CoinStatus, DenominationRecord, getHttpResponseErrorDetails, guardOperationException, HttpResponseStatus, Logger, makeErrorDetails, OperationFailedAndReportedError, OperationFailedError, ProposalRecord, ProposalStatus, PurchaseRecord, readSuccessResponseJsonOrErrorCode, readSuccessResponseJsonOrThrow, readTalerErrorResponse, Stores, throwUnexpectedRequestError, TransactionHandle, URL, WalletContractData } from "../index.js"; -import { PayCoinSelection, CoinCandidateSelection, AvailableCoinInfo, selectPayCoins } from "../util/coinSelection.js"; +import { + AbortStatus, + AllowedAuditorInfo, + AllowedExchangeInfo, + CoinRecord, + CoinStatus, + DenominationRecord, + getHttpResponseErrorDetails, + guardOperationException, + HttpResponseStatus, + Logger, + makeErrorDetails, + OperationFailedAndReportedError, + OperationFailedError, + ProposalRecord, + ProposalStatus, + PurchaseRecord, + readSuccessResponseJsonOrErrorCode, + readSuccessResponseJsonOrThrow, + readTalerErrorResponse, + Stores, + throwUnexpectedRequestError, + TransactionHandle, + URL, + WalletContractData, +} from "../index.js"; +import { + PayCoinSelection, + CoinCandidateSelection, + AvailableCoinInfo, + selectPayCoins, +} from "../util/coinSelection.js"; import { canonicalJson } from "../util/helpers.js"; -import { initRetryInfo, updateRetryInfoTimeout, getRetryDuration } from "../util/retries.js"; +import { + initRetryInfo, + updateRetryInfoTimeout, + getRetryDuration, +} from "../util/retries.js"; import { getTotalRefreshCost, createRefreshGroup } from "./refresh.js"; import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state.js"; @@ -38,7 +98,6 @@ import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state.js"; */ const logger = new Logger("pay.ts"); - /** * Compute the total cost of a payment to the customer. * @@ -123,7 +182,6 @@ export async function getEffectiveDepositAmount( return Amounts.sub(Amounts.sum(amt).amount, Amounts.sum(fees).amount).amount; } - export function isSpendableCoin( coin: CoinRecord, denom: DenominationRecord, |