1 // Copyright (c) 2014-2017 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
9 // GetBlockHeaderVerboseResult models the data from the getblockheader command when
10 // the verbose flag is set. When the verbose flag is not set, getblockheader
11 // returns a hex-encoded string.
12 type GetBlockHeaderVerboseResult struct {
13 Hash string `json:"hash"`
14 Confirmations uint64 `json:"confirmations"`
15 Height int32 `json:"height"`
16 Version int32 `json:"version"`
17 VersionHex string `json:"versionHex"`
18 MerkleRoot string `json:"merkleroot"`
19 Time int64 `json:"time"`
20 Nonce uint64 `json:"nonce"`
21 Bits string `json:"bits"`
22 Difficulty float64 `json:"difficulty"`
23 PreviousHash string `json:"previousblockhash,omitempty"`
24 NextHash string `json:"nextblockhash,omitempty"`
27 // GetBlockVerboseResult models the data from the getblock command when the
28 // verbose flag is set. When the verbose flag is not set, getblock returns a
29 // hex-encoded string.
30 type GetBlockVerboseResult struct {
31 Hash string `json:"hash"`
32 Confirmations uint64 `json:"confirmations"`
33 StrippedSize int32 `json:"strippedsize"`
34 Size int32 `json:"size"`
35 Weight int32 `json:"weight"`
36 Height int64 `json:"height"`
37 Version int32 `json:"version"`
38 VersionHex string `json:"versionHex"`
39 MerkleRoot string `json:"merkleroot"`
40 Tx []string `json:"tx,omitempty"`
41 RawTx []TxRawResult `json:"rawtx,omitempty"`
42 Time int64 `json:"time"`
43 Nonce uint32 `json:"nonce"`
44 Bits string `json:"bits"`
45 Difficulty float64 `json:"difficulty"`
46 PreviousHash string `json:"previousblockhash"`
47 NextHash string `json:"nextblockhash,omitempty"`
50 // CreateMultiSigResult models the data returned from the createmultisig
52 type CreateMultiSigResult struct {
53 Address string `json:"address"`
54 RedeemScript string `json:"redeemScript"`
57 // DecodeScriptResult models the data returned from the decodescript command.
58 type DecodeScriptResult struct {
59 Asm string `json:"asm"`
60 ReqSigs int32 `json:"reqSigs,omitempty"`
61 Type string `json:"type"`
62 Addresses []string `json:"addresses,omitempty"`
63 P2sh string `json:"p2sh,omitempty"`
66 // GetAddedNodeInfoResultAddr models the data of the addresses portion of the
67 // getaddednodeinfo command.
68 type GetAddedNodeInfoResultAddr struct {
69 Address string `json:"address"`
70 Connected string `json:"connected"`
73 // GetAddedNodeInfoResult models the data from the getaddednodeinfo command.
74 type GetAddedNodeInfoResult struct {
75 AddedNode string `json:"addednode"`
76 Connected *bool `json:"connected,omitempty"`
77 Addresses *[]GetAddedNodeInfoResultAddr `json:"addresses,omitempty"`
80 // SoftForkDescription describes the current state of a soft-fork which was
81 // deployed using a super-majority block signalling.
82 type SoftForkDescription struct {
84 Version uint32 `json:"version"`
86 Status bool `json:"status"`
90 // Bip9SoftForkDescription describes the current state of a defined BIP0009
91 // version bits soft-fork.
92 type Bip9SoftForkDescription struct {
93 Status string `json:"status"`
94 Bit uint8 `json:"bit"`
95 StartTime int64 `json:"startTime"`
96 Timeout int64 `json:"timeout"`
97 Since int32 `json:"since"`
100 // GetBlockChainInfoResult models the data returned from the getblockchaininfo
102 type GetBlockChainInfoResult struct {
103 Chain string `json:"chain"`
104 Blocks int32 `json:"blocks"`
105 Headers int32 `json:"headers"`
106 BestBlockHash string `json:"bestblockhash"`
107 Difficulty float64 `json:"difficulty"`
108 MedianTime int64 `json:"mediantime"`
109 VerificationProgress float64 `json:"verificationprogress,omitempty"`
110 Pruned bool `json:"pruned"`
111 PruneHeight int32 `json:"pruneheight,omitempty"`
112 ChainWork string `json:"chainwork,omitempty"`
113 SoftForks []*SoftForkDescription `json:"softforks"`
114 Bip9SoftForks map[string]*Bip9SoftForkDescription `json:"bip9_softforks"`
117 // GetBlockTemplateResultTx models the transactions field of the
118 // getblocktemplate command.
119 type GetBlockTemplateResultTx struct {
120 Data string `json:"data"`
121 Hash string `json:"hash"`
122 Depends []int64 `json:"depends"`
123 Fee int64 `json:"fee"`
124 SigOps int64 `json:"sigops"`
125 Weight int64 `json:"weight"`
128 // GetBlockTemplateResultAux models the coinbaseaux field of the
129 // getblocktemplate command.
130 type GetBlockTemplateResultAux struct {
131 Flags string `json:"flags"`
134 // GetBlockTemplateResult models the data returned from the getblocktemplate
136 type GetBlockTemplateResult struct {
137 // Base fields from BIP 0022. CoinbaseAux is optional. One of
138 // CoinbaseTxn or CoinbaseValue must be specified, but not both.
139 Bits string `json:"bits"`
140 CurTime int64 `json:"curtime"`
141 Height int64 `json:"height"`
142 PreviousHash string `json:"previousblockhash"`
143 SigOpLimit int64 `json:"sigoplimit,omitempty"`
144 SizeLimit int64 `json:"sizelimit,omitempty"`
145 WeightLimit int64 `json:"weightlimit,omitempty"`
146 Transactions []GetBlockTemplateResultTx `json:"transactions"`
147 Version int32 `json:"version"`
148 CoinbaseAux *GetBlockTemplateResultAux `json:"coinbaseaux,omitempty"`
149 CoinbaseTxn *GetBlockTemplateResultTx `json:"coinbasetxn,omitempty"`
150 CoinbaseValue *int64 `json:"coinbasevalue,omitempty"`
151 WorkID string `json:"workid,omitempty"`
153 // Witness commitment defined in BIP 0141.
154 DefaultWitnessCommitment string `json:"default_witness_commitment,omitempty"`
156 // Optional long polling from BIP 0022.
157 LongPollID string `json:"longpollid,omitempty"`
158 LongPollURI string `json:"longpolluri,omitempty"`
159 SubmitOld *bool `json:"submitold,omitempty"`
161 // Basic pool extension from BIP 0023.
162 Target string `json:"target,omitempty"`
163 Expires int64 `json:"expires,omitempty"`
165 // Mutations from BIP 0023.
166 MaxTime int64 `json:"maxtime,omitempty"`
167 MinTime int64 `json:"mintime,omitempty"`
168 Mutable []string `json:"mutable,omitempty"`
169 NonceRange string `json:"noncerange,omitempty"`
171 // Block proposal from BIP 0023.
172 Capabilities []string `json:"capabilities,omitempty"`
173 RejectReasion string `json:"reject-reason,omitempty"`
176 // GetMempoolEntryResult models the data returned from the getmempoolentry
178 type GetMempoolEntryResult struct {
179 Size int32 `json:"size"`
180 Fee float64 `json:"fee"`
181 ModifiedFee float64 `json:"modifiedfee"`
182 Time int64 `json:"time"`
183 Height int64 `json:"height"`
184 StartingPriority float64 `json:"startingpriority"`
185 CurrentPriority float64 `json:"currentpriority"`
186 DescendantCount int64 `json:"descendantcount"`
187 DescendantSize int64 `json:"descendantsize"`
188 DescendantFees float64 `json:"descendantfees"`
189 AncestorCount int64 `json:"ancestorcount"`
190 AncestorSize int64 `json:"ancestorsize"`
191 AncestorFees float64 `json:"ancestorfees"`
192 Depends []string `json:"depends"`
195 // GetMempoolInfoResult models the data returned from the getmempoolinfo
197 type GetMempoolInfoResult struct {
198 Size int64 `json:"size"`
199 Bytes int64 `json:"bytes"`
202 // NetworksResult models the networks data from the getnetworkinfo command.
203 type NetworksResult struct {
204 Name string `json:"name"`
205 Limited bool `json:"limited"`
206 Reachable bool `json:"reachable"`
207 Proxy string `json:"proxy"`
208 ProxyRandomizeCredentials bool `json:"proxy_randomize_credentials"`
211 // LocalAddressesResult models the localaddresses data from the getnetworkinfo
213 type LocalAddressesResult struct {
214 Address string `json:"address"`
215 Port uint16 `json:"port"`
216 Score int32 `json:"score"`
219 // GetNetworkInfoResult models the data returned from the getnetworkinfo
221 type GetNetworkInfoResult struct {
222 Version int32 `json:"version"`
223 SubVersion string `json:"subversion"`
224 ProtocolVersion int32 `json:"protocolversion"`
225 LocalServices string `json:"localservices"`
226 LocalRelay bool `json:"localrelay"`
227 TimeOffset int64 `json:"timeoffset"`
228 Connections int32 `json:"connections"`
229 NetworkActive bool `json:"networkactive"`
230 Networks []NetworksResult `json:"networks"`
231 RelayFee float64 `json:"relayfee"`
232 IncrementalFee float64 `json:"incrementalfee"`
233 LocalAddresses []LocalAddressesResult `json:"localaddresses"`
234 Warnings string `json:"warnings"`
237 // GetPeerInfoResult models the data returned from the getpeerinfo command.
238 type GetPeerInfoResult struct {
240 Addr string `json:"addr"`
241 AddrLocal string `json:"addrlocal,omitempty"`
242 Services string `json:"services"`
243 RelayTxes bool `json:"relaytxes"`
244 LastSend int64 `json:"lastsend"`
245 LastRecv int64 `json:"lastrecv"`
246 BytesSent uint64 `json:"bytessent"`
247 BytesRecv uint64 `json:"bytesrecv"`
248 ConnTime int64 `json:"conntime"`
249 TimeOffset int64 `json:"timeoffset"`
250 PingTime float64 `json:"pingtime"`
251 PingWait float64 `json:"pingwait,omitempty"`
252 Version uint32 `json:"version"`
253 SubVer string `json:"subver"`
254 Inbound bool `json:"inbound"`
255 StartingHeight int32 `json:"startingheight"`
256 CurrentHeight int32 `json:"currentheight,omitempty"`
257 BanScore int32 `json:"banscore"`
258 FeeFilter int64 `json:"feefilter"`
259 SyncNode bool `json:"syncnode"`
262 // GetRawMempoolVerboseResult models the data returned from the getrawmempool
263 // command when the verbose flag is set. When the verbose flag is not set,
264 // getrawmempool returns an array of transaction hashes.
265 type GetRawMempoolVerboseResult struct {
266 Size int32 `json:"size"`
267 Vsize int32 `json:"vsize"`
268 Fee float64 `json:"fee"`
269 Time int64 `json:"time"`
270 Height int64 `json:"height"`
271 StartingPriority float64 `json:"startingpriority"`
272 CurrentPriority float64 `json:"currentpriority"`
273 Depends []string `json:"depends"`
276 // ScriptPubKeyResult models the scriptPubKey data of a tx script. It is
277 // defined separately since it is used by multiple commands.
278 type ScriptPubKeyResult struct {
279 Asm string `json:"asm"`
280 Hex string `json:"hex,omitempty"`
281 ReqSigs int32 `json:"reqSigs,omitempty"`
282 Type string `json:"type"`
283 Addresses []string `json:"addresses,omitempty"`
286 // GetTxOutResult models the data from the gettxout command.
287 type GetTxOutResult struct {
288 BestBlock string `json:"bestblock"`
289 Confirmations int64 `json:"confirmations"`
290 Value float64 `json:"value"`
291 ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"`
292 Version int32 `json:"version"`
293 Coinbase bool `json:"coinbase"`
296 // GetNetTotalsResult models the data returned from the getnettotals command.
297 type GetNetTotalsResult struct {
298 TotalBytesRecv uint64 `json:"totalbytesrecv"`
299 TotalBytesSent uint64 `json:"totalbytessent"`
300 TimeMillis int64 `json:"timemillis"`
303 // ScriptSig models a signature script. It is defined separately since it only
304 // applies to non-coinbase. Therefore the field in the Vin structure needs
306 type ScriptSig struct {
307 Asm string `json:"asm"`
308 Hex string `json:"hex"`
311 // Vin models parts of the tx data. It is defined separately since
312 // getrawtransaction, decoderawtransaction, and searchrawtransaction use the
315 Coinbase string `json:"coinbase"`
316 Txid string `json:"txid"`
317 Vout uint32 `json:"vout"`
318 ScriptSig *ScriptSig `json:"scriptSig"`
319 Sequence uint32 `json:"sequence"`
320 Witness []string `json:"txinwitness"`
323 // IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.
324 func (v *Vin) IsCoinBase() bool {
325 return len(v.Coinbase) > 0
328 // HasWitness returns a bool to show if a Vin has any witness data associated
330 func (v *Vin) HasWitness() bool {
331 return len(v.Witness) > 0
334 // MarshalJSON provides a custom Marshal method for Vin.
335 func (v *Vin) MarshalJSON() ([]byte, error) {
337 coinbaseStruct := struct {
338 Coinbase string `json:"coinbase"`
339 Sequence uint32 `json:"sequence"`
340 Witness []string `json:"witness,omitempty"`
342 Coinbase: v.Coinbase,
343 Sequence: v.Sequence,
346 return json.Marshal(coinbaseStruct)
351 Txid string `json:"txid"`
352 Vout uint32 `json:"vout"`
353 ScriptSig *ScriptSig `json:"scriptSig"`
354 Witness []string `json:"txinwitness"`
355 Sequence uint32 `json:"sequence"`
359 ScriptSig: v.ScriptSig,
361 Sequence: v.Sequence,
363 return json.Marshal(txStruct)
367 Txid string `json:"txid"`
368 Vout uint32 `json:"vout"`
369 ScriptSig *ScriptSig `json:"scriptSig"`
370 Sequence uint32 `json:"sequence"`
374 ScriptSig: v.ScriptSig,
375 Sequence: v.Sequence,
377 return json.Marshal(txStruct)
380 // PrevOut represents previous output for an input Vin.
381 type PrevOut struct {
382 Addresses []string `json:"addresses,omitempty"`
383 Value float64 `json:"value"`
386 // VinPrevOut is like Vin except it includes PrevOut. It is used by searchrawtransaction
387 type VinPrevOut struct {
388 Coinbase string `json:"coinbase"`
389 Txid string `json:"txid"`
390 Vout uint32 `json:"vout"`
391 ScriptSig *ScriptSig `json:"scriptSig"`
392 Witness []string `json:"txinwitness"`
393 PrevOut *PrevOut `json:"prevOut"`
394 Sequence uint32 `json:"sequence"`
397 // IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.
398 func (v *VinPrevOut) IsCoinBase() bool {
399 return len(v.Coinbase) > 0
402 // HasWitness returns a bool to show if a Vin has any witness data associated
404 func (v *VinPrevOut) HasWitness() bool {
405 return len(v.Witness) > 0
408 // MarshalJSON provides a custom Marshal method for VinPrevOut.
409 func (v *VinPrevOut) MarshalJSON() ([]byte, error) {
411 coinbaseStruct := struct {
412 Coinbase string `json:"coinbase"`
413 Sequence uint32 `json:"sequence"`
415 Coinbase: v.Coinbase,
416 Sequence: v.Sequence,
418 return json.Marshal(coinbaseStruct)
423 Txid string `json:"txid"`
424 Vout uint32 `json:"vout"`
425 ScriptSig *ScriptSig `json:"scriptSig"`
426 Witness []string `json:"txinwitness"`
427 PrevOut *PrevOut `json:"prevOut,omitempty"`
428 Sequence uint32 `json:"sequence"`
432 ScriptSig: v.ScriptSig,
435 Sequence: v.Sequence,
437 return json.Marshal(txStruct)
441 Txid string `json:"txid"`
442 Vout uint32 `json:"vout"`
443 ScriptSig *ScriptSig `json:"scriptSig"`
444 PrevOut *PrevOut `json:"prevOut,omitempty"`
445 Sequence uint32 `json:"sequence"`
449 ScriptSig: v.ScriptSig,
451 Sequence: v.Sequence,
453 return json.Marshal(txStruct)
456 // Vout models parts of the tx data. It is defined separately since both
457 // getrawtransaction and decoderawtransaction use the same structure.
459 Value float64 `json:"value"`
461 ScriptPubKey ScriptPubKeyResult `json:"scriptPubKey"`
464 // GetMiningInfoResult models the data from the getmininginfo command.
465 type GetMiningInfoResult struct {
466 Blocks int64 `json:"blocks"`
467 CurrentBlockSize uint64 `json:"currentblocksize"`
468 CurrentBlockWeight uint64 `json:"currentblockweight"`
469 CurrentBlockTx uint64 `json:"currentblocktx"`
470 Difficulty float64 `json:"difficulty"`
471 Errors string `json:"errors"`
472 Generate bool `json:"generate"`
473 GenProcLimit int32 `json:"genproclimit"`
474 HashesPerSec int64 `json:"hashespersec"`
475 NetworkHashPS int64 `json:"networkhashps"`
476 PooledTx uint64 `json:"pooledtx"`
477 TestNet bool `json:"testnet"`
480 // GetWorkResult models the data from the getwork command.
481 type GetWorkResult struct {
482 Data string `json:"data"`
483 Hash1 string `json:"hash1"`
484 Midstate string `json:"midstate"`
485 Target string `json:"target"`
488 // InfoChainResult models the data returned by the chain server getinfo command.
489 type InfoChainResult struct {
490 Version int32 `json:"version"`
491 ProtocolVersion int32 `json:"protocolversion"`
492 Blocks int32 `json:"blocks"`
493 TimeOffset int64 `json:"timeoffset"`
494 Connections int32 `json:"connections"`
495 Proxy string `json:"proxy"`
496 Difficulty float64 `json:"difficulty"`
497 TestNet bool `json:"testnet"`
498 RelayFee float64 `json:"relayfee"`
499 Errors string `json:"errors"`
502 // TxRawResult models the data from the getrawtransaction command.
503 type TxRawResult struct {
504 Hex string `json:"hex"`
505 Txid string `json:"txid"`
506 Hash string `json:"hash,omitempty"`
507 Size int32 `json:"size,omitempty"`
508 Vsize int32 `json:"vsize,omitempty"`
509 Version int32 `json:"version"`
510 LockTime uint32 `json:"locktime"`
511 Vin []Vin `json:"vin"`
512 Vout []Vout `json:"vout"`
513 BlockHash string `json:"blockhash,omitempty"`
514 Confirmations uint64 `json:"confirmations,omitempty"`
515 Time int64 `json:"time,omitempty"`
516 Blocktime int64 `json:"blocktime,omitempty"`
519 // SearchRawTransactionsResult models the data from the searchrawtransaction
521 type SearchRawTransactionsResult struct {
522 Hex string `json:"hex,omitempty"`
523 Txid string `json:"txid"`
524 Hash string `json:"hash"`
525 Size string `json:"size"`
526 Vsize string `json:"vsize"`
527 Version int32 `json:"version"`
528 LockTime uint32 `json:"locktime"`
529 Vin []VinPrevOut `json:"vin"`
530 Vout []Vout `json:"vout"`
531 BlockHash string `json:"blockhash,omitempty"`
532 Confirmations uint64 `json:"confirmations,omitempty"`
533 Time int64 `json:"time,omitempty"`
534 Blocktime int64 `json:"blocktime,omitempty"`
537 // TxRawDecodeResult models the data from the decoderawtransaction command.
538 type TxRawDecodeResult struct {
539 Txid string `json:"txid"`
540 Version int32 `json:"version"`
541 Locktime uint32 `json:"locktime"`
542 Vin []Vin `json:"vin"`
543 Vout []Vout `json:"vout"`
546 // ValidateAddressChainResult models the data returned by the chain server
547 // validateaddress command.
548 type ValidateAddressChainResult struct {
549 IsValid bool `json:"isvalid"`
550 Address string `json:"address,omitempty"`