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

Sub-account transfer API support #299

Open
wants to merge 1 commit 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
14 changes: 13 additions & 1 deletion src/main/java/com/binance/api/client/BinanceApiRestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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.SubAccountTransfer;
import com.binance.api.client.domain.account.Trade;
import com.binance.api.client.domain.account.TradeHistoryItem;
import com.binance.api.client.domain.account.WithdrawHistory;
Expand All @@ -15,8 +16,8 @@
import com.binance.api.client.domain.account.request.CancelOrderResponse;
import com.binance.api.client.domain.account.request.OrderRequest;
import com.binance.api.client.domain.account.request.OrderStatusRequest;
import com.binance.api.client.domain.general.ExchangeInfo;
import com.binance.api.client.domain.general.Asset;
import com.binance.api.client.domain.general.ExchangeInfo;
import com.binance.api.client.domain.market.AggTrade;
import com.binance.api.client.domain.market.BookTicker;
import com.binance.api.client.domain.market.Candlestick;
Expand Down Expand Up @@ -273,6 +274,17 @@ public interface BinanceApiRestClient {
*/
DepositAddress getDepositAddress(String asset);

/**
* Transfer assets from/to main account and sub-account
*
* @param fromEmail Sender sub-account email
* @param toEmail Recipient sub-account email
* @param asset Asset to transfer
* @param amount Amount to transfer
* @return SubAccountTransfer response
*/
SubAccountTransfer subAccountTransfer(String fromEmail, String toEmail, String asset, String amount);

// User stream endpoints

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.binance.api.client.domain.account;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.binance.api.client.constant.BinanceApiConstants;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class SubAccountTransfer {

private boolean success;
private String txnId;

public boolean isSuccess() {
return success;
}

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

public String getTxnId() {
return txnId;
}

public void setTxnId(String txnId) {
this.txnId = txnId;
}

@Override
public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
.append("success", success)
.append("txnId", txnId)
.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ public DepositAddress getDepositAddress(String asset) {
return executeSync(binanceApiService.getDepositAddress(asset, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()));
}

@Override
public SubAccountTransfer subAccountTransfer(String fromEmail, String toEmail, String asset, String amount) {
return executeSync(binanceApiService.subAccountTransfer(fromEmail, toEmail, asset, amount, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()));
}

// User stream endpoints

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ Call<WithdrawResult> withdraw(@Query("asset") String asset, @Query("address") St
@GET("/wapi/v3/depositAddress.html")
Call<DepositAddress> getDepositAddress(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);

@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@POST("/wapi/v3/sub-account/transfer.html")
Call<SubAccountTransfer> subAccountTransfer(@Query("fromEmail") String fromEmail, @Query("toEmail") String toEmail, @Query("asset") String asset, @Query("amount") String amount, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);

// User stream endpoints

@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER)
Expand Down