bitcoin_rpc_json/blockchain.rs
1//! Blockchain related RPC result types.
2
3use strason::Json;
4
5/// Models the result of "waitfornewblock", and "waitforblock"
6#[derive(Debug, Clone, Deserialize, Serialize)]
7pub struct BlockRef {
8 // TODO: Use Sha256dHash
9 pub hash: String,
10 pub height: u64,
11}
12
13/// Models the result of "getblockchaininfo"
14#[derive(Debug, Clone, Deserialize, Serialize)]
15pub struct BlockchainInfo {
16 // TODO: Use Network from rust-bitcoin
17 /// Current network name as defined in BIP70 (main, test, regtest)
18 pub chain: String,
19 /// The current number of blocks processed in the server
20 pub blocks: u64,
21 /// The current number of headers we have validated
22 pub headers: u64,
23 // TODO: Use Sha256dHash from rust-bitcoin
24 /// The hash of the currently best block
25 pub bestblockhash: String,
26 /// The current difficulty
27 pub difficulty: u64,
28 /// Median time for the current best block
29 pub mediantime: u64,
30 /// Estimate of verification progress [0..1]
31 pub verificationprogress: f64,
32 /// Estimate of whether this node is in Initial Block Download mode
33 pub initialblockdownload: bool,
34 /// Total amount of work in active chain, in hexadecimal
35 pub chainwork: String,
36 /// The estimated size of the block and undo files on disk
37 pub size_on_disk: u64,
38 /// If the blocks are subject to pruning
39 pub pruned: bool,
40 /// Lowest-height complete block stored (only present if pruning is enabled)
41 pub pruneheight: u64,
42 /// Whether automatic pruning is enabled (only present if pruning is enabled)
43 pub automatic_pruning: bool,
44 /// The target size used by pruning (only present if automatic pruning is enabled)
45 pub prune_target_size: u64,
46 /// Status of softforks in progress
47 pub softforks: Vec<Softfork>,
48 // TODO: add a type?
49 /// Status of BIP9 softforks in progress
50 pub bip9_softforks: Json,
51 /// Any network and blockchain warnings.
52 pub warnings: String,
53}
54
55/// Status of a softfork
56#[derive(Debug, Clone, Deserialize, Serialize)]
57pub struct Softfork {
58 /// Name of softfork
59 pub id: String,
60 /// Block version
61 pub version: u64,
62 /// Progress toward rejecting pre-softfork blocks
63 pub reject: RejectStatus,
64}
65
66/// Progress toward rejecting pre-softfork blocks
67#[derive(Debug, Clone, Deserialize, Serialize)]
68pub struct RejectStatus {
69 /// `true` if threshold reached
70 pub status: bool,
71}