get-withdrawal-details-for-amount.rst (8049B)
1 .. ts:op:: getWithdrawalDetailsForAmount 2 3 Get details for withdrawing a particular amount (manual withdrawal). 4 5 Computes the terms of withdrawing the given amount: the raw amount 6 the user has to transfer to the exchange, the effective amount that 7 will be added to the wallet balance after withdrawal fees, the number 8 of coins that would be withdrawn, the exchange's bank accounts that 9 can receive the transfer (including accounts that require currency 10 conversion), age-restriction options and a preview of KYC 11 requirements. 12 13 The client uses the result to let the user review the withdrawal 14 before creating it with :ts:op:`acceptManualWithdrawal`. 15 16 **Request:** 17 18 The request must be a `GetWithdrawalDetailsForAmountRequest` object. 19 20 **Response:** 21 22 On success, the result is a `WithdrawalDetailsForAmount` object. 23 24 **Side effects:** 25 26 May refresh the exchange's key material over the network, validates 27 withdrawal denominations and stores the verification results in the 28 database, and queries the bank conversion service for accounts that 29 require currency conversion. No transaction is created. 30 31 **Expected errors:** 32 33 The caller can handle the following errors inline: 34 ``WALLET_EXCHANGE_ENTRY_NOT_FOUND``, 35 ``WALLET_EXCHANGE_TOS_NOT_ACCEPTED``, ``GENERIC_CURRENCY_MISMATCH``. 36 37 **Details:** 38 39 The exchange is selected with ``exchangeBaseUrl``. When it is 40 omitted, ``restrictScope`` names a currency scope and the wallet's 41 preferred exchange for that scope is used instead. 42 43 When ``transactionId`` refers to a prepared bank-integrated 44 withdrawal, the sender account of that withdrawal is taken into 45 account when evaluating account-specific withdrawal rules (KYC). 46 47 An ``unconfirmedKeyChange`` in the result means the exchange changed 48 its key set and the user has not confirmed the change yet; accepting 49 the withdrawal will be refused until the change is confirmed with 50 :ts:op:`confirmExchangeKeyChange`, so this is the point at which to 51 warn the user. 52 53 .. ts:def:: GetWithdrawalDetailsForAmountRequest 54 55 interface GetWithdrawalDetailsForAmountRequest { 56 exchangeBaseUrl?: string; 57 58 // Prepared bank-integrated withdrawal whose sender account should 59 // be checked. 60 transactionId?: TransactionIdStr; 61 62 // Specify currency scope for the withdrawal. 63 // May only be used when exchangeBaseUrl is not specified. 64 restrictScope?: ScopeInfo; 65 66 amount: AmountString; 67 68 restrictAge?: number; 69 70 progressToken?: string; 71 } 72 73 .. ts:def:: WithdrawalDetailsForAmount 74 75 interface WithdrawalDetailsForAmount extends WithdrawalKycPreview { 76 // Exchange base URL for the withdrawal. 77 exchangeBaseUrl: string; 78 79 // Amount that the user will transfer to the exchange. 80 amountRaw: AmountString; 81 82 // Amount that will be added to the user's wallet balance. 83 amountEffective: AmountString; 84 85 // Number of coins that would be used for withdrawal. 86 // UIs should warn if this number is too high (roughly at >100). 87 numCoins: number; 88 89 // Ways to pay the exchange, including accounts that require 90 // currency conversion. 91 withdrawalAccountsList: WithdrawalExchangeAccountDetails[]; 92 93 // If the exchange supports age-restricted coins it will return 94 // the array of ages. 95 ageRestrictionOptions?: number[]; 96 97 // Scope info of the currency withdrawn. 98 scopeInfo: ScopeInfo; 99 100 // Set when the exchange changed its key set and the user has not 101 // confirmed the change. Accepting the withdrawal will be refused 102 // until they do, so this is the point at which to warn them. 103 unconfirmedKeyChange?: ExchangeKeyChangeInfo; 104 105 // KYC soft limit. 106 // Withdrawals over that amount will require KYC. 107 kycSoftLimit?: AmountString; 108 109 // KYC hard limit. 110 // Withdrawals over that amount will be denied. 111 kycHardLimit?: AmountString; 112 113 // Ways to pay the exchange. 114 // Deprecated in favor of withdrawalAccountsList. 115 paytoUris: string[]; 116 } 117 118 .. ts:def:: WithdrawalKycPreview 119 120 interface WithdrawalKycPreview { 121 // Whether the proposed withdrawal needs a KYC warning based on 122 // this wallet's balance, known KYC allowance, advertised 123 // zero-limit rules and known withdrawal volume. This is a 124 // preview, not a guarantee that the exchange will not require 125 // KYC. Optional for compatibility with older wallet-core 126 // versions, which omit it. 127 kycRequired?: boolean; 128 129 // Balance usage from the same evaluation as kycRequired. 130 balanceKyc?: BalanceKycUsage; 131 132 // Account-specific withdrawal-rule preview using this wallet's 133 // history. "ok" only covers exposed rules and available local 134 // history; "unknown" means account limits could not be evaluated 135 // and must not be shown as clearance. Older wallet-core versions 136 // omit this field. 137 withdrawalKycStatus?: WithdrawalKycStatus; 138 } 139 140 .. ts:def:: BalanceKycUsage 141 142 // This wallet's balance at the issuing exchange at preview time, 143 // using the same accounting as balance-KYC enforcement (including 144 // pending refresh outputs). Does not reserve capacity for 145 // concurrent withdrawals or report account-wide 146 // transaction-volume/hard-limit usage. 147 interface BalanceKycUsage { 148 currentBalance: AmountString; 149 150 // Current balance plus the selected coins' value after withdrawal 151 // fees. 152 projectedBalance: AmountString; 153 154 // Applicable balance threshold; omitted when no finite limit is 155 // known. 156 threshold?: AmountString; 157 158 // Additional balance permitted, clamped to zero; omitted with 159 // threshold. 160 remaining?: AmountString; 161 } 162 163 .. ts:def:: WithdrawalKycStatus 164 165 type WithdrawalKycStatus = 166 | "unknown" 167 | "ok" 168 | "kyc-required" 169 | "hard-limit"; 170 171 .. ts:def:: WithdrawalExchangeAccountDetails 172 173 interface WithdrawalExchangeAccountDetails { 174 // Payto URI of the exchange. Depending on whether the (manual!) 175 // withdrawal is accepted or just being checked, this already 176 // includes the subject with the reserve public key. 177 paytoUri: string; 178 179 // Whether the account can be used by the user to send funds for a 180 // withdrawal. "ok": account should be shown to the user; 181 // "error": account should not be shown to the user, UIs might 182 // render the error (in conversionError), especially in dev mode. 183 status: "ok" | "error"; 184 185 // Transfer amount. Might be in a different currency than the 186 // requested amount for withdrawal. Absent if this is a 187 // conversion account and the conversion failed. 188 transferAmount?: AmountString; 189 190 // Currency specification for the external currency. 191 // Only included if this account requires a currency conversion. 192 currencySpecification?: CurrencySpecification; 193 194 // Further restrictions for sending money to the exchange. 195 creditRestrictions?: AccountRestriction[]; 196 197 // Label given to the account or the account's bank by the 198 // exchange. 199 bankLabel?: string; 200 201 // Display priority assigned to this bank account by the exchange. 202 priority?: number; 203 204 // Error that happened when attempting to request the conversion 205 // rate. 206 conversionError?: TalerErrorDetail; 207 208 // Timestamp that indicates when the transfer options expire. 209 // If missing, options do not expire. 210 transferExpiry?: TalerProtocolTimestamp; 211 212 // Options for transferring funds to the exchange for the 213 // withdrawal. 214 transferOptions: TransferOption[]; 215 } 216 217 .. ts:def:: TransferOption 218 219 type TransferOption = 220 | TransferOptionPayto 221 | TransferOptionUri 222 | TransferOptionSwissQrBill; 223 224 .. ts:def:: TransferOptionPayto 225 226 interface TransferOptionPayto { 227 type: "payto"; 228 paytoUri: string; 229 qrCodes: QrCodeSpec[]; 230 } 231 232 .. ts:def:: TransferOptionUri 233 234 interface TransferOptionUri { 235 type: "uri"; 236 uri: string; 237 } 238 239 .. ts:def:: TransferOptionSwissQrBill 240 241 interface TransferOptionSwissQrBill { 242 type: "ch-qr-bill"; 243 paytoUri: string; 244 qrReferenceNumber: string; 245 qrCodes: QrCodeSpec[]; 246 }