Example #1
0
        /// <summary>
        /// Function to withdraw from Bitsamp exchange. At the moment only XRP is supported.
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            string baseurl = null;
            string url;

            switch (withdrawalRequest.Symbol)
            {
            case "BTC":
                // use old API for Bitcoin withdraw
                baseurl = "https://www.bitstamp.net/api/";
                url     = "/bitcoin_withdrawal/";
                break;

            default:
                // this will work for some currencies and fail for others, caller must be aware of the supported currencies
                url = "/" + withdrawalRequest.Symbol.ToLowerInvariant() + "_withdrawal/";
                break;
            }

            Dictionary <string, object> payload = await OnGetNoncePayloadAsync();

            payload["address"]         = withdrawalRequest.Address.ToStringInvariant();
            payload["amount"]          = withdrawalRequest.Amount.ToStringInvariant();
            payload["destination_tag"] = withdrawalRequest.AddressTag.ToStringInvariant();

            JObject responseObject = await MakeJsonRequestAsync <JObject>(url, baseurl, payload, "POST");

            CheckJsonResponse(responseObject);
            return(new ExchangeWithdrawalResponse
            {
                Id = responseObject["id"].ToStringInvariant(),
                Message = responseObject["message"].ToStringInvariant(),
                Success = responseObject["success"].ConvertInvariant <bool>()
            });
        }
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse withdraw = new ExchangeWithdrawalResponse()
            {
                Success = false
            };
            var payload = await OnGetNoncePayloadAsync();

            payload["amount"]        = withdrawalRequest.Amount;
            payload["currency_code"] = withdrawalRequest.Symbol;
            payload["address"]       = withdrawalRequest.Address;
            if (!string.IsNullOrEmpty(withdrawalRequest.AddressTag))
            {
                payload["paymentId"] = withdrawalRequest.AddressTag;
            }
            //{ "id": "d2ce578f-647d-4fa0-b1aa-4a27e5ee597b"}   that's all folks!
            JToken token = await MakeJsonRequestAsync <JToken>("/payment/payout", null, payload, "POST");

            if (token != null && token["id"] != null)
            {
                withdraw.Success = true;
                withdraw.Id      = token["id"].ToStringInvariant();
            }
            return(withdraw);
        }
Example #3
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };
            string symbol  = NormalizeSymbol(withdrawalRequest.Symbol);
            var    payload = await OnGetNoncePayloadAsync();

            JArray array = await MakeJsonRequestAsync <JArray>("/payment-methods", null, await OnGetNoncePayloadAsync());

            if (array != null)
            {
                var rc = array.Where(t => t["currency"].ToStringInvariant() == symbol).FirstOrDefault();

                payload = await OnGetNoncePayloadAsync();

                payload["amount"]   = withdrawalRequest.Amount;
                payload["currency"] = symbol;
                payload["method"]   = rc["id"].ToStringInvariant();
                if (!String.IsNullOrEmpty(withdrawalRequest.AddressTag))
                {
                    payload["tag"] = withdrawalRequest.AddressTag;
                }
                // "status": 0,  "message": "Your transaction is pending. Please confirm it via email.",  "payoutId": "65",  "balance": []...
                JToken token = MakeJsonRequest <JToken>("/withdrawals/make", null, payload, "POST");
                response.Id      = token["payoutId"].ToStringInvariant();
                response.Message = token["message"].ToStringInvariant();
                response.Success = token["status"].ConvertInvariant <int>().Equals(0);
            }
            return(response);
        }
Example #4
0
        /// <summary>
        /// Kucoin doesn't support withdraws to Cryptonight currency addresses (No Address Tag paramater)
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = true
            };
            var payload = await OnGetNoncePayloadAsync();

            payload["address"] = withdrawalRequest.Address;
            payload["amount"]  = withdrawalRequest.Amount;

            JToken token = await MakeJsonRequestAsync <JToken>("/account/" + withdrawalRequest.Symbol + "/withdraw/apply", null, payload, "POST");

            // no data is returned. Check error will throw exception on failure
            return(response);
        }
