OKX: Fix GetAvailableTransferChains bug (#1177)

* okx: fix get cryptocurrency deposit address for chain bug

* Update exchanges/okx/okx_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/okx/okx_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Revert "Update exchanges/okx/okx_wrapper.go"

This reverts commit 4345f57ce0e984f562ec576aeebc09407a1d2544.

* okx: temp filter for available transfer chain

* glorious: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
Ryan O'Hara-Reid
2023-05-08 16:09:13 +10:00
committed by GitHub
parent 19897e99c5
commit 8a6916353f
2 changed files with 17 additions and 11 deletions

View File

@@ -978,16 +978,16 @@ type LightningDepositItem struct {
// CurrencyDepositResponseItem represents the deposit address information item.
type CurrencyDepositResponseItem struct {
Tag string `json:"tag"`
Chain string `json:"chain"`
ContractAddress string `json:"ctAddr"`
Currency string `json:"ccy"`
ToBeneficiaryAccount string `json:"to"`
Address string `json:"addr"`
Selected bool `json:"selected"`
Memo string `json:"memo"`
DepositAddressAttachment string `json:"addrEx"`
PaymentID string `json:"pmtId"`
Tag string `json:"tag"`
Chain string `json:"chain"`
ContractAddress string `json:"ctAddr"`
Currency string `json:"ccy"`
ToBeneficiaryAccount string `json:"to"`
Address string `json:"addr"`
Selected bool `json:"selected"`
Memo string `json:"memo"`
DepositAddressAttachment map[string]string `json:"addrEx"`
PaymentID string `json:"pmtId"`
}
// DepositHistoryResponseItem deposit history response item.

View File

@@ -1453,7 +1453,13 @@ func (ok *Okx) GetAvailableTransferChains(ctx context.Context, cryptocurrency cu
}
chains := make([]string, 0, len(currencyChains))
for x := range currencyChains {
if !cryptocurrency.IsEmpty() && !strings.EqualFold(cryptocurrency.String(), currencyChains[x].Currency) {
if (!cryptocurrency.IsEmpty() && !strings.EqualFold(cryptocurrency.String(), currencyChains[x].Currency)) ||
(!currencyChains[x].CanDeposit && !currencyChains[x].CanWithdraw) ||
// Lightning network is currently not supported by transfer chains
// as it is an invoice string which is generated per request and is
// not a static address. TODO: Add a hook to generate a new invoice
// string per request.
(currencyChains[x].Chain != "" && currencyChains[x].Chain == "BTC-Lightning") {
continue
}
chains = append(chains, currencyChains[x].Chain)