make a withdrawal :param str code: unified currency code :param float amount: the amount to withdraw :param str address: the address to withdraw to :param str tag: :param dict [params]: extra parameters specific to the exchange API endpoint :r
(self, code: str, amount: float, address: str, tag: Str = None, params={})
| 2357 | } |
| 2358 | |
| 2359 | def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction: |
| 2360 | """ |
| 2361 | make a withdrawal |
| 2362 | :param str code: unified currency code |
| 2363 | :param float amount: the amount to withdraw |
| 2364 | :param str address: the address to withdraw to |
| 2365 | :param str tag: |
| 2366 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 2367 | :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>` |
| 2368 | """ |
| 2369 | tag, params = self.handle_withdraw_tag_and_params(tag, params) |
| 2370 | # self method required login, password and twofa key |
| 2371 | sessionToken = self.safe_string(self.options, 'sessionToken') |
| 2372 | if sessionToken is None: |
| 2373 | raise AuthenticationError(self.id + ' call signIn() method to obtain a session token') |
| 2374 | if self.twofa is None: |
| 2375 | raise AuthenticationError(self.id + ' withdraw() requires exchange.twofa credentials') |
| 2376 | self.check_address(address) |
| 2377 | omsId = self.safe_integer(self.options, 'omsId', 1) |
| 2378 | self.load_markets() |
| 2379 | self.load_accounts() |
| 2380 | defaultAccountId = self.safe_integer_2(self.options, 'accountId', 'AccountId', int(self.accounts[0]['id'])) |
| 2381 | accountId = self.safe_integer_2(params, 'accountId', 'AccountId', defaultAccountId) |
| 2382 | params = self.omit(params, ['accountId', 'AccountId']) |
| 2383 | currency = self.currency(code) |
| 2384 | withdrawTemplateTypesRequest = { |
| 2385 | 'omsId': omsId, |
| 2386 | 'AccountId': accountId, |
| 2387 | 'ProductId': currency['id'], |
| 2388 | } |
| 2389 | withdrawTemplateTypesResponse = self.privateGetGetWithdrawTemplateTypes(withdrawTemplateTypesRequest) |
| 2390 | # |
| 2391 | # { |
| 2392 | # "result": True, |
| 2393 | # "errormsg": null, |
| 2394 | # "statuscode": "0", |
| 2395 | # "TemplateTypes": [ |
| 2396 | # {AccountProviderId: "14", TemplateName: "ToExternalBitcoinAddress", AccountProviderName: "BitgoRPC-BTC"}, |
| 2397 | # {AccountProviderId: "20", TemplateName: "ToExternalBitcoinAddress", AccountProviderName: "TrezorBTC"}, |
| 2398 | # {AccountProviderId: "31", TemplateName: "BTC", AccountProviderName: "BTC Fireblocks 1"} |
| 2399 | # ] |
| 2400 | # } |
| 2401 | # |
| 2402 | templateTypes = self.safe_value(withdrawTemplateTypesResponse, 'TemplateTypes', []) |
| 2403 | firstTemplateType = self.safe_value(templateTypes, 0) |
| 2404 | if firstTemplateType is None: |
| 2405 | raise ExchangeError(self.id + ' withdraw() could not find a withdraw template type for ' + currency['code']) |
| 2406 | templateName = self.safe_string(firstTemplateType, 'TemplateName') |
| 2407 | withdrawTemplateRequest = { |
| 2408 | 'omsId': omsId, |
| 2409 | 'AccountId': accountId, |
| 2410 | 'ProductId': currency['id'], |
| 2411 | 'TemplateType': templateName, |
| 2412 | 'AccountProviderId': firstTemplateType['AccountProviderId'], |
| 2413 | } |
| 2414 | withdrawTemplateResponse = self.privateGetGetWithdrawTemplate(withdrawTemplateRequest) |
| 2415 | # |
| 2416 | # { |
nothing calls this directly
no test coverage detected