diff options
author | Florian Dold <florian@dold.me> | 2021-03-17 17:56:37 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-03-17 17:56:37 +0100 |
commit | 07cdfb2e4ec761021477271776b81f33af0e731d (patch) | |
tree | cb62b1d1a04e1e64b8ee47e78196e858727d2c0a /packages/taler-wallet-core/src/operations/withdraw.ts | |
parent | 42a4d666f42ce94274995bfdae644444ff5f6d53 (diff) | |
download | wallet-core-07cdfb2e4ec761021477271776b81f33af0e731d.tar.xz |
towards wallet-core / util split
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/withdraw.ts | 112 |
1 files changed, 99 insertions, 13 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index f8748142f..0c1acf8ec 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { AmountJson, Amounts } from "../util/amounts"; +import { AmountJson, Amounts, parseWithdrawUri, Timestamp } from "@gnu-taler/taler-util"; import { DenominationRecord, Stores, @@ -25,22 +25,22 @@ import { DenominationSelectionInfo, PlanchetRecord, DenomSelectionState, -} from "../types/dbTypes"; + ExchangeRecord, + ExchangeWireInfo, +} from "../db"; import { BankWithdrawDetails, - ExchangeWithdrawDetails, TalerErrorDetails, ExchangeListItem, WithdrawUriInfoResponse, -} from "../types/walletTypes"; +} from "@gnu-taler/taler-util"; import { codecForWithdrawOperationStatusResponse, codecForWithdrawResponse, WithdrawResponse, codecForTalerConfigResponse, -} from "../types/talerTypes"; +} from "@gnu-taler/taler-util"; import { InternalWalletState } from "./state"; -import { parseWithdrawUri } from "../util/taleruri"; import { Logger } from "../util/logging"; import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges"; import { @@ -48,29 +48,115 @@ import { WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, } from "./versions"; -import * as LibtoolVersion from "../util/libtoolVersion"; +import * as LibtoolVersion from "@gnu-taler/taler-util"; import { guardOperationException, makeErrorDetails, OperationFailedError, } from "./errors"; -import { NotificationType } from "../types/notifications"; +import { NotificationType } from "@gnu-taler/taler-util"; import { getTimestampNow, getDurationRemaining, timestampCmp, timestampSubtractDuraction, -} from "../util/time"; +} from "@gnu-taler/taler-util"; import { readSuccessResponseJsonOrThrow } from "../util/http"; import { URL } from "../util/url"; -import { TalerErrorCode } from "../TalerErrorCode"; -import { encodeCrock } from "../crypto/talerCrypto"; +import { TalerErrorCode } from "@gnu-taler/taler-util"; import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries"; -import { compare } from "../util/libtoolVersion"; -import { j2s } from "../util/helpers"; +import { compare } from "@gnu-taler/taler-util"; const logger = new Logger("withdraw.ts"); + +/** + * Information about what will happen when creating a reserve. + * + * Sent to the wallet frontend to be rendered and shown to the user. + */ + interface ExchangeWithdrawDetails { + /** + * Exchange that the reserve will be created at. + */ + exchangeInfo: ExchangeRecord; + + /** + * Filtered wire info to send to the bank. + */ + exchangeWireAccounts: string[]; + + /** + * Selected denominations for withdraw. + */ + selectedDenoms: DenominationSelectionInfo; + + /** + * Fees for withdraw. + */ + withdrawFee: AmountJson; + + /** + * Remaining balance that is too small to be withdrawn. + */ + overhead: AmountJson; + + /** + * Wire fees from the exchange. + */ + wireFees: ExchangeWireInfo; + + /** + * Does the wallet know about an auditor for + * the exchange that the reserve. + */ + isAudited: boolean; + + /** + * Did the user already accept the current terms of service for the exchange? + */ + termsOfServiceAccepted: boolean; + + /** + * The exchange is trusted directly. + */ + isTrusted: boolean; + + /** + * The earliest deposit expiration of the selected coins. + */ + earliestDepositExpiration: Timestamp; + + /** + * Number of currently offered denominations. + */ + numOfferedDenoms: number; + + /** + * Public keys of trusted auditors for the currency we're withdrawing. + */ + trustedAuditorPubs: string[]; + + /** + * Result of checking the wallet's version + * against the exchange's version. + * + * Older exchanges don't return version information. + */ + versionMatch: LibtoolVersion.VersionMatchResult | undefined; + + /** + * Libtool-style version string for the exchange or "unknown" + * for older exchanges. + */ + exchangeVersion: string; + + /** + * Libtool-style version string for the wallet. + */ + walletVersion: string; +} + /** * Check if a denom is withdrawable based on the expiration time * and revocation state. |