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

@@ -5,7 +5,6 @@ import (
"errors"
"sort"
"strconv"
"strings"
"sync"
"time"
@@ -15,6 +14,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"
@@ -590,8 +590,21 @@ func (b *Bitstamp) GetOrderInfo(ctx context.Context, orderID string, pair curren
}
// GetDepositAddress returns a deposit address for a specified currency
func (b *Bitstamp) GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, _ string) (string, error) {
return b.GetCryptoDepositAddress(ctx, cryptocurrency)
func (b *Bitstamp) GetDepositAddress(ctx context.Context, cryptocurrency currency.Code, _, _ string) (*deposit.Address, error) {
addr, err := b.GetCryptoDepositAddress(ctx, cryptocurrency)
if err != nil {
return nil, err
}
var tag string
if addr.DestinationTag != 0 {
tag = strconv.FormatInt(addr.DestinationTag, 10)
}
return &deposit.Address{
Address: addr.Address,
Tag: tag,
}, nil
}
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
@@ -604,21 +617,13 @@ func (b *Bitstamp) WithdrawCryptocurrencyFunds(ctx context.Context, withdrawRequ
withdrawRequest.Amount,
withdrawRequest.Crypto.Address,
withdrawRequest.Currency.String(),
withdrawRequest.Crypto.AddressTag,
true)
withdrawRequest.Crypto.AddressTag)
if err != nil {
return nil, err
}
if len(resp.Error) != 0 {
var details strings.Builder
for x := range resp.Error {
details.WriteString(strings.Join(resp.Error[x], ""))
}
return nil, errors.New(details.String())
}
return &withdraw.ExchangeResponse{
ID: resp.ID,
ID: strconv.FormatInt(resp.ID, 10),
}, nil
}
@@ -643,17 +648,9 @@ func (b *Bitstamp) WithdrawFiatFunds(ctx context.Context, withdrawRequest *withd
if err != nil {
return nil, err
}
if resp.Status == errStr {
var details strings.Builder
for x := range resp.Reason {
details.WriteString(strings.Join(resp.Reason[x], ""))
}
return nil, errors.New(details.String())
}
return &withdraw.ExchangeResponse{
ID: resp.ID,
Status: resp.Status,
ID: strconv.FormatInt(resp.ID, 10),
}, nil
}
@@ -684,17 +681,9 @@ func (b *Bitstamp) WithdrawFiatFundsToInternationalBank(ctx context.Context, wit
if err != nil {
return nil, err
}
if resp.Status == errStr {
var details strings.Builder
for x := range resp.Reason {
details.WriteString(strings.Join(resp.Reason[x], ""))
}
return nil, errors.New(details.String())
}
return &withdraw.ExchangeResponse{
ID: resp.ID,
Status: resp.Status,
ID: strconv.FormatInt(resp.ID, 10),
}, nil
}