diff --git a/pom.xml b/pom.xml index 67e7af532..861e3ed4a 100755 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,10 @@ + 11 + true + UTF-8 + UTF-8 2.4.0 @@ -52,11 +56,26 @@ org.apache.maven.plugins maven-compiler-plugin + 3.7.0 - 1.8 - 1.8 + ${java.version} + ${java.version} + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + verify + + jar-no-fork + + + + diff --git a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java index d0e3b1c01..80a2e06b0 100755 --- a/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java @@ -1,15 +1,6 @@ package com.binance.api.client; -import com.binance.api.client.domain.account.Account; -import com.binance.api.client.domain.account.DepositAddress; -import com.binance.api.client.domain.account.DepositHistory; -import com.binance.api.client.domain.account.NewOrder; -import com.binance.api.client.domain.account.NewOrderResponse; -import com.binance.api.client.domain.account.Order; -import com.binance.api.client.domain.account.Trade; -import com.binance.api.client.domain.account.TradeHistoryItem; -import com.binance.api.client.domain.account.WithdrawHistory; -import com.binance.api.client.domain.account.WithdrawResult; +import com.binance.api.client.domain.account.*; import com.binance.api.client.domain.account.request.AllOrdersRequest; import com.binance.api.client.domain.account.request.CancelOrderRequest; import com.binance.api.client.domain.account.request.CancelOrderResponse; @@ -258,34 +249,71 @@ public interface BinanceApiAsyncRestClient { * * Enable Withdrawals option has to be active in the API settings. * - * @param asset asset symbol to withdraw + * @param coin asset symbol to withdraw + * @param withdrawOrderId client id for withdraw + * @param network the network to use for the withdrawal * @param address address to withdraw to - * @param amount amount to withdraw - * @param name description/alias of the address * @param addressTag Secondary address identifier for coins like XRP,XMR etc. + * @param amount amount to withdraw + * @param transactionFeeFlag When making internal transfer, true for returning the fee to the destination account; false for returning the fee back to the departure account. Default false. + * @param name Description of the address. Space in name should be encoded into %20. + * @param callback the callback that handles the response with a list of trades + */ + void withdraw(String coin, String withdrawOrderId, String network, String address, String addressTag, + String amount, Boolean transactionFeeFlag, String name, BinanceApiCallback callback); + + /** + * Fetch account deposit history. + * + * @param coin the asset to get the history for + * @param callback the callback that handles the response and returns the deposit history */ - void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback callback); + void getDepositHistory(String coin, BinanceApiCallback> callback); + /** * Fetch account deposit history. * + * @param coin the asset to get the history for + * @param status 0(0:pending,6: credited but cannot withdraw, 1:success) + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp + * @param offset Default:0 + * @param limit Default:1000, Max:1000 * @param callback the callback that handles the response and returns the deposit history */ - void getDepositHistory(String asset, BinanceApiCallback callback); + void getDepositHistory(String coin, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit, BinanceApiCallback> callback); + + /** + * Fetch account withdraw history. + * + * @param coin the asset to get the history for + * @param callback the callback that handles the response and returns the withdraw history + */ + void getWithdrawHistory(String coin, BinanceApiCallback> callback); /** * Fetch account withdraw history. * + * @param coin the asset to get the history for + * @param withdrawOrderId client id for withdraw + * @param status 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6:Completed) + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp + * @param offset Default:0 + * @param limit Default:1000, Max:1000 * @param callback the callback that handles the response and returns the withdraw history */ - void getWithdrawHistory(String asset, BinanceApiCallback callback); + void getWithdrawHistory(String coin, String withdrawOrderId, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit, BinanceApiCallback> callback); /** * Fetch deposit address. * * @param callback the callback that handles the response and returns the deposit address */ - void getDepositAddress(String asset, BinanceApiCallback callback); + void getDepositAddress(String asset, String network, BinanceApiCallback callback); // User stream endpoints diff --git a/src/main/java/com/binance/api/client/BinanceApiRestClient.java b/src/main/java/com/binance/api/client/BinanceApiRestClient.java index ebe0b9667..4abb3b7c2 100755 --- a/src/main/java/com/binance/api/client/BinanceApiRestClient.java +++ b/src/main/java/com/binance/api/client/BinanceApiRestClient.java @@ -2,15 +2,9 @@ import com.binance.api.client.domain.account.*; import com.binance.api.client.domain.account.request.*; -import com.binance.api.client.domain.general.ExchangeInfo; import com.binance.api.client.domain.general.Asset; -import com.binance.api.client.domain.market.AggTrade; -import com.binance.api.client.domain.market.BookTicker; -import com.binance.api.client.domain.market.Candlestick; -import com.binance.api.client.domain.market.CandlestickInterval; -import com.binance.api.client.domain.market.OrderBook; -import com.binance.api.client.domain.market.TickerPrice; -import com.binance.api.client.domain.market.TickerStatistics; +import com.binance.api.client.domain.general.ExchangeInfo; +import com.binance.api.client.domain.market.*; import java.util.List; @@ -265,13 +259,17 @@ public interface BinanceApiRestClient { * * Enable Withdrawals option has to be active in the API settings. * - * @param asset asset symbol to withdraw + * @param coin asset symbol to withdraw + * @param withdrawOrderId client id for withdraw + * @param network the network to use for the withdrawal * @param address address to withdraw to - * @param amount amount to withdraw - * @param name description/alias of the address * @param addressTag Secondary address identifier for coins like XRP,XMR etc. + * @param amount amount to withdraw + * @param transactionFeeFlag When making internal transfer, true for returning the fee to the destination account; false for returning the fee back to the departure account. Default false. + * @param name Description of the address. Space in name should be encoded into %20. */ - WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag); + WithdrawResult withdraw(String coin, String withdrawOrderId, String network, String address, String amount, + String name, String addressTag, Boolean transactionFeeFlag); /** * Conver a list of assets to BNB @@ -282,16 +280,47 @@ public interface BinanceApiRestClient { /** * Fetch account deposit history. * + * @param coin the asset to get the history for * @return deposit history, containing a list of deposits */ - DepositHistory getDepositHistory(String asset); + List getDepositHistory(String coin); + + /** + * Fetch account deposit history. + * + * @param coin the asset to get the history for + * @param status 0(0:pending,6: credited but cannot withdraw, 1:success) + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp + * @param offset Default:0 + * @param limit Default:1000, Max:1000 + * @return deposit history, containing a list of deposits + */ + List getDepositHistory(String coin, int status, Long startTime, Long endTime, + int offset, int limit); + + /** + * Fetch account withdraw history. + * + * @param coin the asset to get the history for + * @return withdraw history, containing a list of withdrawals + */ + List getWithdrawHistory(String coin); /** * Fetch account withdraw history. * + * @param coin the asset to get the history for + * @param withdrawOrderId client id for withdraw + * @param status 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 6:Completed) + * @param startTime Default: 90 days from current timestamp + * @param endTime Default: present timestamp + * @param offset Default:0 + * @param limit Default:1000, Max:1000 * @return withdraw history, containing a list of withdrawals */ - WithdrawHistory getWithdrawHistory(String asset); + List getWithdrawHistory(String coin, String withdrawOrderId, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit); /** * Fetch sub-account transfer history. @@ -301,11 +330,12 @@ public interface BinanceApiRestClient { List getSubAccountTransfers(); /** - * Fetch deposit address. - * - * @return deposit address for a given asset. + * Fetch deposit address supported network. + * @param asset coin property + * @param network network property + * @return deposit address for given network and asset */ - DepositAddress getDepositAddress(String asset); + DepositAddress getDepositAddress(String asset, String network); // User stream endpoints diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java index e6ea387b9..26dcbaa6b 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiAsyncRestClientImpl.java @@ -4,16 +4,7 @@ import com.binance.api.client.BinanceApiCallback; import com.binance.api.client.config.BinanceApiConfig; import com.binance.api.client.constant.BinanceApiConstants; -import com.binance.api.client.domain.account.Account; -import com.binance.api.client.domain.account.DepositAddress; -import com.binance.api.client.domain.account.DepositHistory; -import com.binance.api.client.domain.account.NewOrder; -import com.binance.api.client.domain.account.NewOrderResponse; -import com.binance.api.client.domain.account.Order; -import com.binance.api.client.domain.account.Trade; -import com.binance.api.client.domain.account.TradeHistoryItem; -import com.binance.api.client.domain.account.WithdrawHistory; -import com.binance.api.client.domain.account.WithdrawResult; +import com.binance.api.client.domain.account.*; import com.binance.api.client.domain.account.request.AllOrdersRequest; import com.binance.api.client.domain.account.request.CancelOrderRequest; import com.binance.api.client.domain.account.request.CancelOrderResponse; @@ -209,26 +200,47 @@ public void getMyTrades(String symbol, BinanceApiCallback> callback) } @Override - public void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback callback) { - binanceApiService.withdraw(asset, address, amount, name, addressTag, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + public void withdraw(String coin, String withdrawOrderId, String network, String address, String addressTag, + String amount, Boolean transactionFeeFlag, String name, BinanceApiCallback callback) { + binanceApiService.withdraw(coin, withdrawOrderId, network, address, addressTag, amount, transactionFeeFlag, name, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) .enqueue(new BinanceApiCallbackAdapter<>(callback)); } + + @Override + public void getDepositHistory(String coin, BinanceApiCallback> callback) { + binanceApiService.getDepositHistory(coin, null, null, null, null, 1000, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + .enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + @Override - public void getDepositHistory(String asset, BinanceApiCallback callback) { - binanceApiService.getDepositHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + public void getDepositHistory(String coin, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit, BinanceApiCallback> callback) { + binanceApiService.getDepositHistory(coin, status, startTime, endTime, offset, limit, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) .enqueue(new BinanceApiCallbackAdapter<>(callback)); } @Override - public void getWithdrawHistory(String asset, BinanceApiCallback callback) { - binanceApiService.getWithdrawHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + public void getWithdrawHistory(String coin, BinanceApiCallback> callback) { + binanceApiService.getWithdrawHistory(coin, null, null, null, null, null, null, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + .enqueue(new BinanceApiCallbackAdapter<>(callback)); + } + + @Override + public void getWithdrawHistory(String coin, String withdrawOrderId, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit, BinanceApiCallback> callback) { + binanceApiService.getWithdrawHistory(coin, withdrawOrderId, status, startTime, endTime, offset, limit, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) .enqueue(new BinanceApiCallbackAdapter<>(callback)); } @Override - public void getDepositAddress(String asset, BinanceApiCallback callback) { - binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) + public void getDepositAddress(String asset, String network, BinanceApiCallback callback) { + binanceApiService.getDepositAddress(asset, network, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()) .enqueue(new BinanceApiCallbackAdapter<>(callback)); } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java index c80c7a06d..1c7d3558a 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiRestClientImpl.java @@ -229,8 +229,10 @@ public List getMyTrades(String symbol, Long fromId) { } @Override - public WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag) { - return executeSync(binanceApiService.withdraw(asset, address, amount, name, addressTag, + public WithdrawResult withdraw(String coin, String withdrawOrderId, String network, String address, String amount, + String name, String addressTag, Boolean transactionFeeFlag) { + return executeSync(binanceApiService.withdraw(coin, withdrawOrderId, network, address, + addressTag, amount, transactionFeeFlag, name, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } @@ -240,15 +242,29 @@ public DustTransferResponse dustTranfer(List asset) { } @Override - public DepositHistory getDepositHistory(String asset) { - return executeSync(binanceApiService.getDepositHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis())); + public List getDepositHistory(String coin) { + return executeSync(binanceApiService.getDepositHistory(coin, null, null, null, null, null, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } @Override - public WithdrawHistory getWithdrawHistory(String asset) { - return executeSync(binanceApiService.getWithdrawHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, - System.currentTimeMillis())); + public List getDepositHistory(String coin, int status, Long startTime, Long endTime, + int offset, int limit) { + return executeSync(binanceApiService.getDepositHistory(coin, status, startTime, endTime, offset, limit, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); + } + + @Override + public List getWithdrawHistory(String coin) { + return executeSync(binanceApiService.getWithdrawHistory(coin, null, null, null, null, null, null, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); + } + + @Override + public List getWithdrawHistory(String coin, String withdrawOrderId, Integer status, Long startTime, Long endTime, + Integer offset, Integer limit) { + return executeSync(binanceApiService.getWithdrawHistory(coin, withdrawOrderId, status, startTime, endTime, offset, limit, + BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } @Override @@ -257,8 +273,8 @@ public List getSubAccountTransfers() { } @Override - public DepositAddress getDepositAddress(String asset) { - return executeSync(binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, + public DepositAddress getDepositAddress(String asset, String network) { + return executeSync(binanceApiService.getDepositAddress(asset, network, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())); } diff --git a/src/main/java/com/binance/api/client/impl/BinanceApiService.java b/src/main/java/com/binance/api/client/impl/BinanceApiService.java index 5825f9844..c303cdfa1 100755 --- a/src/main/java/com/binance/api/client/impl/BinanceApiService.java +++ b/src/main/java/com/binance/api/client/impl/BinanceApiService.java @@ -152,22 +152,32 @@ Call> getMyTrades(@Query("symbol") String symbol, @Query("limit") In @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @POST("/wapi/v3/withdraw.html") - Call withdraw(@Query("asset") String asset, @Query("address") String address, @Query("amount") String amount, @Query("name") String name, @Query("addressTag") String addressTag, + @POST("/sapi/v1/capital/withdraw/apply") + Call withdraw(@Query("coin") String coin,@Query("withdrawOrderId") String withdrawOrderId, + @Query("network") String network, @Query("address") String address, + @Query("addressTag") String addressTag, @Query("amount") String amount, + @Query("transactionFeeFlag") Boolean feeFlag, @Query("name") String name, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/depositHistory.html") - Call getDepositHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + @GET("/sapi/v1/capital/deposit/hisrec") + Call> getDepositHistory(@Query("coin") String coin, @Query("status") Integer status, + @Query("startTime") Long startTime, @Query("endTime") Long endTime, + @Query("offset") Integer offset, @Query("limit") Integer limit, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/withdrawHistory.html") - Call getWithdrawHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + @GET("/sapi/v1/capital/withdraw/history") + Call> getWithdrawHistory(@Query("coin") String coin, @Query("status") String withdrawOrderId, + @Query("status") Integer status, + @Query("startTime") Long startTime, @Query("endTime") Long endTime, + @Query("offset") Integer offset, @Query("limit") Integer limit, + @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) - @GET("/wapi/v3/depositAddress.html") - Call getDepositAddress(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); + @GET("/sapi/v1/capital/deposit/address") + Call getDepositAddress(@Query("coin") String asset, @Query("network") String network, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp); @Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER) @POST("/sapi/v1/asset/dust") diff --git a/src/test/java/com/binance/api/examples/AccountEndpointsExample.java b/src/test/java/com/binance/api/examples/AccountEndpointsExample.java index 72fc68c3d..485943b05 100755 --- a/src/test/java/com/binance/api/examples/AccountEndpointsExample.java +++ b/src/test/java/com/binance/api/examples/AccountEndpointsExample.java @@ -32,9 +32,9 @@ public static void main(String[] args) { System.out.println(client.getDepositHistory("ETH")); // Get deposit address - System.out.println(client.getDepositAddress("ETH")); + System.out.println(client.getDepositAddress("ETH", null)); // Withdraw - client.withdraw("ETH", "0x123", "0.1", null, null); + client.withdraw("ETH", null, "ERC20", "0x123", "0.1", null, null, false); } } diff --git a/src/test/java/com/binance/api/examples/AccountEndpointsExampleAsync.java b/src/test/java/com/binance/api/examples/AccountEndpointsExampleAsync.java index 5ede0526b..0e52c9fa8 100755 --- a/src/test/java/com/binance/api/examples/AccountEndpointsExampleAsync.java +++ b/src/test/java/com/binance/api/examples/AccountEndpointsExampleAsync.java @@ -26,6 +26,6 @@ public static void main(String[] args) { client.getDepositHistory("ETH", response -> System.out.println(response)); // Withdraw (async) - client.withdraw("ETH", "0x123", "0.1", null, null, response -> {}); + client.withdraw("ETH", null, "ERC20", "0x123", null, "0.1", false, null, response -> {}); } }