From e0df53705af8e9b831c671c902e8b0b4c491fa04 Mon Sep 17 00:00:00 2001 From: "h.moradof" Date: Sun, 12 Apr 2020 19:01:36 +0430 Subject: [PATCH 1/3] Return TxId and AddressTag in DepositHistory response --- Binance.API.Csharp.Client.Models/Account/DepositHistory.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Binance.API.Csharp.Client.Models/Account/DepositHistory.cs b/Binance.API.Csharp.Client.Models/Account/DepositHistory.cs index 40ac1c1..af23dc1 100644 --- a/Binance.API.Csharp.Client.Models/Account/DepositHistory.cs +++ b/Binance.API.Csharp.Client.Models/Account/DepositHistory.cs @@ -13,6 +13,12 @@ public class Deposit public string Asset { get; set; } [JsonProperty("status")] public int Status { get; set; } + [JsonProperty("address")] + public string Address { get; set; } + [JsonProperty("addressTag")] + public string AddressTag { get; set; } + [JsonProperty("txId")] + public string TxId { get; set; } } public class DepositHistory From 8af8c43f8f1cd38b1781f513fe8079e2e0f59886 Mon Sep 17 00:00:00 2001 From: "h.moradof" Date: Tue, 14 Apr 2020 03:07:24 +0430 Subject: [PATCH 2/3] Add addressTag in Withdraw, Fix DepositHistory Bug --- .../Interfaces/IBinanceClient.cs | 2 +- Binance.API.Csharp.Client.Test/BinanceTest.cs | 8 ++++++-- Binance.API.Csharp.Client/BinanceClient.cs | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Binance.API.Csharp.Client.Domain/Interfaces/IBinanceClient.cs b/Binance.API.Csharp.Client.Domain/Interfaces/IBinanceClient.cs index 5312215..38e12e1 100644 --- a/Binance.API.Csharp.Client.Domain/Interfaces/IBinanceClient.cs +++ b/Binance.API.Csharp.Client.Domain/Interfaces/IBinanceClient.cs @@ -162,7 +162,7 @@ public interface IBinanceClient /// Address name. /// Specific number of milliseconds the request is valid for. /// - Task Withdraw(string asset, decimal amount, string address, string addressName = "", long recvWindow = 6000000); + Task Withdraw(string asset, decimal amount, string address, string addressTag = "", string addressName = "", long recvWindow = 6000000); /// /// Fetch deposit history. diff --git a/Binance.API.Csharp.Client.Test/BinanceTest.cs b/Binance.API.Csharp.Client.Test/BinanceTest.cs index 03d6216..fd42459 100644 --- a/Binance.API.Csharp.Client.Test/BinanceTest.cs +++ b/Binance.API.Csharp.Client.Test/BinanceTest.cs @@ -2,13 +2,14 @@ using Binance.API.Csharp.Client.Models.Enums; using System.Threading; using Binance.API.Csharp.Client.Models.WebSocket; +using System; namespace Binance.API.Csharp.Client.Test { [TestClass] public class BinanceTest { - private static ApiClient apiClient = new ApiClient("@YourApiKey", "@YourApiSecret"); + private static ApiClient apiClient = new ApiClient("Ax8fVbYarOuq3hJGiYlw62Oae78U0xvDbFUYlnenQxIQBWpbcxlC6N5NzFlviiUZ", "e3cKGFASMdaZKaRa64tKHnpTwOcKrZF1992xjWVWKEsjf7f2dL9prEHedtGltSWN"); private static BinanceClient binanceClient = new BinanceClient(apiClient,false); #region General @@ -137,7 +138,10 @@ public void Withdraw() [TestMethod] public void GetDepositHistory() { - var depositHistory = binanceClient.GetDepositHistory("neo", DepositStatus.Success).Result; + var depositHistory = binanceClient.GetDepositHistory("btc", DepositStatus.Success, new DateTime(2020)).Result; + + Assert.IsTrue(depositHistory.Success); + Assert.IsNotNull(depositHistory.DepositList); } [TestMethod] diff --git a/Binance.API.Csharp.Client/BinanceClient.cs b/Binance.API.Csharp.Client/BinanceClient.cs index c37503a..9cbb603 100644 --- a/Binance.API.Csharp.Client/BinanceClient.cs +++ b/Binance.API.Csharp.Client/BinanceClient.cs @@ -429,9 +429,10 @@ public async Task> GetTradeList(string symbol, long recvWindo /// Amount to withdraw. /// Address where the asset will be deposited. /// Address name. + /// Address tag. /// Specific number of milliseconds the request is valid for. /// - public async Task Withdraw(string asset, decimal amount, string address, string addressName = "", long recvWindow = 5000) + public async Task Withdraw(string asset, decimal amount, string address, string addressTag = "", string addressName = "", long recvWindow = 5000) { if (string.IsNullOrWhiteSpace(asset)) { @@ -447,6 +448,7 @@ public async Task Withdraw(string asset, decimal amount, strin } var args = $"asset={asset.ToUpper()}&amount={amount}&address={address}" + + (!string.IsNullOrWhiteSpace(addressTag) ? $"&addressTag={addressTag}" : "") + (!string.IsNullOrWhiteSpace(addressName) ? $"&name={addressName}" : "") + $"&recvWindow={recvWindow}"; @@ -477,7 +479,7 @@ public async Task GetDepositHistory(string asset, DepositStatus? + (endTime.HasValue ? $"&endTime={endTime.Value.GetUnixTimeStamp()}" : "") + $"&recvWindow={recvWindow}"; - var result = await _apiClient.CallAsync(ApiMethod.POST, EndPoints.DepositHistory, true, args); + var result = await _apiClient.CallAsync(ApiMethod.GET, EndPoints.DepositHistory, true, args); return result; } From 8568d7bf48c62f9752383439a062618c779aac7f Mon Sep 17 00:00:00 2001 From: "h.moradof" Date: Sun, 3 May 2020 10:23:00 +0430 Subject: [PATCH 3/3] fix bugs --- .../Account/WithdrawResponse.cs | 6 ++++++ Binance.API.Csharp.Client.Test/BinanceTest.cs | 6 +++++- Binance.API.Csharp.Client/BinanceClient.cs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Binance.API.Csharp.Client.Models/Account/WithdrawResponse.cs b/Binance.API.Csharp.Client.Models/Account/WithdrawResponse.cs index 25b479a..8723ac2 100644 --- a/Binance.API.Csharp.Client.Models/Account/WithdrawResponse.cs +++ b/Binance.API.Csharp.Client.Models/Account/WithdrawResponse.cs @@ -13,5 +13,11 @@ public class WithdrawResponse public string Msg { get; set; } [JsonProperty("success")] public bool Success { get; set; } + + + public override string ToString() + { + return $"WithdrawResponse.Success={Success} --- WithdrawResponse.Msg{Msg}"; + } } } diff --git a/Binance.API.Csharp.Client.Test/BinanceTest.cs b/Binance.API.Csharp.Client.Test/BinanceTest.cs index fd42459..6b2ccf8 100644 --- a/Binance.API.Csharp.Client.Test/BinanceTest.cs +++ b/Binance.API.Csharp.Client.Test/BinanceTest.cs @@ -120,7 +120,9 @@ public void GetAllOrders() [TestMethod] public void GetAccountInfo() { + // I need var accountInfo = binanceClient.GetAccountInfo().Result; + } [TestMethod] @@ -132,12 +134,14 @@ public void GetTradeList() [TestMethod] public void Withdraw() { - var withdrawResult = binanceClient.Withdraw("AST", 100m, "@YourDepositAddress").Result; + // I need + var withdrawResult = binanceClient.Withdraw("AST", 100m, "@YourDepositAddress", null).Result; } [TestMethod] public void GetDepositHistory() { + // I need var depositHistory = binanceClient.GetDepositHistory("btc", DepositStatus.Success, new DateTime(2020)).Result; Assert.IsTrue(depositHistory.Success); diff --git a/Binance.API.Csharp.Client/BinanceClient.cs b/Binance.API.Csharp.Client/BinanceClient.cs index 9cbb603..17e9c24 100644 --- a/Binance.API.Csharp.Client/BinanceClient.cs +++ b/Binance.API.Csharp.Client/BinanceClient.cs @@ -448,7 +448,7 @@ public async Task Withdraw(string asset, decimal amount, strin } var args = $"asset={asset.ToUpper()}&amount={amount}&address={address}" - + (!string.IsNullOrWhiteSpace(addressTag) ? $"&addressTag={addressTag}" : "") + + (!string.IsNullOrWhiteSpace(addressTag) && !string.IsNullOrEmpty(addressTag) ? $"&addressTag={addressTag}" : "") + (!string.IsNullOrWhiteSpace(addressName) ? $"&name={addressName}" : "") + $"&recvWindow={recvWindow}";