-
Notifications
You must be signed in to change notification settings - Fork 1
/
transactions.go
51 lines (44 loc) · 1.38 KB
/
transactions.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
47
48
49
50
51
package insight
import (
"net/url"
"strconv"
)
type Input struct {
}
type ScriptPubKey struct {
Addresses []string `json:"addresses"`
}
type Output struct {
Value float64 `json:"value,string"`
N int `json:"n"`
ScriptPubKey *ScriptPubKey `json:"scriptPubKey,omitempty"`
}
type Transaction struct {
TxID string `json:"txid"`
Version int `json:"version"`
Locktime int64 `json:"locktime"`
Vin []*Input `json:"vin"`
Vout []*Output `json:"vout"`
Blockhash string `json:"blockhash"`
Blockheight int64 `json:"blockheight"`
Confirmations int64 `json:"confirmations"`
Time int64 `json:"time"`
BlockTime int64 `json:"blocktime"`
IsCoinbase bool `json:"isCoinbase"`
ValueOut float64 `json:"valueOut"`
ValueIn float64 `json:"valueIn,omitempty"`
Fees float64 `json:"fees,omitempty"`
Size int64 `json:"size"`
}
type TransactionsResponse struct {
PagesTotal int `json:"pagesTotal"`
Transactions []*Transaction `json:"txs"`
}
func (c *Client) TransactionsByBlock(block string, page int) (*TransactionsResponse, error) {
params := make(url.Values)
params.Add("block", block)
params.Add("pageNum", strconv.Itoa(page))
resp := &TransactionsResponse{}
err := c.doRequest("/txs", params, resp)
return resp, err
}