exchanges/engine: Add multichain deposit/withdrawal support (#794)

* Add exchange multichain support

* Start tidying up

* Add multichain transfer support for Bitfinex and fix poloniex bug

* Add Coinbene multichain support

* Start adjusting the deposit address manager

* Fix deposit tests and further enhancements

* Cleanup

* Add bypass flag, expand tests plus error coverage for Huobi

Adjust helpers

* Address nitterinos

* BFX wd changes

* Address nitterinos

* Minor fixes rebasing on master

* Fix BFX acceptableMethods test

* Add some TO-DOs for 2 tests WRT races

* Fix acceptableMethods test round 2

* Address nitterinos
This commit is contained in:
Adrian Gallagher
2021-10-15 15:55:38 +11:00
committed by GitHub
parent b093a7df19
commit 0c00b7e1df
145 changed files with 46329 additions and 5507 deletions

View File

@@ -33,9 +33,6 @@ const (
privateWithdrawCoinsToAddress = "WithdrawCoinsToAddress"
privateCreateCoupon = "CreateYobicode"
privateRedeemCoupon = "RedeemYobicode"
yobitAuthRate = 0
yobitUnauthRate = 0
)
// Yobit is the overarching type across the Yobit package
@@ -192,20 +189,27 @@ func (y *Yobit) GetTradeHistory(ctx context.Context, tidFrom, count, tidEnd, sin
}
// GetCryptoDepositAddress returns the deposit address for a specific currency
func (y *Yobit) GetCryptoDepositAddress(ctx context.Context, coin string) (DepositAddress, error) {
func (y *Yobit) GetCryptoDepositAddress(ctx context.Context, coin string, createNew bool) (*DepositAddress, error) {
req := url.Values{}
req.Add("coinName", coin)
if createNew {
req.Set("need_new", "1")
}
result := DepositAddress{}
err := y.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpotSupplementary, privateGetDepositAddress, req, &result)
var result DepositAddress
err := y.SendAuthenticatedHTTPRequest(ctx,
exchange.RestSpotSupplementary,
privateGetDepositAddress,
req,
&result)
if err != nil {
return result, err
return nil, err
}
if result.Success != 1 {
return result, fmt.Errorf("%s", result.Error)
return nil, errors.New(result.Error)
}
return result, nil
return &result, nil
}
// WithdrawCoinsToAddress initiates a withdrawal to a specified address

View File

@@ -115,6 +115,17 @@ func TestGetOrderInfo(t *testing.T) {
}
}
func TestGetCryptoDepositAddress(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("api keys not set")
}
_, err := y.GetCryptoDepositAddress(context.Background(), "bTc", false)
if err != nil {
t.Error(err)
}
}
func TestCancelOrder(t *testing.T) {
t.Parallel()
err := y.CancelExistingOrder(context.Background(), 1337)
@@ -435,6 +446,7 @@ func TestModifyOrder(t *testing.T) {
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.Request{
Exchange: y.Name,
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
@@ -488,12 +500,12 @@ func TestWithdrawInternationalBank(t *testing.T) {
func TestGetDepositAddress(t *testing.T) {
if areTestAPIKeysSet() {
_, err := y.GetDepositAddress(context.Background(), currency.BTC, "")
_, err := y.GetDepositAddress(context.Background(), currency.BTC, "", "")
if err != nil {
t.Error("GetDepositAddress() Expected error")
t.Error(err)
}
} else {
_, err := y.GetDepositAddress(context.Background(), currency.BTC, "")
_, err := y.GetDepositAddress(context.Background(), currency.BTC, "", "")
if err == nil {
t.Error("GetDepositAddress() error")
}

View File

@@ -16,6 +16,7 @@ import (
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/deposit"
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
@@ -495,13 +496,18 @@ func (y *Yobit) GetOrderInfo(ctx context.Context, orderID string, pair currency.
}
// GetDepositAddress returns a deposit address for a specified currency
func (y *Yobit) GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, _ string) (string, error) {
a, err := y.GetCryptoDepositAddress(ctx, cryptocurrency.String())
if err != nil {
return "", err
func (y *Yobit) GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, _, _ string) (*deposit.Address, error) {
if cryptocurrency == currency.XRP {
// {"success":1,"return":{"status":"online","blocks":65778672,"address":996707783,"processed_amount":0.00000000,"server_time":1629425030}}
return nil, errors.New("XRP isn't supported as the API does not return a valid address")
}
return a.Return.Address, nil
addr, err := y.GetCryptoDepositAddress(ctx, cryptocurrency.String(), false)
if err != nil {
return nil, err
}
return &deposit.Address{Address: addr.Return.Address}, nil
}
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is