Example #5
0
        /// <summary>
        /// Warning: Use with discretion
        /// <rant> Yobit trading seems fine, their API is stable, but their deposits/withdraws are *VERY* problematic.
        /// I'm being kind. Waited as much as two-weeks for deposts to show up on Exchange, even though they were confirmed on the blockchain.
        /// </rant>
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };
            var payload = await OnGetNoncePayloadAsync();

            payload.Add("method", "WithdrawCoinsToAddress");
            payload.Add("coinName", withdrawalRequest.Symbol);
            payload.Add("amount", withdrawalRequest.Amount);
            payload.Add("address", withdrawalRequest.Address);
            await MakeJsonRequestAsync <JToken>("/", PrivateURL, payload, "POST");

            response.Success = true;
            return(response);
        }
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };

            if (!String.IsNullOrEmpty(withdrawalRequest.AddressTag))
            {
                withdrawalRequest.AddressTag = "::" + withdrawalRequest.AddressTag;
            }

            // {"fault": null,"userId": 797,"userName": "******","id": 11285042,"state": "APPROVED","createDate": 1432197911364,"lastModifyDate": 1432197911802,"verificationType": "NONE","verificationData": null, "comment": null, "description": "Transfer from Livecoin", "amount": 0.002, "currency": "BTC", "accountTo": "B1099909", "acceptDate": null, "valueDate": null, "docDate": 1432197911364, "docNumber": 11111111, "correspondentDetails": null, "accountFrom": "B0000001", "outcome": false, "external": null, "externalKey": "1111111", "externalSystemId": 18, "externalServiceId": null, "wallet": "1111111" }
            JToken token = await MakeJsonRequestAsync <JToken>("/payment/out/coin?currency=" + withdrawalRequest.Symbol + "&wallet=" + withdrawalRequest.Address + withdrawalRequest.AddressTag + "&amount=" + withdrawalRequest.Amount, BaseUrl, await OnGetNoncePayloadAsync(), "POST");

            response.Success = true;
            return(response);
        }
Example #7
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };

            var payload = await OnGetNoncePayloadAsync();

            payload.Add("method", "withdraw");
            payload.Add("coin", withdrawalRequest.Symbol);
            payload.Add("amount", withdrawalRequest.Amount);
            payload.Add("address", withdrawalRequest.Address);
            // ( [success] => 1 [error] => Array ([0] => Withdraw requested. ))
            JToken token = await MakeJsonRequestAsync <JToken>("/api", null, payload, "POST");

            if (token["success"].ConvertInvariant <int>() == 1)
            {
                response.Success = true;
            }
            return(response);
        }
Example #8
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };

            var payload = await OnGetNoncePayloadAsync();

            payload.Add("Currency", withdrawalRequest.Symbol);
            payload.Add("Address", withdrawalRequest.Address);
            if (!string.IsNullOrEmpty(withdrawalRequest.AddressTag))
            {
                payload.Add("PaymentId", withdrawalRequest.AddressTag);
            }
            payload.Add("Amount", withdrawalRequest.Amount);
            JToken token = await MakeJsonRequestAsync <JToken>("/SubmitWithdraw", null, payload, "POST");

            response.Id      = token.ConvertInvariant <int>().ToStringInvariant();
            response.Success = true;
            return(response);
        }
        /// <summary>A withdrawal request. Fee is automatically subtracted from the amount.</summary>
        /// <param name="withdrawalRequest">The withdrawal request.</param>
        /// <returns>Withdrawal response from Binance</returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            if (string.IsNullOrWhiteSpace(withdrawalRequest.Symbol))
            {
                throw new ArgumentException("Symbol must be provided for Withdraw");
            }
            else if (string.IsNullOrWhiteSpace(withdrawalRequest.Address))
            {
                throw new ArgumentException("Address must be provided for Withdraw");
            }
            else if (withdrawalRequest.Amount <= 0)
            {
                throw new ArgumentException("Withdrawal amount must be positive and non-zero");
            }

            Dictionary <string, object> payload = await OnGetNoncePayloadAsync();

            payload["asset"]   = withdrawalRequest.Symbol;
            payload["address"] = withdrawalRequest.Address;
            payload["amount"]  = withdrawalRequest.Amount;
            payload["name"]    = withdrawalRequest.Description ?? "apiwithdrawal"; // Contrary to what the API docs say, name is required

            if (!string.IsNullOrWhiteSpace(withdrawalRequest.AddressTag))
            {
                payload["addressTag"] = withdrawalRequest.AddressTag;
            }

            JToken response = await MakeJsonRequestAsync <JToken>("/withdraw.html", WithdrawalUrlPrivate, payload, "POST");

            ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse
            {
                Id      = response["id"].ToStringInvariant(),
                Message = response["msg"].ToStringInvariant(),
            };

            return(withdrawalResponse);
        }
Example #10
0
 protected override Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
 {
     throw new NotImplementedException("Huobi does not provide a withdraw API");
 }