@method @name ndax#withdraw @description make a withdrawal @param {string} code unified currency code @param {float} amount the amount to withdraw @param {string} address the address to withdraw to @param {string} tag @param {object} [params] extra parameters specific to the exchange API endpoint @r
(Object code, Object amount, Object address, Object... optionalArgs)
| 2721 | * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure} |
| 2722 | */ |
| 2723 | public java.util.concurrent.CompletableFuture<Object> withdraw(Object code, Object amount, Object address, Object... optionalArgs) |
| 2724 | { |
| 2725 | |
| 2726 | return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 2727 | |
| 2728 | Object tag = Helpers.getArg(optionalArgs, 0, null); |
| 2729 | Object parameters = Helpers.getArg(optionalArgs, 1, new java.util.HashMap<String, Object>() {{}}); |
| 2730 | var tagparametersVariable = this.handleWithdrawTagAndParams(tag, parameters); |
| 2731 | tag = ((java.util.List<Object>) tagparametersVariable).get(0); |
| 2732 | parameters = ((java.util.List<Object>) tagparametersVariable).get(1); |
| 2733 | // this method required login, password and twofa key |
| 2734 | Object sessionToken = this.safeString(this.options, "sessionToken"); |
| 2735 | if (Helpers.isTrue(Helpers.isEqual(sessionToken, null))) |
| 2736 | { |
| 2737 | throw new AuthenticationError((String)Helpers.add(this.id, " call signIn() method to obtain a session token")) ; |
| 2738 | } |
| 2739 | if (Helpers.isTrue(Helpers.isEqual(this.twofa, null))) |
| 2740 | { |
| 2741 | throw new AuthenticationError((String)Helpers.add(this.id, " withdraw() requires exchange.twofa credentials")) ; |
| 2742 | } |
| 2743 | this.checkAddress(address); |
| 2744 | Object omsId = this.safeInteger(this.options, "omsId", 1); |
| 2745 | (this.loadMarkets()).join(); |
| 2746 | (this.loadAccounts()).join(); |
| 2747 | Object defaultAccountId = this.safeInteger2(this.options, "accountId", "AccountId", Helpers.parseInt(Helpers.GetValue(Helpers.GetValue(this.accounts, 0), "id"))); |
| 2748 | Object accountId = this.safeInteger2(parameters, "accountId", "AccountId", defaultAccountId); |
| 2749 | parameters = this.omit(parameters, new java.util.ArrayList<Object>(java.util.Arrays.asList("accountId", "AccountId"))); |
| 2750 | Object currency = this.currency(code); |
| 2751 | Object withdrawTemplateTypesRequest = new java.util.HashMap<String, Object>() {{ |
| 2752 | put( "omsId", omsId ); |
| 2753 | put( "AccountId", accountId ); |
| 2754 | put( "ProductId", Helpers.GetValue(currency, "id") ); |
| 2755 | }}; |
| 2756 | Object withdrawTemplateTypesResponse = (this.privateGetGetWithdrawTemplateTypes(withdrawTemplateTypesRequest)).join(); |
| 2757 | // |
| 2758 | // { |
| 2759 | // "result": true, |
| 2760 | // "errormsg": null, |
| 2761 | // "statuscode": "0", |
| 2762 | // "TemplateTypes": [ |
| 2763 | // { AccountProviderId: "14", TemplateName: "ToExternalBitcoinAddress", AccountProviderName: "BitgoRPC-BTC" }, |
| 2764 | // { AccountProviderId: "20", TemplateName: "ToExternalBitcoinAddress", AccountProviderName: "TrezorBTC" }, |
| 2765 | // { AccountProviderId: "31", TemplateName: "BTC", AccountProviderName: "BTC Fireblocks 1" } |
| 2766 | // ] |
| 2767 | // } |
| 2768 | // |
| 2769 | Object templateTypes = this.safeValue(withdrawTemplateTypesResponse, "TemplateTypes", new java.util.ArrayList<Object>(java.util.Arrays.asList())); |
| 2770 | Object firstTemplateType = this.safeValue(templateTypes, 0); |
| 2771 | if (Helpers.isTrue(Helpers.isEqual(firstTemplateType, null))) |
| 2772 | { |
| 2773 | throw new ExchangeError((String)Helpers.add(Helpers.add(this.id, " withdraw() could not find a withdraw template type for "), Helpers.GetValue(currency, "code"))) ; |
| 2774 | } |
| 2775 | Object templateName = this.safeString(firstTemplateType, "TemplateName"); |
| 2776 | final Object finalFirstTemplateType = firstTemplateType; |
| 2777 | Object withdrawTemplateRequest = new java.util.HashMap<String, Object>() {{ |
| 2778 | put( "omsId", omsId ); |
| 2779 | put( "AccountId", accountId ); |
| 2780 | put( "ProductId", Helpers.GetValue(currency, "id") ); |
nothing calls this directly
no test coverage detected