예제 #1
0
        /// <summary>
        /// Request withdrawal cancelation
        /// </summary>
        /// <param name="currency_name">base coin or quote coin name</param>
        /// <param name="transferId">The unique id of the withdrawal request specified</param>
        /// <param name="args">Add additional attributes for each exchange</param>
        /// <returns></returns>
        public override async Task <Transfer> CancelCoinWithdraw(string currency_name, string transferId, Dictionary <string, object> args = null)
        {
            var _result = new Transfer();

            var _currency_id = await publicApi.LoadCurrencyId(currency_name);

            if (_currency_id.success == true)
            {
                privateClient.ExchangeInfo.ApiCallWait(TradeType.Private);

                var _params = new Dictionary <string, object>();
                {
                    _params.Add("asset", _currency_id.result);
                    _params.Add("refid", transferId);

                    privateClient.MergeParamsAndArgs(_params, args);
                }

                var _json_value = await privateClient.CallApiPost1Async("/0/private/WithdrawCancel", _params);

#if DEBUG
                _result.rawJson = _json_value.Content;
#endif
                var _json_result = privateClient.GetResponseMessage(_json_value.Response);
                if (_json_result.success == true)
                {
                    var _json_data = privateClient.DeserializeObject <KWithdrawCancel>(_json_value.Content);
                    if (_json_data.result == true)
                    {
                        var _transfer = new KTransferItem
                        {
                            transferId = transferId,
                            timestamp  = CUnixTime.NowMilli,

                            transactionType = TransactionType.Withdraw,

                            currency  = currency_name,
                            toAddress = "",
                            toTag     = "",

                            amount      = 0.0m,
                            isCompleted = _json_data.result
                        };

                        _result.result = _transfer;
                    }
                    else
                    {
                        _json_result.SetFailure("Unknown reference id");
                    }
                }

                _result.SetResult(_json_result);
            }
            else
            {
                _result.SetResult(_currency_id);
            }

            return(_result);
        }
예제 #2
0
        /// <summary>
        /// Withdraw funds
        /// </summary>
        /// <param name="currency_name">base coin or quote coin name</param>
        /// <param name="address">coin address for send</param>
        /// <param name="tag">Secondary address identifier for coins like XRP,XMR etc.</param>
        /// <param name="quantity">amount of coin</param>
        /// <param name="args">Add additional attributes for each exchange</param>
        /// <returns></returns>
        public override async Task <Transfer> CoinWithdraw(string currency_name, string address, string tag, decimal quantity, Dictionary <string, object> args = null)
        {
            var _result = new Transfer();

            var _currency_id = await publicApi.LoadCurrencyId(currency_name);

            if (_currency_id.success == true)
            {
                privateClient.ExchangeInfo.ApiCallWait(TradeType.Private);

                var _params = new Dictionary <string, object>();
                {
                    _params.Add("asset", _currency_id.result);      // asset being withdrawn
                    _params.Add("key", address);                    // withdrawal key name, as set up on your account
                    _params.Add("amount", quantity);                // amount to withdraw, including fees

                    privateClient.MergeParamsAndArgs(_params, args);
                }

                var _json_value = await privateClient.CallApiPost1Async("/0/private/Withdraw", _params);

#if DEBUG
                _result.rawJson = _json_value.Content;
#endif
                var _json_result = privateClient.GetResponseMessage(_json_value.Response);
                if (_json_result.success == true)
                {
                    var _json_data = privateClient.DeserializeObject <KResponse <KTransferItem> >(_json_value.Content);
                    {
                        var _withdraw = new KTransferItem
                        {
                            transferId    = _json_data.result.transferId,
                            transactionId = privateClient.GenerateNonceString(16),
                            timestamp     = CUnixTime.NowMilli,

                            transactionType = TransactionType.Withdraw,

                            currency  = currency_name,
                            toAddress = address,
                            toTag     = tag,

                            amount = quantity,
                            fee    = 0,

                            confirmations = 0,
                            isCompleted   = true
                        };

                        _result.result = _withdraw;
                    }
                }

                _result.SetResult(_json_result);
            }
            else
            {
                _result.SetResult(_currency_id);
            }

            return(_result);
        }