Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Update wallet endpoints #397

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
</licenses>

<properties>
<java.version>11</java.version>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<com.squareup.retrofit2.version>2.4.0</com.squareup.retrofit2.version>
</properties>

Expand Down Expand Up @@ -52,11 +56,26 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
62 changes: 45 additions & 17 deletions src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<WithdrawResult> 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<WithdrawResult> callback);
void getDepositHistory(String coin, BinanceApiCallback<List<Deposit>> 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<DepositHistory> callback);
void getDepositHistory(String coin, Integer status, Long startTime, Long endTime,
Integer offset, Integer limit, BinanceApiCallback<List<Deposit>> 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<List<Withdraw>> 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<WithdrawHistory> callback);
void getWithdrawHistory(String coin, String withdrawOrderId, Integer status, Long startTime, Long endTime,
Integer offset, Integer limit, BinanceApiCallback<List<Withdraw>> callback);

/**
* Fetch deposit address.
*
* @param callback the callback that handles the response and returns the deposit address
*/
void getDepositAddress(String asset, BinanceApiCallback<DepositAddress> callback);
void getDepositAddress(String asset, String network, BinanceApiCallback<DepositAddress> callback);

// User stream endpoints

Expand Down
66 changes: 48 additions & 18 deletions src/main/java/com/binance/api/client/BinanceApiRestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all params documented

* @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
Expand All @@ -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<Deposit> 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Param description missing

*/
List<Deposit> 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<Withdraw> 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<Withdraw> getWithdrawHistory(String coin, String withdrawOrderId, Integer status, Long startTime, Long endTime,
Integer offset, Integer limit);

/**
* Fetch sub-account transfer history.
Expand All @@ -301,11 +330,12 @@ public interface BinanceApiRestClient {
List<SubAccountTransfer> 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -209,26 +200,47 @@ public void getMyTrades(String symbol, BinanceApiCallback<List<Trade>> callback)
}

@Override
public void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback<WithdrawResult> 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<WithdrawResult> 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<List<Deposit>> 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<DepositHistory> 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<List<Deposit>> 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<WithdrawHistory> callback) {
binanceApiService.getWithdrawHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())
public void getWithdrawHistory(String coin, BinanceApiCallback<List<Withdraw>> 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<List<Withdraw>> 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<DepositAddress> callback) {
binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())
public void getDepositAddress(String asset, String network, BinanceApiCallback<DepositAddress> callback) {
binanceApiService.getDepositAddress(asset, network, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())
.enqueue(new BinanceApiCallbackAdapter<>(callback));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ public List<Trade> 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()));
}

Expand All @@ -240,15 +242,29 @@ public DustTransferResponse dustTranfer(List<String> asset) {
}

@Override
public DepositHistory getDepositHistory(String asset) {
return executeSync(binanceApiService.getDepositHistory(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW,
System.currentTimeMillis()));
public List<Deposit> 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<Deposit> 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<Withdraw> getWithdrawHistory(String coin) {
return executeSync(binanceApiService.getWithdrawHistory(coin, null, null, null, null, null, null,
BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()));
}

@Override
public List<Withdraw> 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
Expand All @@ -257,8 +273,8 @@ public List<SubAccountTransfer> 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()));
}

Expand Down
Loading