diff --git a/exchanges/alphapoint/alphapoint.go b/exchanges/alphapoint/alphapoint.go index 98b220c8..92e15302 100644 --- a/exchanges/alphapoint/alphapoint.go +++ b/exchanges/alphapoint/alphapoint.go @@ -54,7 +54,7 @@ func (a *Alphapoint) SetDefaults() { a.AssetTypes = []string{ticker.Spot} a.SupportsAutoPairUpdating = false a.SupportsRESTTickerBatching = false - a.APIWithdrawPermissions = exchange.WithdrawCryptoWith2FA | exchange.AutoWithdrawCryptoWithAPIPermission + a.APIWithdrawPermissions = exchange.WithdrawCryptoWith2FA | exchange.AutoWithdrawCryptoWithAPIPermission | exchange.NoFiatWithdrawals a.Requester = request.New(a.Name, request.NewRateLimit(time.Minute*10, alphapointAuthRate), request.NewRateLimit(time.Minute*10, alphapointUnauthRate), diff --git a/exchanges/alphapoint/alphapoint_test.go b/exchanges/alphapoint/alphapoint_test.go index e7a825f1..8f538602 100644 --- a/exchanges/alphapoint/alphapoint_test.go +++ b/exchanges/alphapoint/alphapoint_test.go @@ -483,7 +483,7 @@ func TestFormatWithdrawPermissions(t *testing.T) { // Arrange a := &Alphapoint{} a.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.WithdrawCryptoWith2FAText + expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.WithdrawCryptoWith2FAText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := a.FormatWithdrawPermissions() // Assert @@ -616,3 +616,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Expected 'Not implemented', recieved %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + a := &Alphapoint{} + a.SetDefaults() + + if areTestAPIKeysSet(a) && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := a.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrNotYetImplemented { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrNotYetImplemented, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + a := &Alphapoint{} + a.SetDefaults() + + if areTestAPIKeysSet(a) && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := a.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrNotYetImplemented { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrNotYetImplemented, err) + } +} diff --git a/exchanges/anx/anx_test.go b/exchanges/anx/anx_test.go index 55263f31..92b50fc0 100644 --- a/exchanges/anx/anx_test.go +++ b/exchanges/anx/anx_test.go @@ -3,6 +3,7 @@ package anx import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -362,3 +363,35 @@ func TestWithdraw(t *testing.T) { t.Error("Expecting an error when no keys are set") } } + +func TestWithdrawFiat(t *testing.T) { + a.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := a.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + a.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := a.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/anx/anx_wrapper.go b/exchanges/anx/anx_wrapper.go index 8dce5a2a..22b759fe 100644 --- a/exchanges/anx/anx_wrapper.go +++ b/exchanges/anx/anx_wrapper.go @@ -319,14 +319,14 @@ func (a *ANX) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawReque // submitted func (a *ANX) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { // Fiat withdrawals available via website - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted func (a *ANX) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { // Fiat withdrawals available via website - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/binance/binance.go b/exchanges/binance/binance.go index f7295084..5e1502bc 100644 --- a/exchanges/binance/binance.go +++ b/exchanges/binance/binance.go @@ -81,7 +81,7 @@ func (b *Binance) SetDefaults() { b.AssetTypes = []string{ticker.Spot} b.SupportsAutoPairUpdating = true b.SupportsRESTTickerBatching = true - b.APIWithdrawPermissions = exchange.AutoWithdrawCrypto + b.APIWithdrawPermissions = exchange.AutoWithdrawCrypto | exchange.NoFiatWithdrawals b.SetValues() b.Requester = request.New(b.Name, request.NewRateLimit(time.Second, binanceAuthRate), diff --git a/exchanges/binance/binance_test.go b/exchanges/binance/binance_test.go index 2fecc28b..fa4c98b6 100644 --- a/exchanges/binance/binance_test.go +++ b/exchanges/binance/binance_test.go @@ -3,6 +3,7 @@ package binance import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -322,7 +323,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange b.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoText + expectedResult := exchange.AutoWithdrawCryptoText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := b.FormatWithdrawPermissions() // Assert @@ -458,3 +459,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/binance/binance_wrapper.go b/exchanges/binance/binance_wrapper.go index 6cc59721..7b79faea 100644 --- a/exchanges/binance/binance_wrapper.go +++ b/exchanges/binance/binance_wrapper.go @@ -280,13 +280,13 @@ func (b *Binance) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawR // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (b *Binance) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (b *Binance) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bitfinex/bitfinex.go b/exchanges/bitfinex/bitfinex.go index d3205f71..7cb26949 100644 --- a/exchanges/bitfinex/bitfinex.go +++ b/exchanges/bitfinex/bitfinex.go @@ -600,6 +600,42 @@ func (b *Bitfinex) WithdrawCryptocurrency(withdrawType, wallet, address, currenc b.SendAuthenticatedHTTPRequest("POST", bitfinexWithdrawal, request, &response) } +// WithdrawFIAT requests a withdrawal from one of your wallets. +// For Cryptocurrency, use WithdrawCryptocurrency +func (b *Bitfinex) WithdrawFIAT(withdrawType, wallet, wireCurrency, + accountName, bankName, bankAddress, bankCity, bankCountry, swift, transactionMessage, + intermediaryBankName, intermediaryBankAddress, intermediaryBankCity, intermediaryBankCountry, intermediaryBankSwift string, + amount, accountNumber, intermediaryBankAccountNumber float64, isExpressWire, requiresIntermediaryBank bool) ([]Withdrawal, error) { + response := []Withdrawal{} + request := make(map[string]interface{}) + request["withdraw_type"] = withdrawType + request["walletselected"] = wallet + request["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) + request["account_name"] = accountName + request["account_number"] = strconv.FormatFloat(accountNumber, 'f', -1, 64) + request["bank_name"] = bankName + request["bank_address"] = bankAddress + request["bank_city"] = bankCity + request["bank_country"] = bankCountry + request["expressWire"] = isExpressWire + request["swift"] = swift + request["detail_payment"] = transactionMessage + request["currency"] = wireCurrency + request["account_address"] = bankAddress + + if requiresIntermediaryBank { + request["intermediary_bank_name"] = intermediaryBankName + request["intermediary_bank_address"] = intermediaryBankAddress + request["intermediary_bank_city"] = intermediaryBankCity + request["intermediary_bank_country"] = intermediaryBankCountry + request["intermediary_bank_account"] = strconv.FormatFloat(intermediaryBankAccountNumber, 'f', -1, 64) + request["intermediary_bank_swift"] = intermediaryBankSwift + } + + return response, + b.SendAuthenticatedHTTPRequest("POST", bitfinexWithdrawal, request, &response) +} + // NewOrder submits a new order and returns a order information // Major Upgrade needed on this function to include all query params func (b *Bitfinex) NewOrder(currencyPair string, amount float64, price float64, buy bool, Type string, hidden bool) (Order, error) { diff --git a/exchanges/bitfinex/bitfinex_test.go b/exchanges/bitfinex/bitfinex_test.go index 06329f62..e4820716 100644 --- a/exchanges/bitfinex/bitfinex_test.go +++ b/exchanges/bitfinex/bitfinex_test.go @@ -831,3 +831,75 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.BTC, + Description: "WITHDRAW IT ALL", + BankAccountName: "Satoshi Nakamoto", + BankAccountNumber: 12345, + BankAddress: "123 Fake St", + BankCity: "Tarry Town", + BankCountry: "Hyrule", + BankName: "Federal Reserve Bank", + WireCurrency: symbol.USD, + SwiftCode: "Taylor", + RequiresIntermediaryBank: false, + IsExpressWire: false, + } + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.BTC, + Description: "WITHDRAW IT ALL", + BankAccountName: "Satoshi Nakamoto", + BankAccountNumber: 12345, + BankAddress: "123 Fake St", + BankCity: "Tarry Town", + BankCountry: "Hyrule", + BankName: "Federal Reserve Bank", + WireCurrency: symbol.USD, + SwiftCode: "Taylor", + RequiresIntermediaryBank: true, + IsExpressWire: false, + IntermediaryBankAccountNumber: 12345, + IntermediaryBankAddress: "123 Fake St", + IntermediaryBankCity: "Tarry Town", + IntermediaryBankCountry: "Hyrule", + IntermediaryBankName: "Federal Reserve Bank", + IntermediarySwiftCode: "Taylor", + } + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} diff --git a/exchanges/bitfinex/bitfinex_types.go b/exchanges/bitfinex/bitfinex_types.go index 8b449b8d..4ab0e68e 100644 --- a/exchanges/bitfinex/bitfinex_types.go +++ b/exchanges/bitfinex/bitfinex_types.go @@ -236,7 +236,8 @@ type WalletTransfer struct { type Withdrawal struct { Status string `json:"status"` Message string `json:"message"` - WithdrawalID int64 `json:"withdrawal_id,string"` + WithdrawalID int64 `json:"withdrawal_id,omitempty"` + Fees string `json:"fees,omitempty"` } // Order holds order information when an order is in the market diff --git a/exchanges/bitfinex/bitfinex_wrapper.go b/exchanges/bitfinex/bitfinex_wrapper.go index d1301415..b535913e 100644 --- a/exchanges/bitfinex/bitfinex_wrapper.go +++ b/exchanges/bitfinex/bitfinex_wrapper.go @@ -251,16 +251,49 @@ func (b *Bitfinex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Withdraw return fmt.Sprintf("%v", resp[0].WithdrawalID), err } -// WithdrawFiatFunds returns a withdrawal ID when a -// withdrawal is submitted +// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted +// Returns comma delimited withdrawal IDs func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + withdrawalType := "wire" + // Bitfinex has support for three types, exchange, margin and deposit + // As this is for trading, I've made the wrapper default 'exchange' + // TODO: Discover an automated way to make the decision for wallet type to withdraw from + walletType := "exchange" + resp, err := b.WithdrawFIAT(withdrawalType, walletType, withdrawRequest.WireCurrency, + withdrawRequest.BankAccountName, withdrawRequest.BankName, withdrawRequest.BankAddress, + withdrawRequest.BankCity, withdrawRequest.BankCountry, withdrawRequest.SwiftCode, + withdrawRequest.Description, withdrawRequest.IntermediaryBankName, withdrawRequest.IntermediaryBankAddress, + withdrawRequest.IntermediaryBankCity, withdrawRequest.IntermediaryBankCountry, withdrawRequest.IntermediarySwiftCode, + withdrawRequest.Amount, withdrawRequest.BankAccountNumber, withdrawRequest.IntermediaryBankAccountNumber, + withdrawRequest.IsExpressWire, withdrawRequest.RequiresIntermediaryBank) + if err != nil { + return "", err + } + if len(resp) == 0 { + return "", errors.New("No withdrawID returned. Check order status") + } + + var withdrawalSuccesses string + var withdrawalErrors string + for _, withdrawl := range resp { + if withdrawl.Status == "error" { + withdrawalErrors += fmt.Sprintf("%v ", withdrawl.Message) + } + if withdrawl.Status == "success" { + withdrawalSuccesses += fmt.Sprintf("%v,", withdrawl.WithdrawalID) + } + } + if len(withdrawalErrors) > 0 { + return withdrawalSuccesses, errors.New(withdrawalErrors) + } + + return withdrawalSuccesses, nil } -// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a -// withdrawal is submitted +// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted +// Returns comma delimited withdrawal IDs func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return b.WithdrawFiatFunds(withdrawRequest) } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bitflyer/bitflyer_test.go b/exchanges/bitflyer/bitflyer_test.go index be4eb24b..18fca113 100644 --- a/exchanges/bitflyer/bitflyer_test.go +++ b/exchanges/bitflyer/bitflyer_test.go @@ -354,3 +354,35 @@ func TestModifyOrder(t *testing.T) { t.Error("Test failed - ModifyOrder() error") } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrNotYetImplemented { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrNotYetImplemented, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrNotYetImplemented { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrNotYetImplemented, err) + } +} diff --git a/exchanges/bithumb/bithumb_test.go b/exchanges/bithumb/bithumb_test.go index 44a4c334..8d52f3d6 100644 --- a/exchanges/bithumb/bithumb_test.go +++ b/exchanges/bithumb/bithumb_test.go @@ -3,6 +3,7 @@ package bithumb import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -431,3 +432,53 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.KRW, + Description: "WITHDRAW IT ALL", + BankAccountName: "Satoshi Nakamoto", + BankAccountNumber: 12345, + BankCode: 123, + BankAddress: "123 Fake St", + BankCity: "Tarry Town", + BankCountry: "Hyrule", + BankName: "Federal Reserve Bank", + WireCurrency: symbol.KRW, + SwiftCode: "Taylor", + RequiresIntermediaryBank: false, + IsExpressWire: false, + } + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/bithumb/bithumb_wrapper.go b/exchanges/bithumb/bithumb_wrapper.go index ae83566f..b903ce03 100644 --- a/exchanges/bithumb/bithumb_wrapper.go +++ b/exchanges/bithumb/bithumb_wrapper.go @@ -1,11 +1,15 @@ package bithumb import ( + "errors" "fmt" + "math" + "strconv" "sync" "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" + "github.com/thrasher-/gocryptotrader/currency/symbol" exchange "github.com/thrasher-/gocryptotrader/exchanges" "github.com/thrasher-/gocryptotrader/exchanges/orderbook" "github.com/thrasher-/gocryptotrader/exchanges/ticker" @@ -258,13 +262,29 @@ func (b *Bithumb) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawR // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (b *Bithumb) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + if math.Mod(withdrawRequest.Amount, 1) != 0 { + return "", errors.New("KRW withdrawals do not support decimal places") + } + if withdrawRequest.Currency.String() != symbol.KRW { + return "", errors.New("Only KRW supported") + } + bankDetails := fmt.Sprintf("%v_%v", withdrawRequest.BankCode, withdrawRequest.BankName) + bankAccountNumber := strconv.FormatFloat(withdrawRequest.BankAccountNumber, 'f', -1, 64) + withdrawAmountInt := int64(withdrawRequest.Amount) + resp, err := b.RequestKRWWithdraw(bankDetails, bankAccountNumber, withdrawAmountInt) + if err != nil { + return "", err + } + if resp.Status != "0000" { + return "", errors.New(resp.Message) + } + + return resp.Message, nil } -// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a -// withdrawal is submitted +// WithdrawFiatFundsToInternationalBank is not supported as Bithumb only withdraws KRW to South Korean banks func (b *Bithumb) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bitmex/bitmex.go b/exchanges/bitmex/bitmex.go index 0a276f57..de155e74 100644 --- a/exchanges/bitmex/bitmex.go +++ b/exchanges/bitmex/bitmex.go @@ -114,7 +114,7 @@ func (b *Bitmex) SetDefaults() { b.Enabled = false b.Verbose = false b.RESTPollingDelay = 10 - b.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithAPIPermission | exchange.WithdrawCryptoWithEmail | exchange.WithdrawCryptoWith2FA + b.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithAPIPermission | exchange.WithdrawCryptoWithEmail | exchange.WithdrawCryptoWith2FA | exchange.NoFiatWithdrawals b.RequestCurrencyPairFormat.Delimiter = "" b.RequestCurrencyPairFormat.Uppercase = true b.ConfigCurrencyPairFormat.Delimiter = "" diff --git a/exchanges/bitmex/bitmex_test.go b/exchanges/bitmex/bitmex_test.go index 692c677b..bdff988b 100644 --- a/exchanges/bitmex/bitmex_test.go +++ b/exchanges/bitmex/bitmex_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" "github.com/thrasher-/gocryptotrader/exchanges" @@ -456,7 +457,8 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange b.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.WithdrawCryptoWith2FAText + " & " + exchange.WithdrawCryptoWithEmailText + expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.WithdrawCryptoWith2FAText + + " & " + exchange.WithdrawCryptoWithEmailText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := b.FormatWithdrawPermissions() // Assert @@ -604,3 +606,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/bitmex/bitmex_wrapper.go b/exchanges/bitmex/bitmex_wrapper.go index 05fe54f1..44932eb5 100644 --- a/exchanges/bitmex/bitmex_wrapper.go +++ b/exchanges/bitmex/bitmex_wrapper.go @@ -278,13 +278,13 @@ func (b *Bitmex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted func (b *Bitmex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is // submitted func (b *Bitmex) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bitstamp/bitstamp.go b/exchanges/bitstamp/bitstamp.go index e76256a6..827ebdb8 100644 --- a/exchanges/bitstamp/bitstamp.go +++ b/exchanges/bitstamp/bitstamp.go @@ -36,6 +36,7 @@ const ( bitstampAPISell = "sell" bitstampAPIMarket = "market" bitstampAPIWithdrawalRequests = "withdrawal_requests" + bitstampAPIOpenWithdrawal = "withdrawal/open" bitstampAPIBitcoinWithdrawal = "bitcoin_withdrawal" bitstampAPILTCWithdrawal = "ltc_withdrawal" bitstampAPIETHWithdrawal = "eth_withdrawal" @@ -514,6 +515,55 @@ func (b *Bitstamp) CryptoWithdrawal(amount float64, address, symbol, destTag str return resp, b.SendAuthenticatedHTTPRequest(endpoint, false, req, &resp) } +// OpenBankWithdrawal Opens a bank withdrawal request (SEPA or international) +func (b *Bitstamp) OpenBankWithdrawal(amount float64, currency, + name, iban, bic, address, postalCode, city, country, + comment, withdrawalType string) (FIATWithdrawalResponse, error) { + var req = url.Values{} + req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + req.Add("account_currency", currency) + req.Add("name", name) + req.Add("iban", iban) + req.Add("bic", bic) + req.Add("address", address) + req.Add("postal_code", postalCode) + req.Add("city", city) + req.Add("country", country) + req.Add("type", withdrawalType) + req.Add("comment", comment) + + resp := FIATWithdrawalResponse{} + return resp, b.SendAuthenticatedHTTPRequest(bitstampAPIOpenWithdrawal, true, req, &resp) +} + +// OpenInternationalBankWithdrawal Opens a bank withdrawal request (international) +func (b *Bitstamp) OpenInternationalBankWithdrawal(amount float64, currency, + name, iban, bic, address, postalCode, city, country, + bankName, bankAddress, bankPostCode, bankCity, bankCountry, internationalCurrency, + comment, withdrawalType string) (FIATWithdrawalResponse, error) { + var req = url.Values{} + req.Add("amount", strconv.FormatFloat(amount, 'f', -1, 64)) + req.Add("account_currency", currency) + req.Add("name", name) + req.Add("iban", iban) + req.Add("bic", bic) + req.Add("address", address) + req.Add("postal_code", postalCode) + req.Add("city", city) + req.Add("country", country) + req.Add("type", withdrawalType) + req.Add("comment", comment) + req.Add("currency", internationalCurrency) + req.Add("bank_name", bankName) + req.Add("bank_address", bankAddress) + req.Add("bank_postal_code", bankPostCode) + req.Add("bank_city", bankCity) + req.Add("bank_country", bankCountry) + + resp := FIATWithdrawalResponse{} + return resp, b.SendAuthenticatedHTTPRequest(bitstampAPIOpenWithdrawal, true, req, &resp) +} + // GetCryptoDepositAddress returns a depositing address by crypto // crypto - example "btc", "ltc", "eth", or "xrp" func (b *Bitstamp) GetCryptoDepositAddress(crypto string) (string, error) { diff --git a/exchanges/bitstamp/bitstamp_test.go b/exchanges/bitstamp/bitstamp_test.go index 2af8e59b..ae8505a7 100644 --- a/exchanges/bitstamp/bitstamp_test.go +++ b/exchanges/bitstamp/bitstamp_test.go @@ -16,7 +16,7 @@ import ( const ( apiKey = "" apiSecret = "" - customerID = "" + customerID = "" // This is the customer id you use to log in canManipulateRealOrders = false ) @@ -381,7 +381,6 @@ func areTestAPIKeysSet() bool { func TestSubmitOrder(t *testing.T) { b.SetDefaults() TestSetup(t) - if areTestAPIKeysSet() && !canManipulateRealOrders { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } @@ -492,3 +491,79 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.USD, + Description: "WITHDRAW IT ALL", + BankAccountName: "Satoshi Nakamoto", + BankAccountNumber: 12345, + BankAddress: "123 Fake St", + BankCity: "Tarry Town", + BankCountry: "AU", + BankName: "Federal Reserve Bank", + WireCurrency: symbol.USD, + SwiftCode: "CTBAAU2S", + RequiresIntermediaryBank: false, + IsExpressWire: false, + BankPostalCode: "2088", + IBAN: "IT60X0542811101000000123456", + } + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.USD, + Description: "WITHDRAW IT ALL", + BankAccountName: "Satoshi Nakamoto", + BankAccountNumber: 12345, + BankAddress: "123 Fake St", + BankCity: "Tarry Town", + BankCountry: "AU", + BankName: "Federal Reserve Bank", + WireCurrency: symbol.USD, + SwiftCode: "CTBAAU2S", + RequiresIntermediaryBank: false, + IsExpressWire: false, + BankPostalCode: "2088", + IBAN: "IT60X0542811101000000123456", + IntermediaryBankAccountNumber: 12345, + IntermediaryBankAddress: "123 Fake St", + IntermediaryBankCity: "Tarry Town", + IntermediaryBankCountry: "AU", + IntermediaryBankName: "Federal Reserve Bank", + IntermediaryBankPostalCode: "2088", + } + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} diff --git a/exchanges/bitstamp/bitstamp_types.go b/exchanges/bitstamp/bitstamp_types.go index 68b19b99..0b5b2c15 100644 --- a/exchanges/bitstamp/bitstamp_types.go +++ b/exchanges/bitstamp/bitstamp_types.go @@ -122,11 +122,19 @@ type WithdrawalRequests struct { TransactionID string `json:"transaction_id"` // Bitcoin withdrawals only } +// CryptoWithdrawalResponse response from a crypto withdrawal request type CryptoWithdrawalResponse struct { ID string `json:"id"` Error string `json:"error"` } +// FIATWithdrawalResponse response from a fiat withdrawal request +type FIATWithdrawalResponse struct { + ID string `json:"id"` + Status string `json:"status"` + Reason string `json:"reason"` +} + // UnconfirmedBTCTransactions holds address information about unconfirmed // transactions type UnconfirmedBTCTransactions struct { @@ -142,3 +150,9 @@ type CaptureError struct { Code interface{} `json:"code"` Error interface{} `json:"error"` } + +const ( + sepaWithdrawal string = "sepa" + internationalWithdrawal string = "international" + errStr string = "error" +) diff --git a/exchanges/bitstamp/bitstamp_wrapper.go b/exchanges/bitstamp/bitstamp_wrapper.go index cbcf9780..a3294237 100644 --- a/exchanges/bitstamp/bitstamp_wrapper.go +++ b/exchanges/bitstamp/bitstamp_wrapper.go @@ -240,13 +240,37 @@ func (b *Bitstamp) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Withdraw // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (b *Bitstamp) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + resp, err := b.OpenBankWithdrawal(withdrawRequest.Amount, withdrawRequest.Currency.String(), + withdrawRequest.BankAccountName, withdrawRequest.IBAN, withdrawRequest.SwiftCode, withdrawRequest.BankAddress, + withdrawRequest.BankPostalCode, withdrawRequest.BankCity, withdrawRequest.BankCountry, + withdrawRequest.Description, sepaWithdrawal) + if err != nil { + return "", err + } + if resp.Status == errStr { + return "", errors.New(resp.Reason) + } + + return resp.ID, nil } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (b *Bitstamp) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + resp, err := b.OpenInternationalBankWithdrawal(withdrawRequest.Amount, withdrawRequest.Currency.String(), + withdrawRequest.BankAccountName, withdrawRequest.IBAN, withdrawRequest.SwiftCode, withdrawRequest.BankAddress, + withdrawRequest.BankPostalCode, withdrawRequest.BankCity, withdrawRequest.BankCountry, + withdrawRequest.IntermediaryBankName, withdrawRequest.IntermediaryBankAddress, withdrawRequest.IntermediaryBankPostalCode, + withdrawRequest.IntermediaryBankCity, withdrawRequest.IntermediaryBankCountry, withdrawRequest.WireCurrency, + withdrawRequest.Description, internationalWithdrawal) + if err != nil { + return "", err + } + if resp.Status == errStr { + return "", errors.New(resp.Reason) + } + + return resp.ID, nil } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/bittrex/bittrex.go b/exchanges/bittrex/bittrex.go index c4d6ab67..7ef28429 100644 --- a/exchanges/bittrex/bittrex.go +++ b/exchanges/bittrex/bittrex.go @@ -68,7 +68,7 @@ func (b *Bittrex) SetDefaults() { b.Enabled = false b.Verbose = false b.RESTPollingDelay = 10 - b.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithAPIPermission + b.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithAPIPermission | exchange.NoFiatWithdrawals b.RequestCurrencyPairFormat.Delimiter = "-" b.RequestCurrencyPairFormat.Uppercase = true b.ConfigCurrencyPairFormat.Delimiter = "-" diff --git a/exchanges/bittrex/bittrex_test.go b/exchanges/bittrex/bittrex_test.go index 89eba6ea..ac0f4936 100644 --- a/exchanges/bittrex/bittrex_test.go +++ b/exchanges/bittrex/bittrex_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -315,7 +316,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange b.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := b.FormatWithdrawPermissions() // Assert @@ -448,3 +449,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/bittrex/bittrex_wrapper.go b/exchanges/bittrex/bittrex_wrapper.go index 55a78377..d9ebb42d 100644 --- a/exchanges/bittrex/bittrex_wrapper.go +++ b/exchanges/bittrex/bittrex_wrapper.go @@ -251,13 +251,13 @@ func (b *Bittrex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawR // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (b *Bittrex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (b *Bittrex) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/btcc/btcc_test.go b/exchanges/btcc/btcc_test.go index d5a1f041..7285dbd2 100644 --- a/exchanges/btcc/btcc_test.go +++ b/exchanges/btcc/btcc_test.go @@ -270,8 +270,8 @@ func TestWithdraw(t *testing.T) { } _, err := b.WithdrawCryptocurrencyFunds(withdrawCryptoRequest) - if err != common.ErrNotYetImplemented { - t.Errorf("Expected 'Not Yet Implemented', recieved %v", err) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) } } @@ -281,3 +281,35 @@ func TestModifyOrder(t *testing.T) { t.Error("Test failed - ModifyOrder() error") } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/btcc/btcc_wrapper.go b/exchanges/btcc/btcc_wrapper.go index a603ecdb..00151b8e 100644 --- a/exchanges/btcc/btcc_wrapper.go +++ b/exchanges/btcc/btcc_wrapper.go @@ -187,19 +187,19 @@ func (b *BTCC) GetDepositAddress(cryptocurrency pair.CurrencyItem) (string, erro // WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is // submitted func (b *BTCC) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (b *BTCC) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (b *BTCC) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/btcmarkets/btcmarkets_test.go b/exchanges/btcmarkets/btcmarkets_test.go index 62fd8ef1..65a4150b 100644 --- a/exchanges/btcmarkets/btcmarkets_test.go +++ b/exchanges/btcmarkets/btcmarkets_test.go @@ -4,6 +4,7 @@ import ( "net/url" "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -400,3 +401,52 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.AUD, + Description: "WITHDRAW IT ALL", + BankAccountName: "Satoshi Nakamoto", + BankAccountNumber: 12345, + BankAddress: "123 Fake St", + BankCity: "Tarry Town", + BankCountry: "Hyrule", + BankName: "Commonwealth Bank of Australia", + WireCurrency: symbol.AUD, + SwiftCode: "Taylor", + RequiresIntermediaryBank: false, + IsExpressWire: false, + } + + _, err := b.WithdrawFiatFunds(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + b.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := b.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/btcmarkets/btcmarkets_wrapper.go b/exchanges/btcmarkets/btcmarkets_wrapper.go index f4613846..49b2702b 100644 --- a/exchanges/btcmarkets/btcmarkets_wrapper.go +++ b/exchanges/btcmarkets/btcmarkets_wrapper.go @@ -8,6 +8,7 @@ import ( "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" + "github.com/thrasher-/gocryptotrader/currency/symbol" exchange "github.com/thrasher-/gocryptotrader/exchanges" "github.com/thrasher-/gocryptotrader/exchanges/orderbook" "github.com/thrasher-/gocryptotrader/exchanges/ticker" @@ -267,17 +268,16 @@ func (b *BTCMarkets) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Withdr // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (b *BTCMarkets) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - bd, err := b.GetClientBankAccounts(b.Name, withdrawRequest.Currency.Upper().String()) - if err != nil { - return "", err + if withdrawRequest.Currency != symbol.AUD { + return "", errors.New("Only AUD supported for withdrawals") } - return b.WithdrawAUD(bd.AccountName, bd.AccountNumber, bd.BankName, bd.BSBNumber, withdrawRequest.Amount) + return b.WithdrawAUD(withdrawRequest.BankAccountName, fmt.Sprintf("%v", withdrawRequest.BankAccountNumber), withdrawRequest.BankName, fmt.Sprintf("%v", withdrawRequest.BankCode), withdrawRequest.Amount) } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (b *BTCMarkets) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/coinbasepro/coinbasepro_test.go b/exchanges/coinbasepro/coinbasepro_test.go index 672d1b71..562721bc 100644 --- a/exchanges/coinbasepro/coinbasepro_test.go +++ b/exchanges/coinbasepro/coinbasepro_test.go @@ -531,3 +531,49 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + c.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.USD, + BankName: "Federal Reserve Bank", + } + + _, err := c.WithdrawFiatFunds(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + c.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.USD, + BankName: "Federal Reserve Bank", + } + + _, err := c.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} diff --git a/exchanges/coinbasepro/coinbasepro_wrapper.go b/exchanges/coinbasepro/coinbasepro_wrapper.go index 8349cbc1..8229cbf5 100644 --- a/exchanges/coinbasepro/coinbasepro_wrapper.go +++ b/exchanges/coinbasepro/coinbasepro_wrapper.go @@ -2,6 +2,7 @@ package coinbasepro import ( "errors" + "fmt" "sync" "github.com/thrasher-/gocryptotrader/common" @@ -207,13 +208,34 @@ func (c *CoinbasePro) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Withd // WithdrawFiatFunds returns a withdrawal ID when a withdrawal is // submitted func (c *CoinbasePro) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + paymentMethods, err := c.GetPayMethods() + if err != nil { + return "", err + } + + selectedWithdrawalMethod := PaymentMethod{} + for _, paymentMethod := range paymentMethods { + if withdrawRequest.BankName == paymentMethod.Name { + selectedWithdrawalMethod = paymentMethod + break + } + } + if len(selectedWithdrawalMethod.ID) <= 0 { + return "", fmt.Errorf("Could not find payment method '%v'. Check the name via the website and try again", withdrawRequest.BankName) + } + + resp, err := c.WithdrawViaPaymentMethod(withdrawRequest.Amount, withdrawRequest.Currency.String(), selectedWithdrawalMethod.ID) + if err != nil { + return "", err + } + + return resp.ID, nil } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (c *CoinbasePro) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return c.WithdrawFiatFunds(withdrawRequest) } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/coinut/coinut_test.go b/exchanges/coinut/coinut_test.go index b993695b..13183072 100644 --- a/exchanges/coinut/coinut_test.go +++ b/exchanges/coinut/coinut_test.go @@ -328,3 +328,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Expected 'Not supported', recieved %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + c.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := c.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + c.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := c.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/exchange.go b/exchanges/exchange.go index f1ec116b..ba88bb9e 100644 --- a/exchanges/exchange.go +++ b/exchanges/exchange.go @@ -100,25 +100,42 @@ type OrderCancellation struct { // WithdrawRequest used for wrapper crypto and FIAT withdraw methods type WithdrawRequest struct { - // Exchange related information + // General withdraw information Description string OneTimePassword int64 AccountID string PIN int64 TradePassword string + Amount float64 + Currency pair.CurrencyItem // Crypto related information - Currency pair.CurrencyItem Address string AddressTag string - Amount float64 FeeAmount float64 // FIAT related information - BankName string - BankAddress string - BankCity string - BankCountry string - SwiftCode string - WireCurrency string + BankAccountName string + BankAccountNumber float64 + BankName string + BankAddress string + BankCity string + BankCountry string + BankPostalCode string + SwiftCode string + IBAN string + BankCode float64 + IsExpressWire bool + // Intermediary bank information + RequiresIntermediaryBank bool + IntermediaryBankAccountNumber float64 + IntermediaryBankName string + IntermediaryBankAddress string + IntermediaryBankCity string + IntermediaryBankCountry string + IntermediaryBankPostalCode string + IntermediarySwiftCode string + IntermediaryBankCode float64 + IntermediaryIBAN string + WireCurrency string } // Definitions for each type of withdrawal method for a given exchange @@ -162,6 +179,8 @@ const ( WithdrawFiatViaWebsiteOnly uint32 = (1 << 17) WithdrawCryptoViaWebsiteOnlyText string = "WITHDRAW CRYPTO VIA WEBSITE ONLY" WithdrawFiatViaWebsiteOnlyText string = "WITHDRAW FIAT VIA WEBSITE ONLY" + NoFiatWithdrawals uint32 = (1 << 18) + NoFiatWithdrawalsText string = "NO FIAT WITHDRAWAL" UnknownWithdrawalTypeText string = "UNKNOWN" ) @@ -907,6 +926,8 @@ func (e *Base) FormatWithdrawPermissions() string { services = append(services, WithdrawCryptoViaWebsiteOnlyText) case WithdrawFiatViaWebsiteOnly: services = append(services, WithdrawFiatViaWebsiteOnlyText) + case NoFiatWithdrawals: + services = append(services, NoFiatWithdrawalsText) default: services = append(services, fmt.Sprintf("%s[1<<%v]", UnknownWithdrawalTypeText, i)) } diff --git a/exchanges/exchange_test.go b/exchanges/exchange_test.go index eb31f845..2e824de5 100644 --- a/exchanges/exchange_test.go +++ b/exchanges/exchange_test.go @@ -901,9 +901,10 @@ func TestFormatWithdrawPermissions(t *testing.T) { WithdrawFiatWithAPIPermission | WithdrawCryptoViaWebsiteOnly | WithdrawFiatViaWebsiteOnly | - 1<<18 + NoFiatWithdrawals | + 1<<19 withdrawPermissions := UAC.FormatWithdrawPermissions() - if withdrawPermissions != "AUTO WITHDRAW CRYPTO & AUTO WITHDRAW CRYPTO WITH API PERMISSION & AUTO WITHDRAW CRYPTO WITH SETUP & WITHDRAW CRYPTO WITH 2FA & WITHDRAW CRYPTO WITH SMS & WITHDRAW CRYPTO WITH EMAIL & WITHDRAW CRYPTO WITH WEBSITE APPROVAL & WITHDRAW CRYPTO WITH API PERMISSION & AUTO WITHDRAW FIAT & AUTO WITHDRAW FIAT WITH API PERMISSION & AUTO WITHDRAW FIAT WITH SETUP & WITHDRAW FIAT WITH 2FA & WITHDRAW FIAT WITH SMS & WITHDRAW FIAT WITH EMAIL & WITHDRAW FIAT WITH WEBSITE APPROVAL & WITHDRAW FIAT WITH API PERMISSION & WITHDRAW CRYPTO VIA WEBSITE ONLY & WITHDRAW FIAT VIA WEBSITE ONLY & UNKNOWN[1<<18]" { + if withdrawPermissions != "AUTO WITHDRAW CRYPTO & AUTO WITHDRAW CRYPTO WITH API PERMISSION & AUTO WITHDRAW CRYPTO WITH SETUP & WITHDRAW CRYPTO WITH 2FA & WITHDRAW CRYPTO WITH SMS & WITHDRAW CRYPTO WITH EMAIL & WITHDRAW CRYPTO WITH WEBSITE APPROVAL & WITHDRAW CRYPTO WITH API PERMISSION & AUTO WITHDRAW FIAT & AUTO WITHDRAW FIAT WITH API PERMISSION & AUTO WITHDRAW FIAT WITH SETUP & WITHDRAW FIAT WITH 2FA & WITHDRAW FIAT WITH SMS & WITHDRAW FIAT WITH EMAIL & WITHDRAW FIAT WITH WEBSITE APPROVAL & WITHDRAW FIAT WITH API PERMISSION & WITHDRAW CRYPTO VIA WEBSITE ONLY & WITHDRAW FIAT VIA WEBSITE ONLY & NO FIAT WITHDRAWAL & UNKNOWN[1<<19]" { t.Errorf("Expected: %s, Received: %s", AutoWithdrawCryptoText+" & "+AutoWithdrawCryptoWithAPIPermissionText, withdrawPermissions) } diff --git a/exchanges/exmo/exmo.go b/exchanges/exmo/exmo.go index d90079c4..e582414a 100644 --- a/exchanges/exmo/exmo.go +++ b/exchanges/exmo/exmo.go @@ -58,7 +58,7 @@ func (e *EXMO) SetDefaults() { e.Enabled = false e.Verbose = false e.RESTPollingDelay = 10 - e.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithSetup + e.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithSetup | exchange.NoFiatWithdrawals e.RequestCurrencyPairFormat.Delimiter = "_" e.RequestCurrencyPairFormat.Uppercase = true e.RequestCurrencyPairFormat.Separator = "," diff --git a/exchanges/exmo/exmo_test.go b/exchanges/exmo/exmo_test.go index be0b4ccd..b4b0d801 100644 --- a/exchanges/exmo/exmo_test.go +++ b/exchanges/exmo/exmo_test.go @@ -3,6 +3,7 @@ package exmo import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" exchange "github.com/thrasher-/gocryptotrader/exchanges" @@ -239,7 +240,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange e.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoWithSetupText + expectedResult := exchange.AutoWithdrawCryptoWithSetupText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := e.FormatWithdrawPermissions() // Assert @@ -367,3 +368,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + e.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := e.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + e.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := e.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/exmo/exmo_wrapper.go b/exchanges/exmo/exmo_wrapper.go index 436d4342..139ac703 100644 --- a/exchanges/exmo/exmo_wrapper.go +++ b/exchanges/exmo/exmo_wrapper.go @@ -264,13 +264,13 @@ func (e *EXMO) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequ // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (e *EXMO) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (e *EXMO) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/gateio/gateio.go b/exchanges/gateio/gateio.go index 1fa0bcbf..618f0330 100644 --- a/exchanges/gateio/gateio.go +++ b/exchanges/gateio/gateio.go @@ -49,7 +49,7 @@ func (g *Gateio) SetDefaults() { g.Enabled = false g.Verbose = false g.RESTPollingDelay = 10 - g.APIWithdrawPermissions = exchange.AutoWithdrawCrypto + g.APIWithdrawPermissions = exchange.AutoWithdrawCrypto | exchange.NoFiatWithdrawals g.RequestCurrencyPairFormat.Delimiter = "_" g.RequestCurrencyPairFormat.Uppercase = false g.ConfigCurrencyPairFormat.Delimiter = "_" diff --git a/exchanges/gateio/gateio_test.go b/exchanges/gateio/gateio_test.go index 401494ef..502f1380 100644 --- a/exchanges/gateio/gateio_test.go +++ b/exchanges/gateio/gateio_test.go @@ -3,6 +3,7 @@ package gateio import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -241,7 +242,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange g.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoText + expectedResult := exchange.AutoWithdrawCryptoText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := g.FormatWithdrawPermissions() // Assert @@ -388,3 +389,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + g.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := g.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + g.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := g.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/gateio/gateio_wrapper.go b/exchanges/gateio/gateio_wrapper.go index c94aa439..73d8aa14 100644 --- a/exchanges/gateio/gateio_wrapper.go +++ b/exchanges/gateio/gateio_wrapper.go @@ -275,13 +275,13 @@ func (g *Gateio) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (g *Gateio) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (g *Gateio) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/gemini/gemini_test.go b/exchanges/gemini/gemini_test.go index 18dbbf85..891251bb 100644 --- a/exchanges/gemini/gemini_test.go +++ b/exchanges/gemini/gemini_test.go @@ -4,6 +4,7 @@ import ( "net/url" "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -326,6 +327,9 @@ func TestGetFee(t *testing.T) { } func TestFormatWithdrawPermissions(t *testing.T) { + TestAddSession(t) + TestSetDefaults(t) + TestSetup(t) // Arrange expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.AutoWithdrawCryptoWithSetupText + " & " + exchange.WithdrawFiatViaWebsiteOnlyText // Act @@ -464,3 +468,37 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + TestAddSession(t) + TestSetDefaults(t) + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := Session[1].WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + TestAddSession(t) + TestSetDefaults(t) + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := Session[1].WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/gemini/gemini_wrapper.go b/exchanges/gemini/gemini_wrapper.go index 5fe4663d..66d5f2ad 100644 --- a/exchanges/gemini/gemini_wrapper.go +++ b/exchanges/gemini/gemini_wrapper.go @@ -207,13 +207,13 @@ func (g *Gemini) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (g *Gemini) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (g *Gemini) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/hitbtc/hitbtc.go b/exchanges/hitbtc/hitbtc.go index 92ab0767..887efd7d 100644 --- a/exchanges/hitbtc/hitbtc.go +++ b/exchanges/hitbtc/hitbtc.go @@ -60,7 +60,7 @@ func (h *HitBTC) SetDefaults() { h.Fee = 0 h.Verbose = false h.RESTPollingDelay = 10 - h.APIWithdrawPermissions = exchange.AutoWithdrawCrypto + h.APIWithdrawPermissions = exchange.AutoWithdrawCrypto | exchange.NoFiatWithdrawals h.RequestCurrencyPairFormat.Delimiter = "" h.RequestCurrencyPairFormat.Uppercase = true h.ConfigCurrencyPairFormat.Delimiter = "-" diff --git a/exchanges/hitbtc/hitbtc_test.go b/exchanges/hitbtc/hitbtc_test.go index 82cc8a27..fc207142 100644 --- a/exchanges/hitbtc/hitbtc_test.go +++ b/exchanges/hitbtc/hitbtc_test.go @@ -3,6 +3,7 @@ package hitbtc import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -166,7 +167,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange h.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoText + expectedResult := exchange.AutoWithdrawCryptoText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := h.FormatWithdrawPermissions() // Assert @@ -299,3 +300,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + h.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := h.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + h.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/hitbtc/hitbtc_wrapper.go b/exchanges/hitbtc/hitbtc_wrapper.go index 32e29964..78158a1a 100644 --- a/exchanges/hitbtc/hitbtc_wrapper.go +++ b/exchanges/hitbtc/hitbtc_wrapper.go @@ -230,13 +230,13 @@ func (h *HitBTC) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (h *HitBTC) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (h *HitBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/huobi/huobi.go b/exchanges/huobi/huobi.go index 13d60f44..c9132248 100644 --- a/exchanges/huobi/huobi.go +++ b/exchanges/huobi/huobi.go @@ -77,7 +77,7 @@ func (h *HUOBI) SetDefaults() { h.Fee = 0 h.Verbose = false h.RESTPollingDelay = 10 - h.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithSetup + h.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithSetup | exchange.NoFiatWithdrawals h.RequestCurrencyPairFormat.Delimiter = "" h.RequestCurrencyPairFormat.Uppercase = false h.ConfigCurrencyPairFormat.Delimiter = "-" diff --git a/exchanges/huobi/huobi_test.go b/exchanges/huobi/huobi_test.go index 3d32073e..03a32a03 100644 --- a/exchanges/huobi/huobi_test.go +++ b/exchanges/huobi/huobi_test.go @@ -387,7 +387,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange h.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoWithSetupText + expectedResult := exchange.AutoWithdrawCryptoWithSetupText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := h.FormatWithdrawPermissions() // Assert @@ -542,3 +542,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + h.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := h.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + h.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/huobi/huobi_wrapper.go b/exchanges/huobi/huobi_wrapper.go index 36940d79..06df2786 100644 --- a/exchanges/huobi/huobi_wrapper.go +++ b/exchanges/huobi/huobi_wrapper.go @@ -344,13 +344,13 @@ func (h *HUOBI) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawReq // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (h *HUOBI) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (h *HUOBI) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/huobihadax/huobihadax.go b/exchanges/huobihadax/huobihadax.go index b887cbec..94e6f01b 100644 --- a/exchanges/huobihadax/huobihadax.go +++ b/exchanges/huobihadax/huobihadax.go @@ -69,7 +69,7 @@ func (h *HUOBIHADAX) SetDefaults() { h.Fee = 0 h.Verbose = false h.RESTPollingDelay = 10 - h.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithSetup + h.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithSetup | exchange.NoFiatWithdrawals h.RequestCurrencyPairFormat.Delimiter = "" h.RequestCurrencyPairFormat.Uppercase = false h.ConfigCurrencyPairFormat.Delimiter = "-" diff --git a/exchanges/huobihadax/huobihadax_test.go b/exchanges/huobihadax/huobihadax_test.go index 5956c5a5..d47d1abb 100644 --- a/exchanges/huobihadax/huobihadax_test.go +++ b/exchanges/huobihadax/huobihadax_test.go @@ -5,6 +5,7 @@ import ( "strconv" "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -366,7 +367,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange h.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoWithSetupText + expectedResult := exchange.AutoWithdrawCryptoWithSetupText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := h.FormatWithdrawPermissions() // Assert @@ -525,3 +526,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + h.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := h.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + h.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := h.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/huobihadax/huobihadax_wrapper.go b/exchanges/huobihadax/huobihadax_wrapper.go index c38dbda3..12f65538 100644 --- a/exchanges/huobihadax/huobihadax_wrapper.go +++ b/exchanges/huobihadax/huobihadax_wrapper.go @@ -309,13 +309,13 @@ func (h *HUOBIHADAX) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Withdr // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (h *HUOBIHADAX) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (h *HUOBIHADAX) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/itbit/itbit_test.go b/exchanges/itbit/itbit_test.go index 90f96a2f..b128677c 100644 --- a/exchanges/itbit/itbit_test.go +++ b/exchanges/itbit/itbit_test.go @@ -374,3 +374,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Expected 'Not supported', recieved %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + i.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := i.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + i.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := i.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/kraken/kraken_test.go b/exchanges/kraken/kraken_test.go index 9e6ec5cb..ec2821c0 100644 --- a/exchanges/kraken/kraken_test.go +++ b/exchanges/kraken/kraken_test.go @@ -469,3 +469,53 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + k.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.EUR, + Address: "", + Description: "donation", + TradePassword: "someBank", + } + + _, err := k.WithdrawFiatFunds(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + k.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{ + Amount: 100, + Currency: symbol.EUR, + Address: "", + Description: "donation", + TradePassword: "someBank", + } + + _, err := k.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if !areTestAPIKeysSet() && err == nil { + t.Errorf("Expecting an error when no keys are set: %v", err) + } + if areTestAPIKeysSet() && err != nil { + t.Errorf("Withdraw failed to be placed: %v", err) + } +} diff --git a/exchanges/kraken/kraken_wrapper.go b/exchanges/kraken/kraken_wrapper.go index f9885bb6..91511a5b 100644 --- a/exchanges/kraken/kraken_wrapper.go +++ b/exchanges/kraken/kraken_wrapper.go @@ -249,13 +249,13 @@ func (k *Kraken) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (k *Kraken) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return k.WithdrawCryptocurrencyFunds(withdrawRequest) } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (k *Kraken) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return k.WithdrawCryptocurrencyFunds(withdrawRequest) } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/lakebtc/lakebtc_test.go b/exchanges/lakebtc/lakebtc_test.go index e04d6378..989542a5 100644 --- a/exchanges/lakebtc/lakebtc_test.go +++ b/exchanges/lakebtc/lakebtc_test.go @@ -3,6 +3,7 @@ package lakebtc import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -361,3 +362,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + l.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := l.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + l.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := l.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/lakebtc/lakebtc_wrapper.go b/exchanges/lakebtc/lakebtc_wrapper.go index e12944f0..c1b13e89 100644 --- a/exchanges/lakebtc/lakebtc_wrapper.go +++ b/exchanges/lakebtc/lakebtc_wrapper.go @@ -223,13 +223,13 @@ func (l *LakeBTC) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawR // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (l *LakeBTC) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (l *LakeBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/liqui/liqui.go b/exchanges/liqui/liqui.go index cf727d5d..8ef70965 100644 --- a/exchanges/liqui/liqui.go +++ b/exchanges/liqui/liqui.go @@ -52,7 +52,7 @@ func (l *Liqui) SetDefaults() { l.Verbose = false l.RESTPollingDelay = 10 l.Ticker = make(map[string]Ticker) - l.APIWithdrawPermissions = exchange.NoAPIWithdrawalMethods + l.APIWithdrawPermissions = exchange.WithdrawCryptoWithAPIPermission | exchange.NoFiatWithdrawals l.RequestCurrencyPairFormat.Delimiter = "_" l.RequestCurrencyPairFormat.Uppercase = false l.RequestCurrencyPairFormat.Separator = "-" diff --git a/exchanges/liqui/liqui_test.go b/exchanges/liqui/liqui_test.go index 3c62866f..9dc2a278 100644 --- a/exchanges/liqui/liqui_test.go +++ b/exchanges/liqui/liqui_test.go @@ -4,6 +4,7 @@ import ( "net/url" "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -224,7 +225,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange l.SetDefaults() - expectedResult := exchange.NoAPIWithdrawalMethodsText + expectedResult := exchange.WithdrawCryptoWithAPIPermissionText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := l.FormatWithdrawPermissions() // Assert @@ -352,3 +353,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + l.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := l.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + l.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := l.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/localbitcoins/localbitcoins.go b/exchanges/localbitcoins/localbitcoins.go index 6a7808e1..1e6cf32b 100644 --- a/exchanges/localbitcoins/localbitcoins.go +++ b/exchanges/localbitcoins/localbitcoins.go @@ -117,7 +117,7 @@ func (l *LocalBitcoins) SetDefaults() { l.Verbose = false l.Verbose = false l.RESTPollingDelay = 10 - l.APIWithdrawPermissions = exchange.WithdrawCryptoViaWebsiteOnly + l.APIWithdrawPermissions = exchange.AutoWithdrawCrypto | exchange.WithdrawFiatViaWebsiteOnly l.RequestCurrencyPairFormat.Delimiter = "" l.RequestCurrencyPairFormat.Uppercase = true l.ConfigCurrencyPairFormat.Delimiter = "" diff --git a/exchanges/localbitcoins/localbitcoins_test.go b/exchanges/localbitcoins/localbitcoins_test.go index 4246cd6d..083dac6f 100644 --- a/exchanges/localbitcoins/localbitcoins_test.go +++ b/exchanges/localbitcoins/localbitcoins_test.go @@ -3,6 +3,7 @@ package localbitcoins import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -189,7 +190,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange l.SetDefaults() - expectedResult := exchange.WithdrawCryptoViaWebsiteOnlyText + expectedResult := exchange.AutoWithdrawCryptoText + " & " + exchange.WithdrawFiatViaWebsiteOnlyText // Act withdrawPermissions := l.FormatWithdrawPermissions() // Assert @@ -322,3 +323,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + l.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := l.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + l.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := l.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/localbitcoins/localbitcoins_wrapper.go b/exchanges/localbitcoins/localbitcoins_wrapper.go index 3a6054a7..6927ee1f 100644 --- a/exchanges/localbitcoins/localbitcoins_wrapper.go +++ b/exchanges/localbitcoins/localbitcoins_wrapper.go @@ -260,13 +260,13 @@ func (l *LocalBitcoins) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Wit // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (l *LocalBitcoins) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (l *LocalBitcoins) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/okcoin/okcoin_test.go b/exchanges/okcoin/okcoin_test.go index 28f384f5..14e8f2de 100644 --- a/exchanges/okcoin/okcoin_test.go +++ b/exchanges/okcoin/okcoin_test.go @@ -3,6 +3,7 @@ package okcoin import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -272,3 +273,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + o.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := o.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + o.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := o.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/okcoin/okcoin_wrapper.go b/exchanges/okcoin/okcoin_wrapper.go index 33171e0b..82cf494f 100644 --- a/exchanges/okcoin/okcoin_wrapper.go +++ b/exchanges/okcoin/okcoin_wrapper.go @@ -299,13 +299,13 @@ func (o *OKCoin) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRe // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (o *OKCoin) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (o *OKCoin) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/okex/okex.go b/exchanges/okex/okex.go index 03d002da..091ac613 100644 --- a/exchanges/okex/okex.go +++ b/exchanges/okex/okex.go @@ -106,7 +106,7 @@ func (o *OKEX) SetDefaults() { o.Enabled = false o.Verbose = false o.RESTPollingDelay = 10 - o.APIWithdrawPermissions = exchange.AutoWithdrawCrypto + o.APIWithdrawPermissions = exchange.AutoWithdrawCrypto | exchange.NoFiatWithdrawals o.RequestCurrencyPairFormat.Delimiter = "_" o.RequestCurrencyPairFormat.Uppercase = false o.ConfigCurrencyPairFormat.Delimiter = "_" diff --git a/exchanges/okex/okex_test.go b/exchanges/okex/okex_test.go index 129d91b1..adf41e03 100644 --- a/exchanges/okex/okex_test.go +++ b/exchanges/okex/okex_test.go @@ -3,6 +3,7 @@ package okex import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -388,7 +389,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange o.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoText + expectedResult := exchange.AutoWithdrawCryptoText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := o.FormatWithdrawPermissions() // Assert @@ -537,3 +538,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + o.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := o.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + o.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := o.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/okex/okex_wrapper.go b/exchanges/okex/okex_wrapper.go index e203cf26..692d184c 100644 --- a/exchanges/okex/okex_wrapper.go +++ b/exchanges/okex/okex_wrapper.go @@ -297,13 +297,13 @@ func (o *OKEX) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawRequ // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (o *OKEX) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (o *OKEX) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/poloniex/poloniex.go b/exchanges/poloniex/poloniex.go index 32e43e9a..12686943 100644 --- a/exchanges/poloniex/poloniex.go +++ b/exchanges/poloniex/poloniex.go @@ -66,7 +66,7 @@ func (p *Poloniex) SetDefaults() { p.Fee = 0 p.Verbose = false p.RESTPollingDelay = 10 - p.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithAPIPermission + p.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithAPIPermission | exchange.NoFiatWithdrawals p.RequestCurrencyPairFormat.Delimiter = "_" p.RequestCurrencyPairFormat.Uppercase = true p.ConfigCurrencyPairFormat.Delimiter = "_" diff --git a/exchanges/poloniex/poloniex_test.go b/exchanges/poloniex/poloniex_test.go index fc7f92ea..20c9258c 100644 --- a/exchanges/poloniex/poloniex_test.go +++ b/exchanges/poloniex/poloniex_test.go @@ -3,6 +3,7 @@ package poloniex import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -184,7 +185,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange p.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := p.FormatWithdrawPermissions() // Assert @@ -317,3 +318,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + p.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := p.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + p.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := p.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/poloniex/poloniex_wrapper.go b/exchanges/poloniex/poloniex_wrapper.go index c3e9680a..815a3d39 100644 --- a/exchanges/poloniex/poloniex_wrapper.go +++ b/exchanges/poloniex/poloniex_wrapper.go @@ -249,13 +249,13 @@ func (p *Poloniex) WithdrawCryptocurrencyFunds(withdrawRequest exchange.Withdraw // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (p *Poloniex) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (p *Poloniex) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/wex/wex.go b/exchanges/wex/wex.go index 26c323a5..7701ddc9 100644 --- a/exchanges/wex/wex.go +++ b/exchanges/wex/wex.go @@ -56,7 +56,7 @@ func (w *WEX) SetDefaults() { w.Verbose = false w.RESTPollingDelay = 10 w.Ticker = make(map[string]Ticker) - w.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithAPIPermission + w.APIWithdrawPermissions = exchange.AutoWithdrawCryptoWithAPIPermission | exchange.NoFiatWithdrawals w.RequestCurrencyPairFormat.Delimiter = "_" w.RequestCurrencyPairFormat.Uppercase = false w.RequestCurrencyPairFormat.Separator = "-" diff --git a/exchanges/wex/wex_test.go b/exchanges/wex/wex_test.go index 4726b90c..6bf48323 100644 --- a/exchanges/wex/wex_test.go +++ b/exchanges/wex/wex_test.go @@ -3,6 +3,7 @@ package wex import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -314,7 +315,7 @@ func TestFormatWithdrawPermissions(t *testing.T) { } // Arrange w.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + expectedResult := exchange.AutoWithdrawCryptoWithAPIPermissionText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := w.FormatWithdrawPermissions() // Assert @@ -456,3 +457,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + w.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := w.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + w.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := w.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/wex/wex_wrapper.go b/exchanges/wex/wex_wrapper.go index e5da7acf..62290143 100644 --- a/exchanges/wex/wex_wrapper.go +++ b/exchanges/wex/wex_wrapper.go @@ -246,13 +246,13 @@ func (w *WEX) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawReque // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (w *WEX) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (w *WEX) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/yobit/yobit_test.go b/exchanges/yobit/yobit_test.go index 67b46b7c..b9687fa3 100644 --- a/exchanges/yobit/yobit_test.go +++ b/exchanges/yobit/yobit_test.go @@ -3,6 +3,7 @@ package yobit import ( "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -436,3 +437,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + y.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := y.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + y.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := y.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/yobit/yobit_wrapper.go b/exchanges/yobit/yobit_wrapper.go index fc023275..529f14bb 100644 --- a/exchanges/yobit/yobit_wrapper.go +++ b/exchanges/yobit/yobit_wrapper.go @@ -234,13 +234,13 @@ func (y *Yobit) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawReq // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (y *Yobit) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (y *Yobit) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket diff --git a/exchanges/zb/zb.go b/exchanges/zb/zb.go index a7ca43e1..133d5094 100644 --- a/exchanges/zb/zb.go +++ b/exchanges/zb/zb.go @@ -51,7 +51,7 @@ func (z *ZB) SetDefaults() { z.Fee = 0 z.Verbose = false z.RESTPollingDelay = 10 - z.APIWithdrawPermissions = exchange.AutoWithdrawCrypto + z.APIWithdrawPermissions = exchange.AutoWithdrawCrypto | exchange.NoFiatWithdrawals z.RequestCurrencyPairFormat.Delimiter = "_" z.RequestCurrencyPairFormat.Uppercase = false z.ConfigCurrencyPairFormat.Delimiter = "_" diff --git a/exchanges/zb/zb_test.go b/exchanges/zb/zb_test.go index 7635af07..6b36e562 100644 --- a/exchanges/zb/zb_test.go +++ b/exchanges/zb/zb_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/currency/pair" "github.com/thrasher-/gocryptotrader/currency/symbol" @@ -221,7 +222,7 @@ func TestGetFee(t *testing.T) { func TestFormatWithdrawPermissions(t *testing.T) { // Arrange z.SetDefaults() - expectedResult := exchange.AutoWithdrawCryptoText + expectedResult := exchange.AutoWithdrawCryptoText + " & " + exchange.NoFiatWithdrawalsText // Act withdrawPermissions := z.FormatWithdrawPermissions() // Assert @@ -368,3 +369,35 @@ func TestWithdraw(t *testing.T) { t.Errorf("Withdraw failed to be placed: %v", err) } } + +func TestWithdrawFiat(t *testing.T) { + z.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := z.WithdrawFiatFunds(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} + +func TestWithdrawInternationalBank(t *testing.T) { + z.SetDefaults() + TestSetup(t) + + if areTestAPIKeysSet() && !canManipulateRealOrders { + t.Skip("API keys set, canManipulateRealOrders false, skipping test") + } + + var withdrawFiatRequest = exchange.WithdrawRequest{} + + _, err := z.WithdrawFiatFundsToInternationalBank(withdrawFiatRequest) + if err != common.ErrFunctionNotSupported { + t.Errorf("Expected '%v', recieved: '%v'", common.ErrFunctionNotSupported, err) + } +} diff --git a/exchanges/zb/zb_wrapper.go b/exchanges/zb/zb_wrapper.go index ff9548fb..a5f98c55 100644 --- a/exchanges/zb/zb_wrapper.go +++ b/exchanges/zb/zb_wrapper.go @@ -256,13 +256,13 @@ func (z *ZB) WithdrawCryptocurrencyFunds(withdrawRequest exchange.WithdrawReques // WithdrawFiatFunds returns a withdrawal ID when a // withdrawal is submitted func (z *ZB) WithdrawFiatFunds(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a // withdrawal is submitted func (z *ZB) WithdrawFiatFundsToInternationalBank(withdrawRequest exchange.WithdrawRequest) (string, error) { - return "", common.ErrNotYetImplemented + return "", common.ErrFunctionNotSupported } // GetWebsocket returns a pointer to the exchange websocket