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

Commit

Permalink
Merge pull request #126 from igorustinov/master
Browse files Browse the repository at this point in the history
Support for withdrawal status.
  • Loading branch information
joaopsilva authored May 4, 2018
2 parents 69f56f5 + 6067b08 commit db200f2
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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.request.AllOrdersRequest;
import com.binance.api.client.domain.account.request.CancelOrderRequest;
import com.binance.api.client.domain.account.request.OrderRequest;
Expand Down Expand Up @@ -260,8 +261,9 @@ public interface BinanceApiAsyncRestClient {
* @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.
*/
void withdraw(String asset, String address, String amount, String name, BinanceApiCallback<Void> callback);
void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback<WithdrawResult> callback);

/**
* Fetch account deposit history.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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.request.AllOrdersRequest;
import com.binance.api.client.domain.account.request.CancelOrderRequest;
import com.binance.api.client.domain.account.request.OrderRequest;
Expand Down Expand Up @@ -246,8 +247,9 @@ public interface BinanceApiRestClient {
* @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.
*/
void withdraw(String asset, String address, String amount, String name);
WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag);

/**
* Fetch account deposit history.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ public class DepositHistory {

private boolean success;

private String msg;

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

public List<Deposit> getDepositList() {
return depositList;
}
Expand All @@ -39,6 +49,7 @@ public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
.append("depositList", depositList)
.append("success", success)
.append("msg", msg)
.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.binance.api.client.domain.account;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* A withdraw result that was done to a Binance account.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class WithdrawResult {

/**
* Withdraw message.
*/
private String msg;

/**
* Withdraw success.
*/
private boolean success;

/**
* Withdraw id.
*/
private String id;

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

public boolean isSuccess() {
return success;
}

public void setSuccess(boolean success) {
this.success = success;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("msg", msg)
.append("success", success)
.append("id", id)
.toString();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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.request.AllOrdersRequest;
import com.binance.api.client.domain.account.request.CancelOrderRequest;
import com.binance.api.client.domain.account.request.OrderRequest;
Expand Down Expand Up @@ -198,8 +199,8 @@ public void getMyTrades(String symbol, BinanceApiCallback<List<Trade>> callback)
}

@Override
public void withdraw(String asset, String address, String amount, String name, BinanceApiCallback<Void> callback) {
binanceApiService.withdraw(asset, address, amount, name, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis())
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())
.enqueue(new BinanceApiCallbackAdapter<>(callback));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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.request.AllOrdersRequest;
import com.binance.api.client.domain.account.request.CancelOrderRequest;
import com.binance.api.client.domain.account.request.OrderRequest;
Expand Down Expand Up @@ -193,8 +194,8 @@ public List<Trade> getMyTrades(String symbol) {
}

@Override
public void withdraw(String asset, String address, String amount, String name) {
executeSync(binanceApiService.withdraw(asset, address, amount, name, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()));
public WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag) {
return executeSync(binanceApiService.withdraw(asset, address, amount, name, addressTag, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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.event.ListenKey;
import com.binance.api.client.domain.general.Asset;
import com.binance.api.client.domain.general.ExchangeInfo;
Expand Down Expand Up @@ -135,8 +136,8 @@ Call<List<Trade>> getMyTrades(@Query("symbol") String symbol, @Query("limit") In

@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@POST("/wapi/v3/withdraw.html")
Call<Void> withdraw(@Query("asset") String asset, @Query("address") String address, @Query("amount") String amount, @Query("name") String name,
@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
Call<WithdrawResult> withdraw(@Query("asset") String asset, @Query("address") String address, @Query("amount") String amount, @Query("name") String name, @Query("addressTag") String addressTag,
@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);


@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public static void main(String[] args) {
System.out.println(client.getDepositAddress("ETH"));

// Withdraw
client.withdraw("ETH", "0x123", "0.1", null);
client.withdraw("ETH", "0x123", "0.1", null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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, response -> {});
client.withdraw("ETH", "0x123", "0.1", null, null, response -> {});
}
}

0 comments on commit db200f2

Please sign in to comment.