* @method * @name cryptocom#withdraw * @description make a withdrawal * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-withdrawal * @param {string} code unified currency code * @param {float} amount the amount to withdraw * @param {s
(code: string, amount: number, address: string, tag: Str = undefined, params = {})
| 1986 | * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure} |
| 1987 | */ |
| 1988 | async withdraw (code: string, amount: number, address: string, tag: Str = undefined, params = {}): Promise<Transaction> { |
| 1989 | [ tag, params ] = this.handleWithdrawTagAndParams (tag, params); |
| 1990 | await this.loadMarkets (); |
| 1991 | const currency = this.safeCurrency (code); // for instance, USDC is not inferred from markets but it's still available |
| 1992 | const request: Dict = { |
| 1993 | 'currency': currency['id'], |
| 1994 | 'amount': amount, |
| 1995 | 'address': address, |
| 1996 | }; |
| 1997 | if (tag !== undefined) { |
| 1998 | request['address_tag'] = tag; |
| 1999 | } |
| 2000 | let networkCode: Str = undefined; |
| 2001 | [ networkCode, params ] = this.handleNetworkCodeAndParams (params); |
| 2002 | const networkId = this.networkCodeToId ((networkCode as string), code); |
| 2003 | if (networkId !== undefined) { |
| 2004 | request['network_id'] = networkId; |
| 2005 | } |
| 2006 | const response = await this.v1PrivatePostPrivateCreateWithdrawal (this.extend (request, params)); |
| 2007 | // |
| 2008 | // { |
| 2009 | // "id":-1, |
| 2010 | // "method":"private/create-withdrawal", |
| 2011 | // "code":0, |
| 2012 | // "result": { |
| 2013 | // "id": 2220, |
| 2014 | // "amount": 1, |
| 2015 | // "fee": 0.0004, |
| 2016 | // "symbol": "BTC", |
| 2017 | // "address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBf", |
| 2018 | // "client_wid": "my_withdrawal_002", |
| 2019 | // "create_time":1607063412000 |
| 2020 | // } |
| 2021 | // } |
| 2022 | // |
| 2023 | const result = this.safeDict (response, 'result'); |
| 2024 | return this.parseTransaction (result as Dict, currency); |
| 2025 | } |
| 2026 | |
| 2027 | /** |
| 2028 | * @method |
nothing calls this directly
no test coverage detected