mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Add WithdrawStatus/WithdrawCancel functions and tests to kraken (#237)
* Add functions and tests to kraken * Fix changes requested
This commit is contained in:
committed by
Adrian Gallagher
parent
41415ca3b9
commit
89956f50ea
@@ -44,6 +44,8 @@ const (
|
||||
krakenWithdraw = "Withdraw"
|
||||
krakenDepositMethods = "DepositMethods"
|
||||
krakenDepositAddresses = "DepositAddresses"
|
||||
krakenWithdrawStatus = "WithdrawStatus"
|
||||
krakenWithdrawCancel = "WithdrawCancel"
|
||||
|
||||
krakenAuthRate = 0
|
||||
krakenUnauthRate = 0
|
||||
@@ -1027,3 +1029,41 @@ func (k *Kraken) GetCryptoDepositAddress(method, code string) (string, error) {
|
||||
|
||||
return "", errors.New("no addresses returned")
|
||||
}
|
||||
|
||||
// WithdrawStatus gets the status of recent withdrawals
|
||||
func (k *Kraken) WithdrawStatus(currency, method string) ([]WithdrawStatusResponse, error) {
|
||||
var response struct {
|
||||
Error []string `json:"error"`
|
||||
Result []WithdrawStatusResponse `json:"result"`
|
||||
}
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("asset ", currency)
|
||||
if len(method) != 0 {
|
||||
params.Set("method", method)
|
||||
}
|
||||
|
||||
if err := k.SendAuthenticatedHTTPRequest(krakenWithdrawStatus, params, &response); err != nil {
|
||||
return response.Result, err
|
||||
}
|
||||
|
||||
return response.Result, GetError(response.Error)
|
||||
}
|
||||
|
||||
// WithdrawCancel sends a withdrawal cancelation request
|
||||
func (k *Kraken) WithdrawCancel(currency, refID string) (bool, error) {
|
||||
var response struct {
|
||||
Error []string `json:"error"`
|
||||
Result bool `json:"result"`
|
||||
}
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("asset ", currency)
|
||||
params.Set("refid", refID)
|
||||
|
||||
if err := k.SendAuthenticatedHTTPRequest(krakenWithdrawCancel, params, &response); err != nil {
|
||||
return response.Result, err
|
||||
}
|
||||
|
||||
return response.Result, GetError(response.Error)
|
||||
}
|
||||
|
||||
@@ -533,3 +533,32 @@ func TestGetDepositAddress(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithdrawStatus(t *testing.T) {
|
||||
k.SetDefaults()
|
||||
TestSetup(t)
|
||||
|
||||
if areTestAPIKeysSet() {
|
||||
_, err := k.WithdrawStatus(symbol.BTC, "")
|
||||
if err == nil {
|
||||
t.Error("Test Failed - WithdrawStatus() error", err)
|
||||
}
|
||||
} else {
|
||||
_, err := k.WithdrawStatus(symbol.BTC, "")
|
||||
if err == nil {
|
||||
t.Error("Test Failed - WithdrawStatus() error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithdrawCancel(t *testing.T) {
|
||||
k.SetDefaults()
|
||||
TestSetup(t)
|
||||
|
||||
_, err := k.WithdrawCancel(symbol.BTC, "")
|
||||
if areTestAPIKeysSet() && err == nil {
|
||||
t.Error("Test Failed - WithdrawCancel() error cannot be nil")
|
||||
} else if !areTestAPIKeysSet() && err == nil {
|
||||
t.Errorf("Test Failed - WithdrawCancel() error - expecting an error when no keys are set but recieved nil")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,3 +372,17 @@ type DepositAddress struct {
|
||||
ExpireTime int64 `json:"expiretm,string"`
|
||||
New bool `json:"new"`
|
||||
}
|
||||
|
||||
// WithdrawStatusResponse defines a withdrawal status response
|
||||
type WithdrawStatusResponse struct {
|
||||
Method string `json:"method"`
|
||||
Aclass string `json:"aclass"`
|
||||
Asset string `json:"asset"`
|
||||
Refid string `json:"refid"`
|
||||
TxID string `json:"txid"`
|
||||
Info string `json:"info"`
|
||||
Amount float64 `json:"amount,string"`
|
||||
Fee float64 `json:"fee,string"`
|
||||
Time float64 `json:"time"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user