-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdefinitions.go
398 lines (339 loc) · 13.3 KB
/
definitions.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
package whatsonchain
// NetworkType is used internally to represent the possible values
// for network in queries to be submitted: {"main", "test", "stn"}
type NetworkType string
const (
// NetworkMain is for main-net
NetworkMain NetworkType = "main"
// NetworkTest is for test-net
NetworkTest NetworkType = "test"
// NetworkStn is for the stn-net
NetworkStn NetworkType = "stn"
// MaxTransactionsUTXO is the max allowed in the request
MaxTransactionsUTXO int = 20
// MaxTransactionsRaw is the max allowed in the request
MaxTransactionsRaw int = 20
// MaxBroadcastTransactions is the max transactions for Bulk Broadcast
MaxBroadcastTransactions = 100
// MaxSingleTransactionSize is the max single TX size for Bulk Broadcast
MaxSingleTransactionSize = 102400
// MaxCombinedTransactionSize is the max of all transactions combined
MaxCombinedTransactionSize = 1e+7
// MaxAddressesForLookup is the max allowed in the request for Bulk requests
MaxAddressesForLookup int = 20
// MaxScriptsForLookup is the max allowed in the request for Bulk requests
MaxScriptsForLookup int = 20
)
// AddressInfo is the address info for a returned address request
type AddressInfo struct {
Address string `json:"address"`
IsMine bool `json:"ismine"`
IsScript bool `json:"isscript"`
IsValid bool `json:"isvalid"`
IsWatchOnly bool `json:"iswatchonly"`
ScriptPubKey string `json:"scriptPubKey"`
}
// AddressBalance is the address balance (unconfirmed and confirmed)
type AddressBalance struct {
Confirmed int64 `json:"confirmed"`
Unconfirmed int64 `json:"unconfirmed"`
}
// AddressBalanceRecord is the result from Bulk Balance request
type AddressBalanceRecord struct {
Address string `json:"address"`
Error string `json:"error"`
Balance *AddressBalance `json:"balance"`
}
// AddressList is used to create a Bulk Balance request
type AddressList struct {
Addresses []string `json:"addresses"`
}
// AddressBalances is the response from Bulk Balance request
type AddressBalances []*AddressBalanceRecord
// AddressHistory is the history of transactions for an address
type AddressHistory []*HistoryRecord
// BlockInfo is the response info about a returned block
type BlockInfo struct {
Bits string `json:"bits"`
ChainWork string `json:"chainwork"`
CoinbaseTx CoinbaseTxInfo `json:"coinbaseTx"`
Confirmations int64 `json:"confirmations"`
Difficulty float64 `json:"difficulty"`
Hash string `json:"hash"`
Height int64 `json:"height"`
MedianTime int64 `json:"mediantime"`
MerkleRoot string `json:"merkleroot"`
Miner string `json:"Bmgpool"`
NextBlockHash string `json:"nextblockhash"`
Nonce int64 `json:"nonce"`
Pages Page `json:"pages"`
PreviousBlockHash string `json:"previousblockhash"`
Size int64 `json:"size"`
Time int64 `json:"time"`
TotalFees float64 `json:"totalFees"`
Tx []string `json:"tx"`
TxCount int64 `json:"txcount"`
Version int64 `json:"version"`
VersionHex string `json:"versionHex"`
}
// BlockPagesInfo is the response from the page request
type BlockPagesInfo []string
// BulkBroadcastResponse is the response from a bulk broadcast request
type BulkBroadcastResponse struct {
Feedback bool `json:"feedback"`
StatusURL string `json:"statusUrl"`
}
// BulkUnspentResponse is the response from Bulk Unspent transactions
type BulkUnspentResponse []*BulkResponseRecord
// BulkResponseRecord is the record in the results for Bulk Unspent transactions
type BulkResponseRecord struct {
Address string `json:"address"`
Error string `json:"error"`
Utxos []*HistoryRecord `json:"unspent"`
}
// BulkScriptUnspentResponse is the response from Bulk Unspent transactions
type BulkScriptUnspentResponse []*BulkScriptResponseRecord
// BulkScriptResponseRecord is the record in the results for Bulk Unspent transactions
type BulkScriptResponseRecord struct {
Script string `json:"script"`
Error string `json:"error"`
Utxos []*HistoryRecord `json:"unspent"`
}
// ChainInfo is the structure response from getting info about the chain
type ChainInfo struct {
BestBlockHash string `json:"bestblockhash"`
Blocks int64 `json:"blocks"`
Chain string `json:"chain"`
ChainWork string `json:"chainwork"`
Difficulty float64 `json:"difficulty"`
Headers int64 `json:"headers"`
MedianTime int64 `json:"mediantime"`
Pruned bool `json:"pruned"`
VerificationProgress float64 `json:"verificationprogress"`
}
// CirculatingSupply is the structure response
type CirculatingSupply float64
// CoinbaseTxInfo is the coinbase tx info inside the BlockInfo
type CoinbaseTxInfo struct {
BlockHash string `json:"blockhash"`
BlockTime int64 `json:"blocktime"`
Confirmations int64 `json:"confirmations"`
Hash string `json:"hash"`
Hex string `json:"hex"`
LockTime int64 `json:"locktime"`
Size int64 `json:"size"`
Time int64 `json:"time"`
TxID string `json:"txid"`
Version int64 `json:"version"`
Vin []VinInfo `json:"vin"`
Vout []VoutInfo `json:"vout"`
}
// ExchangeRate is the response from getting the current exchange rate
type ExchangeRate struct {
Currency string `json:"currency"`
Rate float64 `json:"rate"`
Time int64 `json:"time"`
}
// FeeQuote is the structure response for a fee in a quote
type FeeQuote struct {
FeeType string `json:"feeType"`
MiningFee *Fee `json:"miningFee"`
RelayFee *Fee `json:"relayFee"`
}
// Fee is the actual fee (satoshis per byte)
type Fee struct {
Bytes int `json:"bytes"`
Satoshis int `json:"satoshis"`
}
// FeeQuotes is the structure response from getting quotes from Merchant API
type FeeQuotes struct {
Quotes []*QuoteProvider `json:"quotes"`
}
// HistoryRecord is an internal record of AddressHistory
type HistoryRecord struct {
Height int64 `json:"height"`
Info *TxInfo `json:"info,omitempty"` // Custom for our wrapper
TxHash string `json:"tx_hash"`
TxPos int64 `json:"tx_pos"`
Value int64 `json:"value"`
}
// MempoolInfo is the response for the get mempool info request
type MempoolInfo struct {
Bytes int64 `json:"bytes"`
MaxMempool int64 `json:"maxmempool"`
MempoolMinFee int64 `json:"mempoolminfee"`
Size int64 `json:"size"`
Usage int64 `json:"usage"`
}
// MerkleResults is the results from the proof request
type MerkleResults []*MerkleInfo
// MerkleInfo is the response for the get merkle request
type MerkleInfo struct {
BlockHash string `json:"blockHash"`
Branches []*MerkleBranch `json:"branches"`
Hash string `json:"hash"`
MerkleRoot string `json:"merkleRoot"`
}
// MerkleBranch is a merkle branch
type MerkleBranch struct {
Hash string `json:"hash"`
Pos string `json:"pos"`
}
// MerkleTSCResults is the results from the tsc proof request
type MerkleTSCResults []*MerkleTSCInfo
// MerkleTSCInfo is the response for the get TSC merkle request
type MerkleTSCInfo struct {
Index int `json:"index"`
Nodes []string `json:"nodes"`
Target string `json:"target"`
TxOrID string `json:"txOrId"`
}
// MerchantResponse is the response from a tx submission
type MerchantResponse struct {
APIVersion string `json:"apiVersion"`
CurrentHighestBlockHash string `json:"currentHighestBlockHash"`
CurrentHighestBlockHeight int64 `json:"currentHighestBlockHeight"`
MinerID string `json:"minerId"`
ResultDescription string `json:"resultDescription"`
ReturnResult string `json:"returnResult"`
Timestamp string `json:"timestamp"`
TxID string `json:"txid"`
TxSecondMempoolExpiry int `json:"txSecondMempoolExpiry"`
}
// MerchantError is the error response from a bad tx submission
type MerchantError struct {
Code int `json:"code"`
Error string `json:"error"`
Status int `json:"status"`
}
// MerchantStatus is the response from a status request
type MerchantStatus struct {
APIVersion string `json:"apiVersion"`
BlockHash string `json:"blockHash"`
BlockHeight int64 `json:"blockHeight"`
Confirmations int64 `json:"confirmations"`
MinerID string `json:"minerId"`
ResultDescription string `json:"resultDescription"`
ReturnResult string `json:"returnResult"`
Timestamp string `json:"timestamp"`
TxSecondMempoolExpiry int `json:"txSecondMempoolExpiry"`
}
// Page is used as a subtype for BlockInfo
type Page struct {
Size int64 `json:"size"`
URI []string `json:"uri"`
}
// ScriptsList is used to create a Bulk UTXO request
type ScriptsList struct {
Scripts []string `json:"scripts"`
}
// ScriptList is the list of script history records
type ScriptList []*ScriptRecord
// ScriptRecord is the script history record
type ScriptRecord struct {
Height int64 `json:"height"`
TxHash string `json:"tx_hash"`
TxPos int64 `json:"tx_pos"`
Value int64 `json:"value"`
}
// ScriptSigInfo is the scriptSig info inside the VinInfo
type ScriptSigInfo struct {
Asm string `json:"asm"`
Hex string `json:"hex"`
}
// SearchResults is the response from searching for explorer links
type SearchResults struct {
Results []*SearchResult `json:"results"`
}
// SearchResult is the actual result for the search (included in SearchResults)
type SearchResult struct {
Type string `json:"type"`
URL string `json:"url"`
}
// ScriptPubKeyInfo is the scriptPubKey info inside the VoutInfo
type ScriptPubKeyInfo struct {
Addresses []string `json:"addresses"`
Asm string `json:"asm"`
Hex string `json:"hex"`
IsTruncated bool `json:"isTruncated"`
OpReturn string `json:"-"` // todo: support this (can be an object of key/vals based on the op return data)
ReqSigs int64 `json:"reqSigs"`
Type string `json:"type"`
}
// StatusResponse is the response from requesting a status update
type StatusResponse struct {
Payload string `json:"payload"`
ProviderID string `json:"providerId"`
ProviderName string `json:"providerName"`
PublicKey string `json:"publicKey"`
Signature string `json:"signature"`
Status *MerchantStatus `json:"status"`
}
// QuoteProvider is the structure response for a quote provider (which has quotes)
type QuoteProvider struct {
Payload string `json:"payload"`
ProviderID string `json:"providerId"`
ProviderName string `json:"providerName"`
PublicKey string `json:"publicKey"`
Quote *Quote `json:"quote"`
Signature string `json:"signature"`
TxStatusURL string `json:"txStatusUrl"`
TxSubmissionURL string `json:"txSubmissionUrl"`
}
// Quote is the structure response for a quote
type Quote struct {
APIVersion string `json:"apiVersion"`
CurrentHighestBlockHash string `json:"currentHighestBlockHash"`
CurrentHighestBlockHeight int64 `json:"currentHighestBlockHeight"`
ExpiryTime string `json:"expiryTime"`
Fees []*FeeQuote `json:"fees"`
MinerID string `json:"minerId"`
MinerReputation interface{} `json:"minerReputation"`
Timestamp string `json:"timestamp"`
}
// SubmissionResponse is the response from submitting a tx via Merchant API
type SubmissionResponse struct {
Error *MerchantError `json:"error"`
Payload string `json:"payload"`
ProviderID string `json:"providerId"`
ProviderName string `json:"providerName"`
PublicKey string `json:"publicKey"`
Response *MerchantResponse `json:"response"`
Signature string `json:"signature"`
}
// TxInfo is the response info about a returned tx
type TxInfo struct {
BlockHash string `json:"blockhash"`
BlockHeight int64 `json:"blockheight"`
BlockTime int64 `json:"blocktime"`
Confirmations int64 `json:"confirmations"`
Hash string `json:"hash"`
Hex string `json:"hex"`
LockTime int64 `json:"locktime"`
Size int64 `json:"size"`
Time int64 `json:"time"`
TxID string `json:"txid"`
Version int64 `json:"version"`
Vin []VinInfo `json:"vin"`
Vout []VoutInfo `json:"vout"`
}
// TxList is the list of tx info structs returned from the /txs post response
type TxList []*TxInfo
// TxHashes is the list of tx hashes for the post request
type TxHashes struct {
TxIDs []string `json:"txids"`
}
// VinInfo is the vin info inside the CoinbaseTxInfo
type VinInfo struct {
Coinbase string `json:"coinbase"`
ScriptSig ScriptSigInfo `json:"scriptSig"`
Sequence int64 `json:"sequence"`
TxID string `json:"txid"`
Vout int64 `json:"vout"`
}
// VoutInfo is the vout info inside the CoinbaseTxInfo
type VoutInfo struct {
N int64 `json:"n"`
ScriptPubKey ScriptPubKeyInfo `json:"scriptPubKey"`
Value float64 `json:"value"`
}