mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-08 15:11:07 +00:00
engine/okgroup: fix panic when calling GetDepositAddress() (#858)
* engine/okgroup: fix caller panic and patched for re-occurance * engine/helpers: remove nil check as it was not neccessary.
This commit is contained in:
@@ -691,10 +691,7 @@ func (bot *Engine) GetCryptocurrencyDepositAddressesByExchange(exchName string)
|
|||||||
func (bot *Engine) GetExchangeCryptocurrencyDepositAddress(ctx context.Context, exchName, accountID, chain string, item currency.Code, bypassCache bool) (*deposit.Address, error) {
|
func (bot *Engine) GetExchangeCryptocurrencyDepositAddress(ctx context.Context, exchName, accountID, chain string, item currency.Code, bypassCache bool) (*deposit.Address, error) {
|
||||||
if bot.DepositAddressManager != nil && bot.DepositAddressManager.IsSynced() && !bypassCache {
|
if bot.DepositAddressManager != nil && bot.DepositAddressManager.IsSynced() && !bypassCache {
|
||||||
resp, err := bot.DepositAddressManager.GetDepositAddressByExchangeAndCurrency(exchName, chain, item)
|
resp, err := bot.DepositAddressManager.GetDepositAddressByExchangeAndCurrency(exchName, chain, item)
|
||||||
if err != nil {
|
return &resp, err
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
}
|
||||||
exch, err := bot.GetExchangeByName(exchName)
|
exch, err := bot.GetExchangeByName(exchName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ import (
|
|||||||
// Therefore this OKGroup_Wrapper can be shared between OKEX and OKCoin.
|
// Therefore this OKGroup_Wrapper can be shared between OKEX and OKCoin.
|
||||||
// When circumstances change, wrapper funcs can be split appropriately
|
// When circumstances change, wrapper funcs can be split appropriately
|
||||||
|
|
||||||
|
var errNoAccountDepositAddress = errors.New("no account deposit address")
|
||||||
|
|
||||||
// Setup sets user exchange configuration settings
|
// Setup sets user exchange configuration settings
|
||||||
func (o *OKGroup) Setup(exch *config.Exchange) error {
|
func (o *OKGroup) Setup(exch *config.Exchange) error {
|
||||||
err := exch.Validate()
|
err := exch.Validate()
|
||||||
@@ -428,11 +430,16 @@ func (o *OKGroup) GetOrderInfo(ctx context.Context, orderID string, pair currenc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetDepositAddress returns a deposit address for a specified currency
|
// GetDepositAddress returns a deposit address for a specified currency
|
||||||
func (o *OKGroup) GetDepositAddress(ctx context.Context, p currency.Code, _, _ string) (*deposit.Address, error) {
|
func (o *OKGroup) GetDepositAddress(ctx context.Context, c currency.Code, _, _ string) (*deposit.Address, error) {
|
||||||
wallet, err := o.GetAccountDepositAddressForCurrency(ctx, p.Lower().String())
|
wallet, err := o.GetAccountDepositAddressForCurrency(ctx, c.Lower().String())
|
||||||
if err != nil || len(wallet) == 0 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if len(wallet) == 0 {
|
||||||
|
return nil, fmt.Errorf("%w for currency %s",
|
||||||
|
errNoAccountDepositAddress,
|
||||||
|
c)
|
||||||
|
}
|
||||||
return &deposit.Address{
|
return &deposit.Address{
|
||||||
Address: wallet[0].Address,
|
Address: wallet[0].Address,
|
||||||
Tag: wallet[0].Tag,
|
Tag: wallet[0].Tag,
|
||||||
|
|||||||
Reference in New Issue
Block a user