Repository navigation
Expand file tree
/
Copy pathaddress.go
More file actions
84 lines (73 loc) · 1.96 KB
/
Copy pathaddress.go
File metadata and controls
84 lines (73 loc) · 1.96 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package blockchain
import (
"fmt"
"strings"
)
type Address struct {
Hash160 string `json:"hash160"`
Address string `json:"address"`
NTx int `json:"n_tx"`
TotalReceived int `json:"total_received"`
TotalSent int `json:"total_sent"`
FinalBalance int `json:"final_balance"`
Txs []*Tx `json:"txs"`
}
type MultiAddr struct {
Addresses []*Address `json:"addresses"`
Txs []*Tx `json:"txs"`
}
type Tx struct {
Result int `json:"result"`
Ver int `json:"ver"`
Size int `json:"size"`
Inputs []*Inputs `json:"inputs"`
Time int `json:"time"`
BlockHeight int `json:"block_height"`
TxIndex int `json:"tx_index"`
VinSz int `json:"vin_sz"`
Hash string `json:"hash"`
VoutSz int `json:"vout_sz"`
RelayedBy string `json:"relayed_by"`
Out []*Out `json:"out"`
}
type Inputs struct {
Sequence int `json:"sequence"`
Script string `json:"script"`
PrevOut *PrevOut `json:"prev_out"`
}
type PrevOut struct {
Spent bool `json:"spent"`
TxIndex int `json:"tx_index"`
Type int `json:"type"`
Addr string `json:"addr"`
Value int `json:"value"`
N int `json:"n"`
Script string `json:"script"`
}
type Out struct {
Spent bool `json:"spent"`
TxIndex int `json:"tx_index"`
Type int `json:"type"`
Addr string `json:"addr"`
Value int `json:"value"`
N int `json:"n"`
Script string `json:"script"`
}
func (c *Client) GetAddress(address string) (*Address, error) {
rsp := &Address{}
var path = "/address/" + address
e := c.loadResponse(path, rsp, true)
if e != nil {
fmt.Print(e)
}
return rsp, e
}
func (c *Client) GetAddresses(addresses []string) (*MultiAddr, error) {
rsp := &MultiAddr{}
var path = "/multiaddr?active=" + strings.Join(addresses, "|")
e := c.loadResponse(path, rsp, false)
if e != nil {
fmt.Print(e)
}
return rsp, e
}