forked from alfg/blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction.go
45 lines (38 loc) · 1 KB
/
transaction.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
package blockchain
import (
"fmt"
)
type Transaction struct {
Hash string `json:"hash"`
Ver int `json:"ver"`
VinSz int `json:"vin_sz"`
VoutSz int `json:"vout_sz"`
LockTime int `json:"lock_time"`
Size int `json:"size"`
RelayedBy string `json:"relayed_by"`
BlockHeight int `json:"block_height"`
TxIndex int `json:"tx_index"`
Inputs []*Inputs `json:"inputs"`
Out []*Out `json:"out"`
}
type Transactions struct {
Transactions []*Transaction `json:"txs"`
}
func (c *Client) GetTransaction(transaction string) (*Transaction, error) {
rsp := &Transaction{}
var path = "/rawtx/" + transaction
e := c.loadResponse(path, rsp, false)
if e != nil {
fmt.Print(e)
}
return rsp, e
}
func (c *Client) GetUnconfirmedTransactions() (*Transactions, error) {
rsp := &Transactions{}
var path = "/unconfirmed-transactions"
e := c.loadResponse(path, rsp, true)
if e != nil {
fmt.Print(e)
}
return rsp, e
}