Skip to content

Commit

Permalink
Withdrawals (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
byroncoetsee authored Dec 10, 2022
1 parent 691cecd commit 0f4ac5c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
33 changes: 33 additions & 0 deletions rest/private_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,39 @@ func (api *Kraken) GetDepositStatus(method string, assets ...string) ([]DepositS
return response, nil
}

// WithdrawFunds - returns withdrawal response
func (api *Kraken) WithdrawFunds(asset string, key string, amount float64) (response WithdrawFunds, err error) {
data := url.Values{
"asset": {asset},
"key": {key},
"amount": {strconv.FormatFloat(amount, 'f', 8, 64)},
}

if err = api.request("Withdraw", true, data, &response); err != nil {
return response, err
}
return response, nil
}

// GetWithdrawStatus - returns withdrawal statuses
func (api *Kraken) GetWithdrawStatus(asset string, method string) ([]WithdrawStatus, error) {
data := url.Values{}

if len(asset) > 0 {
data.Add("asset", asset)
}

if len(method) > 0 {
data.Add("method", method)
}

response := make([]WithdrawStatus, 0)
if err := api.request("WithdrawStatus", true, data, &response); err != nil {
return response, err
}
return response, nil
}

// QueryTrades - returns trades by IDs
func (api *Kraken) QueryTrades(trades bool, txIDs ...string) (map[string]PrivateTrade, error) {
data := url.Values{}
Expand Down
19 changes: 19 additions & 0 deletions rest/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,25 @@ type DepositStatuses struct {
Status string `json:"status"`
}

// WithdrawFunds - response on WithdrawFunds request
type WithdrawFunds struct {
RefID string `json:"refid"`
}

// GetWithdrawStatus - response on WithdrawStatus request
type WithdrawStatus struct {
Method string `json:"method,omitempty"`
AClass string `json:"a_class,omitempty"`
Asset string `json:"asset,omitempty"`
Refid string `json:"refid,omitempty"`
Txid string `json:"txid,omitempty"`
Info string `json:"info,omitempty"`
Amount string `json:"amount,omitempty"`
Fee string `json:"fee,omitempty"`
Time int `json:"time,omitempty"`
Status string `json:"status,omitempty"`
}

// PrivateTrade - structure of account's trades
type PrivateTrade struct {
OrderID string `json:"ordertxid"`
Expand Down

0 comments on commit 0f4ac5c

Please sign in to comment.