/
insightapitypes.go
190 lines (170 loc) · 6.74 KB
/
insightapitypes.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// Copyright (c) 2017, Jonathan Chappelow
// See LICENSE for details.
package types
import (
"encoding/json"
"github.com/decred/dcrdata/v3/db/dbtypes"
)
// InsightAddress models an address transactions
//
type InsightAddress struct {
Address string `json:"address,omitempty"`
From int `json:"from"`
To int `json:"to"`
Transactions []InsightTx `json:"items,omitempty"`
}
// InsightAddressInfo models basic information
// about an address
type InsightAddressInfo struct {
Address string `json:"addrStr,omitempty"`
Balance float64 `json:"balance"`
BalanceSat int64 `json:"balanceSat"`
TotalReceived float64 `json:"totalReceived"`
TotalReceivedSat int64 `json:"totalReceivedSat"`
TotalSent float64 `json:"totalSent"`
TotalSentSat int64 `json:"totalSentSat"`
UnconfirmedBalance float64 `json:"unconfirmedBalance"`
UnconfirmedBalanceSat int64 `json:"unconfirmedBalanceSat"`
UnconfirmedTxAppearances int64 `json:"unconfirmedTxApperances"`
TxAppearances int64 `json:"txApperances"`
TransactionsID []string `json:"transactions,omitempty"`
}
// InsightRawTx contains the raw transaction string
// of a transaction
type InsightRawTx struct {
Rawtx string `json:"rawtx"`
}
// InsightMultiAddrsTx models multi address post data structure
type InsightMultiAddrsTx struct {
Addresses string `json:"addrs"`
From json.Number `json:"from,Number,omitempty"`
To json.Number `json:"to,Number,omitempty"`
NoAsm json.Number `json:"noAsm"`
NoScriptSig json.Number `json:"noScriptSig"`
NoSpent json.Number `json:"noSpent"`
}
type InsightMultiAddrsTxOutput struct {
TotalItems int64 `json:"totalItems"`
From int `json:"from"`
To int `json:"to"`
Items []InsightTx `json:"items"`
}
// InsightAddr models the multi address post data structure
type InsightAddr struct {
Addrs string `json:"addrs"`
}
// InsightPagination models basic pagination output
// for a result
type InsightPagination struct {
Next string `json:"next,omitempty"`
Prev string `json:"prev,omitempty"`
IsToday string `json:"isToday,omitempty"`
}
// AddressTxnOutput models an address transaction outputs
type AddressTxnOutput struct {
Address string `json:"address"`
TxnID string `json:"txid"`
Vout uint32 `json:"vout"`
BlockTime int64 `json:"ts,omitempty"`
ScriptPubKey string `json:"scriptPubKey"`
Height int64 `json:"height,omitempty"`
BlockHash string `json:"block_hash,omitempty"`
Amount float64 `json:"amount,omitempty"`
Atoms int64 `json:"atoms,omitempty"` // Not Required per Insight spec
Satoshis int64 `json:"satoshis,omitempty"`
Confirmations int64 `json:"confirmations"`
}
// SpendByFundingHash models a return from
// GetSpendDetailsByFundingHash
type SpendByFundingHash struct {
FundingTxVoutIndex uint32
SpendingTxVinIndex interface{}
SpendingTxHash interface{}
BlockHeight interface{}
}
type InsightTx struct {
Txid string `json:"txid,omitempty"`
Version int32 `json:"version,omitempty"`
Locktime uint32 `json:"locktime"`
IsCoinBase bool `json:"isCoinBase,omitempty"`
Vins []*InsightVin `json:"vin,omitempty"`
Vouts []*InsightVout `json:"vout,omitempty"`
Blockhash string `json:"blockhash,omitempty"`
Blockheight int64 `json:"blockheight"`
Confirmations int64 `json:"confirmations"`
Time int64 `json:"time,omitempty"`
Blocktime int64 `json:"blocktime,omitempty"`
ValueOut float64 `json:"valueOut,omitempty"`
Size uint32 `json:"size,omitempty"`
ValueIn float64 `json:"valueIn,omitempty"`
Fees float64 `json:"fees,omitempty"`
}
type InsightVin struct {
Txid string `json:"txid,omitempty"`
Vout uint32 `json:"vout,omitempty"`
Sequence uint32 `json:"sequence,omitempty"`
N int `json:"n"`
ScriptSig *InsightScriptSig `json:"scriptSig,omitempty"`
Addr string `json:"addr,omitempty"`
ValueSat int64 `json:"valueSat,omitempty"`
Value float64 `json:"value,omitempty"`
CoinBase string `json:"coinbase,omitempty"`
}
type InsightScriptSig struct {
Hex string `json:"hex,omitempty"`
Asm string `json:"asm,omitempty"`
}
type InsightVout struct {
Value float64 `json:"value"`
N uint32 `json:"n"`
ScriptPubKey InsightScriptPubKey `json:"scriptPubKey,omitempty"`
SpentTxID interface{} `json:"spentTxId"` // Insight requires null if unspent and spending TxID if spent
SpentIndex interface{} `json:"spentIndex"` // Insight requires null if unspent and Index if spent
SpentHeight interface{} `json:"spentHeight"` // Insight requires null if unspent and SpentHeight if spent
}
type InsightScriptPubKey struct {
Hex string `json:"hex,omitempty"`
Asm string `json:"asm,omitempty"`
Addresses []string `json:"addresses,omitempty"`
Type string `json:"type,omitempty"`
}
// InsightBlockResult models the data required by a block json return for
// Insight API
type InsightBlockResult struct {
Hash string `json:"hash"`
Confirmations int64 `json:"confirmations"`
Size int32 `json:"size"`
Height int64 `json:"height"`
Version int32 `json:"version"`
MerkleRoot string `json:"merkleroot"`
Tx []string `json:"tx,omitempty"`
Time int64 `json:"time"`
Nonce uint32 `json:"nonce"`
Bits string `json:"bits"`
Difficulty float64 `json:"difficulty"`
PreviousHash string `json:"previousblockhash"`
NextHash string `json:"nextblockhash,omitempty"`
Reward float64 `json:"reward"`
IsMainChain bool `json:"isMainChain"`
}
// InsightBlocksSummaryResult models data required by blocks json return for
// Insight API
type InsightBlocksSummaryResult struct {
Blocks []dbtypes.BlockDataBasic `json:"blocks"`
Length int `json:"length"`
Pagination struct {
Next string `json:"next"`
Prev string `json:"prev"`
CurrentTs int64 `json:"currentTs"`
Current string `json:"current"`
IsToday bool `json:"isToday"`
More bool `json:"more"`
MoreTs int64 `json:"moreTs,omitempty"`
} `json:"pagination"`
}
// InsightBlockAddrTxSummary models the data required by addrtx json return for
// Insight API
type InsightBlockAddrTxSummary struct {
PagesTotal int64 `json:"pagesTotal"`
Txs []InsightTx `json:"txs"`
}