Withdraw additional functionality (validation/submission/tracking) (#409)

* reworked request struct and exchange response started work on validation system

* removed import cycle until work around

* Added intial withdraw support via CLI added

* Added Crypto command to gctcli

* moved var declartion to single line

* Test updates for binance and anx

* All exchange tests have been updated test coverage added to validate

* First pass at adding withdrawl select from database

* started adding basic lru cache system

* Added basic LRU cache including Add Get Remove Contains ContainsOrAdd Clear

* wording changes on comments

* removed exported var's in strut as they are not required

* Added README

* README updates

* corrected ID on commands

* rm line :D

* merged in origin/cache

* linter fixes (gofmt)

* Added basic cache lookup to events

* swapped to mutex over rwmutex updated comments

* unexported getNewest & getOldest

* unexported getNewest & getOldest

* Updated comments and cited references in source

* updated comments

* WIP

* Migrated exchange WithdrawFiat wrapper to new struct response

* Migrated exchange WithdrawFiat wrapper to new struct response

* started work on bank management

* Added exchange level banking details back with migration to banking package

* Removed broken tests for now

* Added validation to bank accounts

* removed duplicate bank details from withdraw struct

* Test coverage increased

* gofmt

* merged upstream/master with clean up

* First pass at adding command line linking to gctcli

* added validation for crypto address, added gctcli support to retreive previous withdrawal requests

* general cleanup

* general cleanup

* reordered imports

* Increased test coverage moved to database sublogger

* Pass incorrect currency no longer return error from c.CheckBankAccountConfig

* remove TestMain() for now as other tests in this package will need to be reworked

* Happy little race car

* Reverted to upstream tests

* Added test covarege for validation method, corrected response on cli protobuf

* query clean up and removal of duplicated code

* cleaned up queries into singlem ethod increased test coverage

* Migrated international fund withdraw to new exchange response and added cache size override

* Migrated international fund withdraw to new exchange response and added cache size override

* Extended gctcli commands

* lowered default cache to 25

* small code clean up

* added get by date method

* add returned error

* cli commands cleaing return error on nil results to fix out of bounds

* merged write & read helpers into one for test coverage and increased engine/withdraw test coverage

* gofmt

* Added test coverage for valid ID

* removed unused param

* converted to use timestamp package from protobuf

* gofmt

* use built in RFC3339 timestamp

* remove setting of CreatedAt & UpdatedAt and allow ORm to take care of it

* also use ptype on byid

* code flow improvements

* remove inverse conditional check and linters run

* removed test data

* removed comment

* removed comment

* also write failures to database for auditing

* converted to use default time for start & end

* Default to time.Now() minus 30 days

* Default to time.Now() minus 30 days

* small code clean up

* fixed missing semicolon on migrations, code clean up

* updated sqlite migrations

* Added additonal check for exchange level bank account if global is not found

* case sensativity fix for currency names

* use correct compare

* test coverage fixed

* removed space

* return pointer to banking.Account

* return pointer to banking.Account

* added else check back to validate()

* Added empty string as default to migration over NULL due to retrivial of data
This commit is contained in:
Andrew
2020-02-26 15:45:13 +11:00
committed by GitHub
parent def3cdf226
commit b26ec86d43
122 changed files with 18066 additions and 2029 deletions

View File

@@ -11,7 +11,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
const (
@@ -562,8 +562,7 @@ func TestModifyOrder(t *testing.T) {
func TestWithdraw(t *testing.T) {
t.Parallel()
var withdrawCryptoRequest = withdraw.CryptoRequest{}
_, err := a.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
_, err := a.WithdrawCryptocurrencyFunds(&withdraw.Request{})
if err != common.ErrNotYetImplemented {
t.Errorf("Expected 'Not implemented', received %v", err)
}
@@ -575,8 +574,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
_, err := a.WithdrawFiatFunds(&withdrawFiatRequest)
_, err := a.WithdrawFiatFunds(&withdraw.Request{})
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}
@@ -588,8 +586,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
_, err := a.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
_, err := a.WithdrawFiatFundsToInternationalBank(&withdraw.Request{})
if err != common.ErrNotYetImplemented {
t.Errorf("Expected '%v', received: '%v'", common.ErrNotYetImplemented, err)
}

View File

@@ -17,7 +17,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config for Alphapoint
@@ -299,18 +299,18 @@ func (a *Alphapoint) GetDepositAddress(cryptocurrency currency.Code, _ string) (
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (a *Alphapoint) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return "", common.ErrNotYetImplemented
func (a *Alphapoint) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrNotYetImplemented
}
// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted
func (a *Alphapoint) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrNotYetImplemented
func (a *Alphapoint) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrNotYetImplemented
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is
// submitted
func (a *Alphapoint) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
func (a *Alphapoint) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (string, error) {
return "", common.ErrNotYetImplemented
}

View File

@@ -9,7 +9,7 @@ import (
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply your own keys here for due diligence testing
@@ -463,13 +463,13 @@ func TestWithdraw(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: 0,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: 0,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
_, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
@@ -486,8 +486,7 @@ func TestWithdraw(t *testing.T) {
func TestWithdrawFiat(t *testing.T) {
t.Parallel()
var withdrawFiatRequest withdraw.FiatRequest
_, err := b.WithdrawFiatFunds(&withdrawFiatRequest)
_, err := b.WithdrawFiatFunds(&withdraw.Request{})
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}
@@ -496,8 +495,7 @@ func TestWithdrawFiat(t *testing.T) {
func TestWithdrawInternationalBank(t *testing.T) {
t.Parallel()
var withdrawFiatRequest withdraw.FiatRequest
_, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
_, err := b.WithdrawFiatFundsToInternationalBank(&withdraw.Request{})
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
}

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -511,24 +511,30 @@ func (b *Binance) GetDepositAddress(cryptocurrency currency.Code, _ string) (str
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *Binance) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
func (b *Binance) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
amountStr := strconv.FormatFloat(withdrawRequest.Amount, 'f', -1, 64)
return b.WithdrawCrypto(withdrawRequest.Currency.String(),
withdrawRequest.Address,
withdrawRequest.AddressTag,
v, err := b.WithdrawCrypto(withdrawRequest.Currency.String(),
withdrawRequest.Crypto.Address,
withdrawRequest.Crypto.AddressTag,
withdrawRequest.Description, amountStr)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: v,
}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (b *Binance) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *Binance) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (b *Binance) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *Binance) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -17,8 +17,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
const (
@@ -671,32 +671,32 @@ func (b *Bitfinex) WithdrawCryptocurrency(wallet, address, paymentID string, amo
}
// WithdrawFIAT Sends an authenticated request to withdraw FIAT currency
func (b *Bitfinex) WithdrawFIAT(withdrawalType, walletType string, withdrawRequest *withdraw.FiatRequest) (Withdrawal, error) {
func (b *Bitfinex) WithdrawFIAT(withdrawalType, walletType string, withdrawRequest *withdraw.Request) (Withdrawal, error) {
var response []Withdrawal
req := make(map[string]interface{})
req["withdraw_type"] = withdrawalType
req["walletselected"] = walletType
req["amount"] = strconv.FormatFloat(withdrawRequest.Amount, 'f', -1, 64)
req["account_name"] = withdrawRequest.BankAccountName
req["account_number"] = withdrawRequest.BankAccountNumber
req["bank_name"] = withdrawRequest.BankName
req["bank_address"] = withdrawRequest.BankAddress
req["bank_city"] = withdrawRequest.BankCity
req["bank_country"] = withdrawRequest.BankCountry
req["expressWire"] = withdrawRequest.IsExpressWire
req["swift"] = withdrawRequest.SwiftCode
req["account_name"] = withdrawRequest.Fiat.Bank.AccountName
req["account_number"] = withdrawRequest.Fiat.Bank.AccountNumber
req["bank_name"] = withdrawRequest.Fiat.Bank.BankName
req["bank_address"] = withdrawRequest.Fiat.Bank.BankAddress
req["bank_city"] = withdrawRequest.Fiat.Bank.BankPostalCity
req["bank_country"] = withdrawRequest.Fiat.Bank.BankCountry
req["expressWire"] = withdrawRequest.Fiat.IsExpressWire
req["swift"] = withdrawRequest.Fiat.Bank.SWIFTCode
req["detail_payment"] = withdrawRequest.Description
req["currency"] = withdrawRequest.WireCurrency
req["account_address"] = withdrawRequest.BankAddress
req["currency"] = withdrawRequest.Currency
req["account_address"] = withdrawRequest.Fiat.Bank.BankAddress
if withdrawRequest.RequiresIntermediaryBank {
req["intermediary_bank_name"] = withdrawRequest.IntermediaryBankName
req["intermediary_bank_address"] = withdrawRequest.IntermediaryBankAddress
req["intermediary_bank_city"] = withdrawRequest.IntermediaryBankCity
req["intermediary_bank_country"] = withdrawRequest.IntermediaryBankCountry
req["intermediary_bank_account"] = strconv.FormatFloat(withdrawRequest.IntermediaryBankAccountNumber, 'f', -1, 64)
req["intermediary_bank_swift"] = withdrawRequest.IntermediarySwiftCode
if withdrawRequest.Fiat.RequiresIntermediaryBank {
req["intermediary_bank_name"] = withdrawRequest.Fiat.IntermediaryBankName
req["intermediary_bank_address"] = withdrawRequest.Fiat.IntermediaryBankAddress
req["intermediary_bank_city"] = withdrawRequest.Fiat.IntermediaryBankCity
req["intermediary_bank_country"] = withdrawRequest.Fiat.IntermediaryBankCountry
req["intermediary_bank_account"] = strconv.FormatFloat(withdrawRequest.Fiat.IntermediaryBankAccountNumber, 'f', -1, 64)
req["intermediary_bank_swift"] = withdrawRequest.Fiat.IntermediarySwiftCode
}
err := b.SendAuthenticatedHTTPRequest(http.MethodPost,

View File

@@ -16,7 +16,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply your own keys here to do better tests
@@ -273,55 +274,6 @@ func TestWalletTransfer(t *testing.T) {
}
}
func TestWithdrawCryptocurrency(t *testing.T) {
if !b.ValidateAPICredentials() {
t.SkipNow()
}
t.Parallel()
_, err := b.WithdrawCryptocurrency("bad",
"rEb8TK3gBgk5auZkwc6sHnwrGVJH8DuaLh",
"102257461",
1,
currency.XRP)
if err == nil {
t.Error("error cannot be nil")
}
}
func TestWithdrawFiat(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: 1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
},
BankAccountName: "Satoshi Nakamoto",
BankAccountNumber: "12345",
BankAddress: "123 Fake St",
BankCity: "Tarry Town",
BankCountry: "Hyrule",
BankName: "Federal Reserve Bank",
WireCurrency: currency.USD.String(),
SwiftCode: "Taylor",
RequiresIntermediaryBank: false,
IsExpressWire: false,
}
_, err := b.WithdrawFIAT("wire", "exchange", &withdrawFiatRequest)
if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
if areTestAPIKeysSet() && err != nil {
t.Errorf("Withdraw failed to be placed: %v", err)
}
}
func TestNewOrder(t *testing.T) {
if !b.ValidateAPICredentials() {
t.SkipNow()
@@ -862,13 +814,13 @@ func TestWithdraw(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
_, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
@@ -880,34 +832,53 @@ func TestWithdraw(t *testing.T) {
}
}
func TestWithdrawFiat(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.Request{
Amount: -1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
Fiat: &withdraw.FiatRequest{
Bank: &banking.Account{},
WireCurrency: currency.USD.String(),
},
}
_, err := b.WithdrawFiatFunds(&withdrawFiatRequest)
if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
if areTestAPIKeysSet() && err != nil {
t.Errorf("Withdraw failed to be placed: %v", err)
}
}
func TestWithdrawInternationalBank(t *testing.T) {
t.Parallel()
if areTestAPIKeysSet() && !canManipulateRealOrders {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
var withdrawFiatRequest = withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Fiat: &withdraw.FiatRequest{
Bank: &banking.Account{},
WireCurrency: currency.USD.String(),
RequiresIntermediaryBank: true,
IsExpressWire: false,
IntermediaryBankAccountNumber: 12345,
IntermediaryBankAddress: "123 Fake St",
IntermediaryBankCity: "Tarry Town",
IntermediaryBankCountry: "Hyrule",
IntermediaryBankName: "Federal Reserve Bank",
IntermediarySwiftCode: "Taylor",
},
BankAccountName: "Satoshi Nakamoto",
BankAccountNumber: "12345",
BankAddress: "123 Fake St",
BankCity: "Tarry Town",
BankCountry: "Hyrule",
BankName: "Federal Reserve Bank",
WireCurrency: currency.USD.String(),
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)

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -537,26 +537,29 @@ func (b *Bitfinex) GetDepositAddress(c currency.Code, accountID string) (string,
}
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted
func (b *Bitfinex) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
func (b *Bitfinex) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
// 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.WithdrawCryptocurrency(walletType,
withdrawRequest.Address,
withdrawRequest.Crypto.Address,
withdrawRequest.Description,
withdrawRequest.Amount,
withdrawRequest.Currency)
if err != nil {
return "", err
return nil, err
}
return strconv.FormatInt(resp.WithdrawalID, 10), err
return &withdraw.ExchangeResponse{
ID: strconv.FormatInt(resp.WithdrawalID, 10),
Status: resp.Status,
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is submitted
// Returns comma delimited withdrawal IDs
func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
withdrawalType := "wire"
// Bitfinex has support for three types, exchange, margin and deposit
// As this is for trading, I've made the wrapper default 'exchange'
@@ -564,16 +567,26 @@ func (b *Bitfinex) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (str
walletType := "exchange"
resp, err := b.WithdrawFIAT(withdrawalType, walletType, withdrawRequest)
if err != nil {
return "", err
return nil, err
}
return strconv.FormatInt(resp.WithdrawalID, 10), nil
return &withdraw.ExchangeResponse{
ID: strconv.FormatInt(resp.WithdrawalID, 10),
Status: resp.Status,
}, err
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is submitted
// Returns comma delimited withdrawal IDs
func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return b.WithdrawFiatFunds(withdrawRequest)
func (b *Bitfinex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := b.WithdrawFiatFunds(withdrawRequest)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: v.ID,
Status: v.Status,
}, nil
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -12,7 +12,7 @@ import (
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply your own keys here for due diligence testing
@@ -368,13 +368,13 @@ func TestWithdraw(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
_, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
@@ -400,7 +400,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := b.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrNotYetImplemented {
@@ -414,7 +414,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrNotYetImplemented {

View File

@@ -16,8 +16,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -319,20 +319,20 @@ func (b *Bitflyer) GetDepositAddress(cryptocurrency currency.Code, accountID str
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *Bitflyer) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return "", common.ErrNotYetImplemented
func (b *Bitflyer) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrNotYetImplemented
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bitflyer) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrNotYetImplemented
func (b *Bitflyer) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrNotYetImplemented
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bitflyer) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrNotYetImplemented
func (b *Bitflyer) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrNotYetImplemented
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -11,7 +11,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply your own keys here for due diligence testing
@@ -450,13 +451,13 @@ func TestWithdraw(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
_, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
@@ -474,23 +475,16 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
var withdrawFiatRequest = withdraw.Request{
Fiat: &withdraw.FiatRequest{
Bank: &banking.Account{},
WireCurrency: currency.KRW.String(),
RequiresIntermediaryBank: false,
IsExpressWire: false,
},
BankAccountName: "Satoshi Nakamoto",
BankAccountNumber: "12345",
BankCode: 123,
BankAddress: "123 Fake St",
BankCity: "Tarry Town",
BankCountry: "Hyrule",
BankName: "Federal Reserve Bank",
WireCurrency: currency.KRW.String(),
SwiftCode: "Taylor",
RequiresIntermediaryBank: false,
IsExpressWire: false,
Amount: -1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
}
_, err := b.WithdrawFiatFunds(&withdrawFiatRequest)
@@ -508,7 +502,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -423,39 +423,47 @@ func (b *Bithumb) GetDepositAddress(cryptocurrency currency.Code, _ string) (str
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *Bithumb) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
_, err := b.WithdrawCrypto(withdrawRequest.Address,
withdrawRequest.AddressTag,
func (b *Bithumb) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := b.WithdrawCrypto(withdrawRequest.Crypto.Address,
withdrawRequest.Crypto.AddressTag,
withdrawRequest.Currency.String(),
withdrawRequest.Amount)
return "", err
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: v.Message,
Status: v.Status,
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bithumb) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
func (b *Bithumb) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
if math.Mod(withdrawRequest.Amount, 1) != 0 {
return "", errors.New("currency KRW does not support decimal places")
return nil, errors.New("currency KRW does not support decimal places")
}
if withdrawRequest.Currency != currency.KRW {
return "", errors.New("only KRW is supported")
return nil, errors.New("only KRW is supported")
}
bankDetails := strconv.FormatFloat(withdrawRequest.BankCode, 'f', -1, 64) +
"_" + withdrawRequest.BankName
resp, err := b.RequestKRWWithdraw(bankDetails, withdrawRequest.BankAccountNumber, int64(withdrawRequest.Amount))
bankDetails := strconv.FormatFloat(withdrawRequest.Fiat.Bank.BankCode, 'f', -1, 64) +
"_" + withdrawRequest.Fiat.Bank.BankName
resp, err := b.RequestKRWWithdraw(bankDetails, withdrawRequest.Fiat.Bank.AccountNumber, int64(withdrawRequest.Amount))
if err != nil {
return "", err
return nil, err
}
if resp.Status != "0000" {
return "", errors.New(resp.Message)
return nil, errors.New(resp.Message)
}
return resp.Message, nil
return &withdraw.ExchangeResponse{
Status: resp.Status,
}, nil
}
// WithdrawFiatFundsToInternationalBank is not supported as Bithumb only withdraws KRW to South Korean banks
func (b *Bithumb) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *Bithumb) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -17,7 +17,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply your own keys here for due diligence testing
@@ -608,14 +608,14 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
OneTimePassword: 000000,
withdrawCryptoRequest := withdraw.Request{
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
OneTimePassword: 000000,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -636,7 +636,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := b.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -648,7 +648,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -18,8 +18,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -523,35 +523,38 @@ func (b *Bitmex) GetDepositAddress(cryptocurrency currency.Code, _ string) (stri
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *Bitmex) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
func (b *Bitmex) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
var request = UserRequestWithdrawalParams{
Address: withdrawRequest.Address,
Address: withdrawRequest.Crypto.Address,
Amount: withdrawRequest.Amount,
Currency: withdrawRequest.Currency.String(),
OtpToken: withdrawRequest.OneTimePassword,
}
if withdrawRequest.FeeAmount > 0 {
request.Fee = withdrawRequest.FeeAmount
if withdrawRequest.Crypto.FeeAmount > 0 {
request.Fee = withdrawRequest.Crypto.FeeAmount
}
resp, err := b.UserRequestWithdrawal(request)
if err != nil {
return "", err
return nil, err
}
return resp.TransactID, nil
return &withdraw.ExchangeResponse{
Status: resp.Text,
ID: resp.Tx,
}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *Bitmex) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *Bitmex) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is
// submitted
func (b *Bitmex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *Bitmex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -8,7 +8,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please add your private keys and customerID for better tests
@@ -456,13 +457,13 @@ func TestWithdraw(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
_, err := b.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
@@ -483,24 +484,26 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
var withdrawFiatRequest = withdraw.Request{
Fiat: &withdraw.FiatRequest{
Bank: &banking.Account{
AccountName: "Satoshi Nakamoto",
AccountNumber: "12345",
BankAddress: "123 Fake St",
BankPostalCity: "Tarry Town",
BankCountry: "AU",
BankName: "Federal Reserve Bank",
SWIFTCode: "CTBAAU2S",
BankPostalCode: "2088",
IBAN: "IT60X0542811101000000123456",
},
WireCurrency: currency.USD.String(),
RequiresIntermediaryBank: false,
IsExpressWire: false,
},
BankAccountName: "Satoshi Nakamoto",
BankAccountNumber: "12345",
BankAddress: "123 Fake St",
BankCity: "Tarry Town",
BankCountry: "AU",
BankName: "Federal Reserve Bank",
WireCurrency: currency.USD.String(),
SwiftCode: "CTBAAU2S",
RequiresIntermediaryBank: false,
IsExpressWire: false,
BankPostalCode: "2088",
IBAN: "IT60X0542811101000000123456",
Amount: -1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
}
_, err := b.WithdrawFiatFunds(&withdrawFiatRequest)
@@ -521,30 +524,32 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
var withdrawFiatRequest = withdraw.Request{
Fiat: &withdraw.FiatRequest{
Bank: &banking.Account{
AccountName: "Satoshi Nakamoto",
AccountNumber: "12345",
BankAddress: "123 Fake St",
BankPostalCity: "Tarry Town",
BankCountry: "AU",
BankName: "Federal Reserve Bank",
SWIFTCode: "CTBAAU2S",
BankPostalCode: "2088",
IBAN: "IT60X0542811101000000123456",
},
WireCurrency: currency.USD.String(),
RequiresIntermediaryBank: false,
IsExpressWire: false,
IntermediaryBankAccountNumber: 12345,
IntermediaryBankAddress: "123 Fake St",
IntermediaryBankCity: "Tarry Town",
IntermediaryBankCountry: "AU",
IntermediaryBankName: "Federal Reserve Bank",
IntermediaryBankPostalCode: "2088",
},
BankAccountName: "Satoshi Nakamoto",
BankAccountNumber: "12345",
BankAddress: "123 Fake St",
BankCity: "Tarry Town",
BankCountry: "AU",
BankName: "Federal Reserve Bank",
WireCurrency: currency.USD.String(),
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",
Amount: -1,
Currency: currency.USD,
Description: "WITHDRAW IT ALL",
}
_, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -436,86 +436,94 @@ func (b *Bitstamp) GetDepositAddress(cryptocurrency currency.Code, _ string) (st
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *Bitstamp) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
func (b *Bitstamp) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
resp, err := b.CryptoWithdrawal(withdrawRequest.Amount,
withdrawRequest.Address,
withdrawRequest.Crypto.Address,
withdrawRequest.Currency.String(),
withdrawRequest.AddressTag,
withdrawRequest.Crypto.AddressTag,
true)
if err != nil {
return "", err
return nil, err
}
if len(resp.Error) != 0 {
var details strings.Builder
for x := range resp.Error {
details.WriteString(strings.Join(resp.Error[x], ""))
}
return "", errors.New(details.String())
return nil, errors.New(details.String())
}
return resp.ID, nil
return &withdraw.ExchangeResponse{
ID: resp.ID,
}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bitstamp) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
func (b *Bitstamp) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
resp, err := b.OpenBankWithdrawal(withdrawRequest.Amount,
withdrawRequest.Currency.String(),
withdrawRequest.BankAccountName,
withdrawRequest.IBAN,
withdrawRequest.SwiftCode,
withdrawRequest.BankAddress,
withdrawRequest.BankPostalCode,
withdrawRequest.BankCity,
withdrawRequest.BankCountry,
withdrawRequest.Fiat.Bank.AccountName,
withdrawRequest.Fiat.Bank.IBAN,
withdrawRequest.Fiat.Bank.SWIFTCode,
withdrawRequest.Fiat.Bank.BankAddress,
withdrawRequest.Fiat.Bank.BankPostalCode,
withdrawRequest.Fiat.Bank.BankPostalCity,
withdrawRequest.Fiat.Bank.BankCountry,
withdrawRequest.Description,
sepaWithdrawal)
if err != nil {
return "", err
return nil, err
}
if resp.Status == errStr {
var details strings.Builder
for x := range resp.Reason {
details.WriteString(strings.Join(resp.Reason[x], ""))
}
return "", errors.New(details.String())
return nil, errors.New(details.String())
}
return resp.ID, nil
return &withdraw.ExchangeResponse{
ID: resp.ID,
Status: resp.Status,
}, nil
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bitstamp) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
func (b *Bitstamp) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
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.Fiat.Bank.AccountName,
withdrawRequest.Fiat.Bank.IBAN,
withdrawRequest.Fiat.Bank.SWIFTCode,
withdrawRequest.Fiat.Bank.BankAddress,
withdrawRequest.Fiat.Bank.BankPostalCode,
withdrawRequest.Fiat.Bank.BankPostalCity,
withdrawRequest.Fiat.Bank.BankCountry,
withdrawRequest.Fiat.IntermediaryBankName,
withdrawRequest.Fiat.IntermediaryBankAddress,
withdrawRequest.Fiat.IntermediaryBankPostalCode,
withdrawRequest.Fiat.IntermediaryBankCity,
withdrawRequest.Fiat.IntermediaryBankCountry,
withdrawRequest.Fiat.WireCurrency,
withdrawRequest.Description,
internationalWithdrawal)
if err != nil {
return "", err
return nil, err
}
if resp.Status == errStr {
var details strings.Builder
for x := range resp.Reason {
details.WriteString(strings.Join(resp.Reason[x], ""))
}
return "", errors.New(details.String())
return nil, errors.New(details.String())
}
return resp.ID, nil
return &withdraw.ExchangeResponse{
ID: resp.ID,
Status: resp.Status,
}, nil
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -11,7 +11,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply you own test keys here to run better tests.
@@ -462,13 +462,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -489,7 +489,8 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := b.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -501,7 +502,8 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := b.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -17,8 +17,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -429,21 +429,26 @@ func (b *Bittrex) GetDepositAddress(cryptocurrency currency.Code, _ string) (str
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *Bittrex) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
uuid, err := b.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.AddressTag, withdrawRequest.Address, withdrawRequest.Amount)
return uuid.Result.ID, err
func (b *Bittrex) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
uuid, err := b.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.Crypto.AddressTag, withdrawRequest.Crypto.Address, withdrawRequest.Amount)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: uuid.Result.ID,
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bittrex) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *Bittrex) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (b *Bittrex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *Bittrex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -500,43 +500,49 @@ func (b *BTCMarkets) GetDepositAddress(cryptocurrency currency.Code, accountID s
}
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is submitted
func (b *BTCMarkets) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
func (b *BTCMarkets) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
a, err := b.RequestWithdraw(withdrawRequest.Currency.String(),
withdrawRequest.Amount,
withdrawRequest.Address,
withdrawRequest.Crypto.Address,
"",
"",
"",
"")
if err != nil {
return "", err
return nil, err
}
return a.Status, nil
return &withdraw.ExchangeResponse{
ID: a.ID,
Status: a.Status,
}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (b *BTCMarkets) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
func (b *BTCMarkets) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
if withdrawRequest.Currency != currency.AUD {
return "", errors.New("only aud is supported for withdrawals")
return nil, errors.New("only aud is supported for withdrawals")
}
a, err := b.RequestWithdraw(withdrawRequest.GenericInfo.Currency.String(),
withdrawRequest.GenericInfo.Amount,
a, err := b.RequestWithdraw(withdrawRequest.Currency.String(),
withdrawRequest.Amount,
"",
withdrawRequest.BankAccountName,
withdrawRequest.BankAccountNumber,
withdrawRequest.BSB,
withdrawRequest.BankName)
withdrawRequest.Fiat.Bank.AccountName,
withdrawRequest.Fiat.Bank.AccountNumber,
withdrawRequest.Fiat.Bank.BSBNumber,
withdrawRequest.Fiat.Bank.BankName)
if err != nil {
return "", err
return nil, err
}
return a.Status, nil
return &withdraw.ExchangeResponse{
ID: a.ID,
Status: a.Status,
}, nil
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (b *BTCMarkets) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *BTCMarkets) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -511,20 +511,20 @@ func (b *BTSE) GetDepositAddress(cryptocurrency currency.Code, accountID string)
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *BTSE) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *BTSE) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is
// submitted
func (b *BTSE) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *BTSE) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is
// submitted
func (b *BTSE) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (b *BTSE) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -16,7 +16,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
var c CoinbasePro
@@ -544,13 +545,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -571,12 +572,14 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: 100,
Currency: currency.USD,
var withdrawFiatRequest = withdraw.Request{
Amount: 100,
Currency: currency.USD,
Fiat: &withdraw.FiatRequest{
Bank: &banking.Account{
BankName: "Federal Reserve Bank",
},
},
BankName: "Federal Reserve Bank",
}
_, err := c.WithdrawFiatFunds(&withdrawFiatRequest)
@@ -593,12 +596,14 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: 100,
Currency: currency.USD,
var withdrawFiatRequest = withdraw.Request{
Amount: 100,
Currency: currency.USD,
Fiat: &withdraw.FiatRequest{
Bank: &banking.Account{
BankName: "Federal Reserve Bank",
},
},
BankName: "Federal Reserve Bank",
}
_, err := c.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -463,42 +463,56 @@ func (c *CoinbasePro) GetDepositAddress(cryptocurrency currency.Code, accountID
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (c *CoinbasePro) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
resp, err := c.WithdrawCrypto(withdrawRequest.Amount, withdrawRequest.Currency.String(), withdrawRequest.Address)
return resp.ID, err
func (c *CoinbasePro) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
resp, err := c.WithdrawCrypto(withdrawRequest.Amount, withdrawRequest.Currency.String(), withdrawRequest.Crypto.Address)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: resp.ID,
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is
// submitted
func (c *CoinbasePro) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
func (c *CoinbasePro) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
paymentMethods, err := c.GetPayMethods()
if err != nil {
return "", err
return nil, err
}
selectedWithdrawalMethod := PaymentMethod{}
for i := range paymentMethods {
if withdrawRequest.BankName == paymentMethods[i].Name {
if withdrawRequest.Fiat.Bank.BankName == paymentMethods[i].Name {
selectedWithdrawalMethod = paymentMethods[i]
break
}
}
if selectedWithdrawalMethod.ID == "" {
return "", fmt.Errorf("could not find payment method '%v'. Check the name via the website and try again", withdrawRequest.BankName)
return nil, fmt.Errorf("could not find payment method '%v'. Check the name via the website and try again", withdrawRequest.Fiat.Bank.BankName)
}
resp, err := c.WithdrawViaPaymentMethod(withdrawRequest.Amount, withdrawRequest.Currency.String(), selectedWithdrawalMethod.ID)
if err != nil {
return "", err
return nil, err
}
return resp.ID, nil
return &withdraw.ExchangeResponse{
Status: resp.ID,
}, nil
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (c *CoinbasePro) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return c.WithdrawFiatFunds(withdrawRequest)
func (c *CoinbasePro) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := c.WithdrawFiatFunds(withdrawRequest)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: v.ID,
Status: v.Status,
}, nil
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -18,8 +18,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -560,20 +560,20 @@ func (c *Coinbene) GetDepositAddress(cryptocurrency currency.Code, accountID str
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (c *Coinbene) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (c *Coinbene) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is
// submitted
func (c *Coinbene) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (c *Coinbene) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is
// submitted
func (c *Coinbene) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (c *Coinbene) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -15,7 +15,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
var c COINUT
@@ -384,13 +384,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -408,7 +408,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := c.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -420,7 +420,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := c.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -664,20 +664,20 @@ func (c *COINUT) GetDepositAddress(cryptocurrency currency.Code, accountID strin
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (c *COINUT) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (c *COINUT) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (c *COINUT) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (c *COINUT) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (c *COINUT) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (c *COINUT) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -16,6 +16,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/protocol"
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
)
const (
@@ -222,16 +223,16 @@ func (e *Base) GetPairAssetType(c currency.Pair) (asset.Item, error) {
// GetClientBankAccounts returns banking details associated with
// a client for withdrawal purposes
func (e *Base) GetClientBankAccounts(exchangeName, withdrawalCurrency string) (config.BankAccount, error) {
func (e *Base) GetClientBankAccounts(exchangeName, withdrawalCurrency string) (*banking.Account, error) {
cfg := config.GetConfig()
return cfg.GetClientBankAccounts(exchangeName, withdrawalCurrency)
}
// GetExchangeBankAccounts returns banking details associated with an
// exchange for funding purposes
func (e *Base) GetExchangeBankAccounts(exchangeName, depositCurrency string) (config.BankAccount, error) {
func (e *Base) GetExchangeBankAccounts(id, depositCurrency string) (*banking.Account, error) {
cfg := config.GetConfig()
return cfg.GetExchangeBankAccounts(exchangeName, depositCurrency)
return cfg.GetExchangeBankAccounts(e.Name, id, depositCurrency)
}
// SetCurrencyPairFormat checks the exchange request and config currency pair

View File

@@ -12,6 +12,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/protocol"
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
)
const (
@@ -311,7 +312,7 @@ func TestGetClientBankAccounts(t *testing.T) {
}
var b Base
var r config.BankAccount
var r *banking.Account
r, err = b.GetClientBankAccounts("Kraken", "USD")
if err != nil {
t.Error(err)
@@ -321,31 +322,7 @@ func TestGetClientBankAccounts(t *testing.T) {
t.Error("incorrect bank name")
}
r, err = b.GetClientBankAccounts("MEOW", "USD")
if err == nil {
t.Error("an error should have been thrown for a non-existent exchange")
}
}
func TestGetExchangeBankAccounts(t *testing.T) {
cfg := config.GetConfig()
err := cfg.LoadConfig(config.TestFile, true)
if err != nil {
t.Fatal(err)
}
var b Base
var r config.BankAccount
r, err = b.GetExchangeBankAccounts("Bitfinex", "USD")
if err != nil {
t.Error(err)
}
if r.BankName != "Deutsche Bank Privat Und Geschaeftskunden AG" {
t.Error("incorrect bank name")
}
_, err = b.GetExchangeBankAccounts("MEOW", "USD")
_, err = b.GetClientBankAccounts("MEOW", "USD")
if err == nil {
t.Error("an error should have been thrown for a non-existent exchange")
}

View File

@@ -11,7 +11,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
const (
@@ -384,13 +384,13 @@ func TestWithdraw(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
_, err := e.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
@@ -407,7 +407,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := e.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -419,7 +419,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := e.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -434,25 +434,27 @@ func (e *EXMO) GetDepositAddress(cryptocurrency currency.Code, _ string) (string
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (e *EXMO) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
func (e *EXMO) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
resp, err := e.WithdrawCryptocurrency(withdrawRequest.Currency.String(),
withdrawRequest.Address,
withdrawRequest.AddressTag,
withdrawRequest.Crypto.Address,
withdrawRequest.Crypto.AddressTag,
withdrawRequest.Amount)
return strconv.FormatInt(resp, 10), err
return &withdraw.ExchangeResponse{
ID: strconv.FormatInt(resp, 10),
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (e *EXMO) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (e *EXMO) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (e *EXMO) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (e *EXMO) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -15,6 +15,7 @@ import (
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
const (
@@ -497,7 +498,7 @@ func getCryptocurrencyWithdrawalFee(c currency.Code) float64 {
}
// WithdrawCrypto withdraws cryptocurrency to your selected wallet
func (g *Gateio) WithdrawCrypto(currency, address string, amount float64) (string, error) {
func (g *Gateio) WithdrawCrypto(currency, address string, amount float64) (*withdraw.ExchangeResponse, error) {
type response struct {
Result bool `json:"result"`
Message string `json:"message"`
@@ -512,13 +513,15 @@ func (g *Gateio) WithdrawCrypto(currency, address string, amount float64) (strin
)
err := g.SendAuthenticatedHTTPRequest(http.MethodPost, gateioWithdraw, params, &result)
if err != nil {
return "", err
return nil, err
}
if !result.Result {
return "", fmt.Errorf("code:%d message:%s", result.Code, result.Message)
return nil, fmt.Errorf("code:%d message:%s", result.Code, result.Message)
}
return result.Message, nil
return &withdraw.ExchangeResponse{
Status: result.Message,
}, nil
}
// GetCryptoDepositAddress returns a deposit address for a cryptocurrency

View File

@@ -15,7 +15,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply your own APIKEYS here for due diligence testing
@@ -407,13 +407,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -434,7 +434,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := g.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -446,7 +446,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := g.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -21,8 +21,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -539,20 +539,20 @@ func (g *Gateio) GetDepositAddress(cryptocurrency currency.Code, _ string) (stri
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (g *Gateio) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return g.WithdrawCrypto(withdrawRequest.Currency.String(), withdrawRequest.Address, withdrawRequest.Amount)
func (g *Gateio) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return g.WithdrawCrypto(withdrawRequest.Currency.String(), withdrawRequest.Crypto.Address, withdrawRequest.Amount)
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (g *Gateio) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (g *Gateio) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (g *Gateio) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (g *Gateio) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -13,7 +13,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please enter sandbox API keys & assigned roles for better testing procedures
@@ -479,13 +479,13 @@ func TestModifyOrder(t *testing.T) {
func TestWithdraw(t *testing.T) {
t.Parallel()
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders && !mockTests {
@@ -510,7 +510,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := g.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",
@@ -525,7 +525,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := g.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -412,28 +412,30 @@ func (g *Gemini) GetDepositAddress(cryptocurrency currency.Code, _ string) (stri
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (g *Gemini) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
resp, err := g.WithdrawCrypto(withdrawRequest.Address, withdrawRequest.Currency.String(), withdrawRequest.Amount)
func (g *Gemini) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
resp, err := g.WithdrawCrypto(withdrawRequest.Crypto.Address, withdrawRequest.Currency.String(), withdrawRequest.Amount)
if err != nil {
return "", err
return nil, err
}
if resp.Result == "error" {
return "", errors.New(resp.Message)
return nil, errors.New(resp.Message)
}
return resp.TXHash, err
return &withdraw.ExchangeResponse{
ID: resp.TXHash,
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (g *Gemini) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (g *Gemini) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (g *Gemini) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (g *Gemini) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -17,7 +17,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
var h HitBTC
@@ -341,13 +341,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -368,7 +368,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := h.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -380,7 +380,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := h.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -484,21 +484,26 @@ func (h *HitBTC) GetDepositAddress(currency currency.Code, _ string) (string, er
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (h *HitBTC) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
_, err := h.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.Address, withdrawRequest.Amount)
return "", err
func (h *HitBTC) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := h.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.Crypto.Address, withdrawRequest.Amount)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
Status: common.IsEnabled(v),
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (h *HitBTC) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (h *HitBTC) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (h *HitBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (h *HitBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -15,7 +15,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply you own test keys here for due diligence testing.
@@ -557,13 +557,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -584,7 +584,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := h.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -596,7 +596,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := h.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -655,21 +655,26 @@ func (h *HUOBI) GetDepositAddress(cryptocurrency currency.Code, accountID string
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (h *HUOBI) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
resp, err := h.Withdraw(withdrawRequest.Currency, withdrawRequest.Address, withdrawRequest.AddressTag, withdrawRequest.Amount, withdrawRequest.FeeAmount)
return strconv.FormatInt(resp, 10), err
func (h *HUOBI) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
resp, err := h.Withdraw(withdrawRequest.Currency, withdrawRequest.Crypto.Address, withdrawRequest.Crypto.AddressTag, withdrawRequest.Amount, withdrawRequest.Crypto.FeeAmount)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: strconv.FormatInt(resp, 10),
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (h *HUOBI) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (h *HUOBI) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (h *HUOBI) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (h *HUOBI) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -11,7 +11,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// IBotExchange enforces standard functions for all exchanges supported in
@@ -54,9 +54,9 @@ type IBotExchange interface {
GetDepositAddress(cryptocurrency currency.Code, accountID string) (string, error)
GetOrderHistory(getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)
GetActiveOrders(getOrdersRequest *order.GetOrdersRequest) ([]order.Detail, error)
WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error)
WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error)
WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error)
WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)
WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)
WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error)
SetHTTPClientUserAgent(ua string)
GetHTTPClientUserAgent() string
SetClientProxyAddress(addr string) error

View File

@@ -12,7 +12,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
var i ItBit
@@ -391,13 +391,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -415,7 +415,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := i.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -427,7 +427,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := i.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -408,20 +408,20 @@ func (i *ItBit) GetDepositAddress(cryptocurrency currency.Code, accountID string
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (i *ItBit) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (i *ItBit) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (i *ItBit) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (i *ItBit) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (i *ItBit) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (i *ItBit) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -15,7 +15,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
var k Kraken
@@ -531,14 +531,14 @@ func TestModifyOrder(t *testing.T) {
// TestWithdraw wrapper test
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.XXBT,
Description: "WITHDRAW IT ALL",
TradePassword: "Key",
withdrawCryptoRequest := withdraw.Request{
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
Amount: -1,
Currency: currency.XXBT,
Description: "WITHDRAW IT ALL",
TradePassword: "Key",
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -560,13 +560,11 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.EUR,
Description: "WITHDRAW IT ALL",
TradePassword: "someBank",
},
var withdrawFiatRequest = withdraw.Request{
Amount: -1,
Currency: currency.EUR,
Description: "WITHDRAW IT ALL",
TradePassword: "someBank",
}
_, err := k.WithdrawFiatFunds(&withdrawFiatRequest)
@@ -584,13 +582,11 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.EUR,
Description: "WITHDRAW IT ALL",
TradePassword: "someBank",
},
var withdrawFiatRequest = withdraw.Request{
Amount: -1,
Currency: currency.EUR,
Description: "WITHDRAW IT ALL",
TradePassword: "someBank",
}
_, err := k.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -587,20 +587,38 @@ func (k *Kraken) GetDepositAddress(cryptocurrency currency.Code, _ string) (stri
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal
// Populate exchange.WithdrawRequest.TradePassword with withdrawal key name, as set up on your account
func (k *Kraken) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return k.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.TradePassword, withdrawRequest.Amount)
func (k *Kraken) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := k.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.TradePassword, withdrawRequest.Amount)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: v,
}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (k *Kraken) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return k.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.TradePassword, withdrawRequest.Amount)
func (k *Kraken) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := k.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.TradePassword, withdrawRequest.Amount)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
Status: v,
}, nil
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (k *Kraken) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return k.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.TradePassword, withdrawRequest.Amount)
func (k *Kraken) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := k.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.TradePassword, withdrawRequest.Amount)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
Status: v,
}, nil
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -14,7 +14,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
var l LakeBTC
@@ -377,13 +377,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -404,7 +404,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := l.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -416,7 +416,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := l.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -420,29 +420,31 @@ func (l *LakeBTC) GetDepositAddress(cryptocurrency currency.Code, _ string) (str
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (l *LakeBTC) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
func (l *LakeBTC) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
if withdrawRequest.Currency != currency.BTC {
return "", errors.New("only BTC supported for withdrawals")
return nil, errors.New("only BTC supported for withdrawals")
}
resp, err := l.CreateWithdraw(withdrawRequest.Amount, withdrawRequest.Description)
if err != nil {
return "", err
return nil, err
}
return strconv.FormatInt(resp.ID, 10), nil
return &withdraw.ExchangeResponse{
ID: strconv.FormatInt(resp.ID, 10),
}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (l *LakeBTC) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (l *LakeBTC) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (l *LakeBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (l *LakeBTC) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -469,23 +469,28 @@ func (l *Lbank) GetDepositAddress(cryptocurrency currency.Code, accountID string
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (l *Lbank) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
resp, err := l.Withdraw(withdrawRequest.Address, withdrawRequest.Currency.String(),
func (l *Lbank) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
resp, err := l.Withdraw(withdrawRequest.Crypto.Address, withdrawRequest.Currency.String(),
strconv.FormatFloat(withdrawRequest.Amount, 'f', -1, 64), "",
withdrawRequest.Description, "")
return resp.WithdrawID, err
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: resp.WithdrawID,
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a withdrawal is
// submitted
func (l *Lbank) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (l *Lbank) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a withdrawal is
// submitted
func (l *Lbank) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (l *Lbank) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -8,7 +8,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply your own APIKEYS here for due diligence testing
@@ -334,13 +334,13 @@ func TestModifyOrder(t *testing.T) {
func TestWithdraw(t *testing.T) {
t.Parallel()
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders && !mockTests {
@@ -361,7 +361,7 @@ func TestWithdraw(t *testing.T) {
func TestWithdrawFiat(t *testing.T) {
t.Parallel()
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := l.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",
@@ -373,7 +373,7 @@ func TestWithdrawFiat(t *testing.T) {
func TestWithdrawInternationalBank(t *testing.T) {
t.Parallel()
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := l.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",

View File

@@ -21,8 +21,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -410,23 +410,26 @@ func (l *LocalBitcoins) GetDepositAddress(cryptocurrency currency.Code, _ string
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (l *LocalBitcoins) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return "",
l.WalletSend(withdrawRequest.Address,
withdrawRequest.Amount,
withdrawRequest.PIN)
func (l *LocalBitcoins) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
err := l.WalletSend(withdrawRequest.Crypto.Address,
withdrawRequest.Amount,
withdrawRequest.PIN)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (l *LocalBitcoins) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (l *LocalBitcoins) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (l *LocalBitcoins) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (l *LocalBitcoins) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -21,7 +21,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply you own test keys here for due diligence testing.
@@ -1061,15 +1061,15 @@ func TestModifyOrder(t *testing.T) {
func TestWithdraw(t *testing.T) {
TestSetRealOrderDefaults(t)
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
TradePassword: "Password",
withdrawCryptoRequest := withdraw.Request{
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
FeeAmount: 1,
},
Address: core.BitcoinDonationAddress,
FeeAmount: 1,
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
TradePassword: "Password",
}
_, err := o.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
@@ -1079,7 +1079,7 @@ func TestWithdraw(t *testing.T) {
// TestWithdrawFiat Wrapper test
func TestWithdrawFiat(t *testing.T) {
TestSetRealOrderDefaults(t)
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := o.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -1089,7 +1089,7 @@ func TestWithdrawFiat(t *testing.T) {
// TestSubmitOrder Wrapper test
func TestWithdrawInternationalBank(t *testing.T) {
TestSetRealOrderDefaults(t)
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := o.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -23,7 +23,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply you own test keys here for due diligence testing.
@@ -1753,15 +1753,15 @@ func TestModifyOrder(t *testing.T) {
func TestWithdraw(t *testing.T) {
TestSetRealOrderDefaults(t)
t.Parallel()
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
TradePassword: "Password",
withdrawCryptoRequest := withdraw.Request{
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
FeeAmount: 1,
},
Address: core.BitcoinDonationAddress,
FeeAmount: 1,
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
TradePassword: "Password",
}
_, err := o.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest)
testStandardErrorHandling(t, err)
@@ -1771,7 +1771,7 @@ func TestWithdraw(t *testing.T) {
func TestWithdrawFiat(t *testing.T) {
TestSetRealOrderDefaults(t)
t.Parallel()
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := o.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",
@@ -1784,7 +1784,7 @@ func TestWithdrawFiat(t *testing.T) {
func TestWithdrawInternationalBank(t *testing.T) {
TestSetRealOrderDefaults(t)
t.Parallel()
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := o.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",

View File

@@ -15,7 +15,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Note: GoCryptoTrader wrapper funcs currently only support SPOT trades.
@@ -384,38 +384,40 @@ func (o *OKGroup) GetDepositAddress(p currency.Code, accountID string) (string,
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (o *OKGroup) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
func (o *OKGroup) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
withdrawal, err := o.AccountWithdraw(AccountWithdrawRequest{
Amount: withdrawRequest.Amount,
Currency: withdrawRequest.Currency.Lower().String(),
Destination: 4, // 1, 2, 3 are all internal
Fee: withdrawRequest.FeeAmount,
ToAddress: withdrawRequest.Address,
Fee: withdrawRequest.Crypto.FeeAmount,
ToAddress: withdrawRequest.Crypto.Address,
TradePwd: withdrawRequest.TradePassword,
})
if err != nil {
return "", err
return nil, err
}
if !withdrawal.Result {
return strconv.FormatInt(withdrawal.WithdrawalID, 10),
return nil,
fmt.Errorf("could not withdraw currency %s to %s, no error specified",
withdrawRequest.Currency,
withdrawRequest.Address)
withdrawRequest.Crypto.Address)
}
return strconv.FormatInt(withdrawal.WithdrawalID, 10), nil
return &withdraw.ExchangeResponse{
ID: strconv.FormatInt(withdrawal.WithdrawalID, 10),
}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (o *OKGroup) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (o *OKGroup) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (o *OKGroup) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (o *OKGroup) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetActiveOrders retrieves any orders that are active/open

View File

@@ -499,8 +499,8 @@ func (p *Poloniex) MoveOrder(orderID int64, rate, amount float64, postOnly, imme
}
// Withdraw withdraws a currency to a specific delegated address
func (p *Poloniex) Withdraw(currency, address string, amount float64) (bool, error) {
result := Withdraw{}
func (p *Poloniex) Withdraw(currency, address string, amount float64) (*Withdraw, error) {
result := &Withdraw{}
values := url.Values{}
values.Set("currency", currency)
@@ -509,14 +509,14 @@ func (p *Poloniex) Withdraw(currency, address string, amount float64) (bool, err
err := p.SendAuthenticatedHTTPRequest(http.MethodPost, poloniexWithdraw, values, &result)
if err != nil {
return false, err
return nil, err
}
if result.Error != "" {
return false, errors.New(result.Error)
return nil, errors.New(result.Error)
}
return true, nil
return result, nil
}
// GetFeeInfo returns fee information

View File

@@ -14,7 +14,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply your own APIKEYS here for due diligence testing
@@ -349,15 +349,16 @@ func TestModifyOrder(t *testing.T) {
func TestWithdraw(t *testing.T) {
t.Parallel()
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: 0,
Currency: currency.LTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
FeeAmount: 1,
},
Address: core.BitcoinDonationAddress,
Amount: 0,
Currency: currency.LTC,
Description: "WITHDRAW IT ALL",
TradePassword: "Password",
}
if areTestAPIKeysSet() && !canManipulateRealOrders && !mockTests {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
@@ -379,7 +380,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest withdraw.FiatRequest
var withdrawFiatRequest withdraw.Request
_, err := p.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",
@@ -393,7 +394,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest withdraw.FiatRequest
var withdrawFiatRequest withdraw.Request
_, err := p.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",

View File

@@ -19,8 +19,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -478,21 +478,26 @@ func (p *Poloniex) GetDepositAddress(cryptocurrency currency.Code, _ string) (st
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (p *Poloniex) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
_, err := p.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.Address, withdrawRequest.Amount)
return "", err
func (p *Poloniex) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := p.Withdraw(withdrawRequest.Currency.String(), withdrawRequest.Crypto.Address, withdrawRequest.Amount)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
Status: v.Response,
}, err
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (p *Poloniex) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (p *Poloniex) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (p *Poloniex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (p *Poloniex) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -1,74 +0,0 @@
package withdraw
import (
"errors"
"strings"
"github.com/thrasher-corp/gocryptotrader/currency"
)
// Valid takes interface and passes to asset type to check the request meets requirements to submit
func Valid(request interface{}) error {
switch request := request.(type) {
case *FiatRequest:
return ValidateFiat(request)
case *CryptoRequest:
return ValidateCrypto(request)
default:
return ErrInvalidRequest
}
}
// ValidateFiat checks if Fiat request is valid
func ValidateFiat(request *FiatRequest) (err error) {
if request == nil {
return ErrRequestCannotBeNil
}
var allErrors []string
if (request.Currency != currency.Code{}) {
if !request.Currency.IsFiatCurrency() {
allErrors = append(allErrors, "currency is not a fiat currency")
}
} else {
allErrors = append(allErrors, ErrStrNoCurrencySet)
}
if request.Amount <= 0 {
allErrors = append(allErrors, ErrStrAmountMustBeGreaterThanZero)
}
if len(allErrors) > 0 {
err = errors.New(strings.Join(allErrors, ", "))
}
return err
}
// ValidateCrypto checks if Crypto request is valid
func ValidateCrypto(request *CryptoRequest) (err error) {
if request == nil {
return ErrRequestCannotBeNil
}
var allErrors []string
if (request.Currency != currency.Code{}) {
if !request.Currency.IsCryptocurrency() {
allErrors = append(allErrors, "currency is not a crypto currency")
}
} else {
allErrors = append(allErrors, ErrStrNoCurrencySet)
}
if request.Amount <= 0 {
allErrors = append(allErrors, ErrStrAmountMustBeGreaterThanZero)
}
if request.Address == "" {
allErrors = append(allErrors, ErrStrAddressNotSet)
}
if len(allErrors) > 0 {
err = errors.New(strings.Join(allErrors, ", "))
}
return err
}

View File

@@ -1,179 +0,0 @@
package withdraw
import (
"errors"
"testing"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/currency"
)
var (
validFiatRequest = &FiatRequest{
GenericInfo: GenericInfo{
Currency: currency.AUD,
Description: "Test Withdrawal",
Amount: 0.1,
},
BankAccountName: "test-bank-account",
BankAccountNumber: "test-bank-number",
BankName: "test-bank-name",
BSB: "",
SwiftCode: "",
IBAN: "",
}
invalidFiatRequest = &FiatRequest{}
invalidCurrencyFiatRequest = &FiatRequest{
GenericInfo: GenericInfo{
Currency: currency.BTC,
Amount: 1,
},
}
validCryptoRequest = &CryptoRequest{
GenericInfo: GenericInfo{
Currency: currency.BTC,
Description: "Test Withdrawal",
Amount: 0.1,
},
Address: core.BitcoinDonationAddress,
}
invalidCryptoRequest = &CryptoRequest{}
invalidCurrencyCryptoRequest = &CryptoRequest{
GenericInfo: GenericInfo{
Currency: currency.AUD,
Amount: 0,
},
}
invalidCryptoAddressRequest = &CryptoRequest{
GenericInfo: GenericInfo{
Currency: currency.BTC,
Description: "Test Withdrawal",
Amount: 0.1,
},
Address: "1D10TH0RS3",
}
)
func TestValid(t *testing.T) {
testCases := []struct {
name string
request interface{}
output interface{}
}{
{
"Fiat",
validFiatRequest,
nil,
},
{
"Crypto",
validCryptoRequest,
nil,
},
{
"Invalid",
nil,
ErrInvalidRequest,
},
}
for _, tests := range testCases {
test := tests
t.Run(test.name, func(t *testing.T) {
err := Valid(test.request)
if err != nil {
if test.output.(error).Error() != err.Error() {
t.Fatal(err)
}
}
})
}
}
func TestValidateFiat(t *testing.T) {
testCases := []struct {
name string
request *FiatRequest
output interface{}
}{
{
"Valid",
validFiatRequest,
nil,
},
{
"Invalid",
invalidFiatRequest,
errors.New("currency not set, amount must be greater than 0"),
},
{
"NoRequest",
nil,
ErrRequestCannotBeNil,
},
{
"CryptoCurrency",
invalidCurrencyFiatRequest,
errors.New("currency is not a fiat currency"),
},
}
for _, tests := range testCases {
test := tests
t.Run(test.name, func(t *testing.T) {
err := ValidateFiat(test.request)
if err != nil {
if test.output.(error).Error() != err.Error() {
t.Fatal(err)
}
}
})
}
}
func TestValidateCrypto(t *testing.T) {
testCases := []struct {
name string
request *CryptoRequest
output interface{}
}{
{
"Valid",
validCryptoRequest,
nil,
},
{
"Invalid",
invalidCryptoRequest,
errors.New("currency not set, amount must be greater than 0, address cannot be empty"),
},
{
"NoRequest",
nil,
ErrRequestCannotBeNil,
},
{
"FiatCurrency",
invalidCurrencyCryptoRequest,
errors.New("currency is not a crypto currency, amount must be greater than 0, address cannot be empty"),
},
{
"InvalidAddress",
invalidCryptoAddressRequest,
errors.New(ErrStrAddressisInvalid),
},
}
for _, tests := range testCases {
test := tests
t.Run(test.name, func(t *testing.T) {
err := ValidateCrypto(test.request)
if err != nil {
if test.output.(error).Error() != err.Error() {
t.Fatal(err)
}
}
})
}
}

View File

@@ -1,76 +0,0 @@
package withdraw
import (
"errors"
"github.com/thrasher-corp/gocryptotrader/currency"
)
const (
// ErrStrAmountMustBeGreaterThanZero message to return when withdraw amount is less than 0
ErrStrAmountMustBeGreaterThanZero = "amount must be greater than 0"
// ErrStrAddressisInvalid message to return when address is invalid for crypto request
ErrStrAddressisInvalid = "address is not valid"
// ErrStrAddressNotSet message to return when address is empty
ErrStrAddressNotSet = "address cannot be empty"
// ErrStrNoCurrencySet message to return when no currency is set
ErrStrNoCurrencySet = "currency not set"
)
var (
// ErrRequestCannotBeNil message to return when a request is nil
ErrRequestCannotBeNil = errors.New("request cannot be nil")
// ErrInvalidRequest message to return when a request is invalid
ErrInvalidRequest = errors.New("invalid request type")
)
// GenericInfo stores genric withdraw request info
type GenericInfo struct {
// General withdraw information
Currency currency.Code
Description string
OneTimePassword int64
AccountID string
PIN int64
TradePassword string
Amount float64
}
// CryptoRequest stores the info required for a crypto withdrawal request
type CryptoRequest struct {
GenericInfo
// Crypto related information
Address string
AddressTag string
FeeAmount float64
}
// FiatRequest used for fiat withdrawal requests
type FiatRequest struct {
GenericInfo
// FIAT related information
BankAccountName string
BankAccountNumber string
BankName string
BankAddress string
BankCity string
BankCountry string
BankPostalCode string
BSB 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
}

View File

@@ -14,7 +14,7 @@ import (
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
var y Yobit
@@ -447,13 +447,13 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
},
Address: core.BitcoinDonationAddress,
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -474,7 +474,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := y.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",
@@ -488,7 +488,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := y.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'",

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -423,27 +423,27 @@ func (y *Yobit) GetDepositAddress(cryptocurrency currency.Code, _ string) (strin
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (y *Yobit) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
resp, err := y.WithdrawCoinsToAddress(withdrawRequest.Currency.String(), withdrawRequest.Amount, withdrawRequest.Address)
func (y *Yobit) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
resp, err := y.WithdrawCoinsToAddress(withdrawRequest.Currency.String(), withdrawRequest.Amount, withdrawRequest.Crypto.Address)
if err != nil {
return "", err
return nil, err
}
if len(resp.Error) > 0 {
return "", errors.New(resp.Error)
return nil, errors.New(resp.Error)
}
return "success", nil
return &withdraw.ExchangeResponse{}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (y *Yobit) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (y *Yobit) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (y *Yobit) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (y *Yobit) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket

View File

@@ -17,7 +17,7 @@ import (
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// Please supply you own test keys here for due diligence testing.
@@ -415,14 +415,14 @@ func TestModifyOrder(t *testing.T) {
}
func TestWithdraw(t *testing.T) {
withdrawCryptoRequest := withdraw.CryptoRequest{
GenericInfo: withdraw.GenericInfo{
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
withdrawCryptoRequest := withdraw.Request{
Crypto: &withdraw.CryptoRequest{
Address: core.BitcoinDonationAddress,
FeeAmount: 1,
},
Address: core.BitcoinDonationAddress,
FeeAmount: 1,
Amount: -1,
Currency: currency.BTC,
Description: "WITHDRAW IT ALL",
}
if areTestAPIKeysSet() && !canManipulateRealOrders {
@@ -443,7 +443,7 @@ func TestWithdrawFiat(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := z.WithdrawFiatFunds(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)
@@ -455,7 +455,7 @@ func TestWithdrawInternationalBank(t *testing.T) {
t.Skip("API keys set, canManipulateRealOrders false, skipping test")
}
var withdrawFiatRequest = withdraw.FiatRequest{}
var withdrawFiatRequest = withdraw.Request{}
_, err := z.WithdrawFiatFundsToInternationalBank(&withdrawFiatRequest)
if err != common.ErrFunctionNotSupported {
t.Errorf("Expected '%v', received: '%v'", common.ErrFunctionNotSupported, err)

View File

@@ -20,8 +20,8 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
"github.com/thrasher-corp/gocryptotrader/exchanges/websocket/wshandler"
"github.com/thrasher-corp/gocryptotrader/exchanges/withdraw"
"github.com/thrasher-corp/gocryptotrader/log"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
// GetDefaultConfig returns a default exchange config
@@ -515,20 +515,26 @@ func (z *ZB) GetDepositAddress(cryptocurrency currency.Code, _ string) (string,
// WithdrawCryptocurrencyFunds returns a withdrawal ID when a withdrawal is
// submitted
func (z *ZB) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.CryptoRequest) (string, error) {
return z.Withdraw(withdrawRequest.Currency.Lower().String(), withdrawRequest.Address, withdrawRequest.TradePassword, withdrawRequest.Amount, withdrawRequest.FeeAmount, false)
func (z *ZB) WithdrawCryptocurrencyFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
v, err := z.Withdraw(withdrawRequest.Currency.Lower().String(), withdrawRequest.Crypto.Address, withdrawRequest.TradePassword, withdrawRequest.Amount, withdrawRequest.Crypto.FeeAmount, false)
if err != nil {
return nil, err
}
return &withdraw.ExchangeResponse{
ID: v,
}, nil
}
// WithdrawFiatFunds returns a withdrawal ID when a
// withdrawal is submitted
func (z *ZB) WithdrawFiatFunds(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (z *ZB) WithdrawFiatFunds(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// WithdrawFiatFundsToInternationalBank returns a withdrawal ID when a
// withdrawal is submitted
func (z *ZB) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.FiatRequest) (string, error) {
return "", common.ErrFunctionNotSupported
func (z *ZB) WithdrawFiatFundsToInternationalBank(withdrawRequest *withdraw.Request) (*withdraw.ExchangeResponse, error) {
return nil, common.ErrFunctionNotSupported
}
// GetWebsocket returns a pointer to the exchange websocket