forked from bitfinexcom/bitfinex-api-go
/
deposit.go
46 lines (36 loc) · 819 Bytes
/
deposit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package bitfinex
import "errors"
type DepositService struct {
client *Client
}
type DepositResponse struct {
Result string
Method string
Currency string
Address string
}
func (d *DepositResponse) Success() (bool, error) {
if d.Result == "success" {
return true, nil
} else {
err := errors.New(d.Address)
return false, err
}
}
func (s *DepositService) New(method, walletName string, renew int) (DepositResponse, error) {
payload := map[string]interface{}{
"method": method,
"wallet_name": walletName,
"renew": renew,
}
req, err := s.client.newAuthenticatedRequest("POST", "deposit/new", payload)
if err != nil {
return DepositResponse{}, err
}
var v DepositResponse
_, err = s.client.do(req, &v)
if err != nil {
return DepositResponse{}, err
}
return v, nil
}