Skip to content

Commit

Permalink
change get_block_header_info() to return the additional info includin…
Browse files Browse the repository at this point in the history
…g coinbase and merkle_proof.
  • Loading branch information
Danconnolly committed Mar 7, 2024
1 parent 23bfa3d commit 094c43e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jsonrpc = { version = "0.16.0", features = ["minreq_http"]}
serde = "1"
serde_json = "1"
hex = "0.4.3"
bitcoinsv = "0.2.1"
bitcoinsv = "0.2.2"
async-trait = "0.1.75"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub trait RpcApi: Sized {

/// Returns the block header as a BlockHeader struct.
fn get_block_header(&self, hash: &BlockHash) -> Result<BlockHeader> {
let hex: String = self.call("getblockheader", &[into_json(hash)?, false.into()])?;
let hex: String = self.call("getblockheader", &[into_json(hash)?, 0.into()])?;
Ok(BlockHeader::from_hex(hex)?)
}

Expand All @@ -268,7 +268,7 @@ pub trait RpcApi: Sized {
&self,
hash: &BlockHash,
) -> Result<json::GetBlockHeaderResult> {
self.call("getblockheader", &[into_json(hash)?, true.into()])
self.call("getblockheader", &[into_json(hash)?, 2.into()])
}

/// Compute per block statistics for a given window.
Expand Down
2 changes: 1 addition & 1 deletion json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ path = "src/lib.rs"
hex = "0.4.3"
serde = { version = "1", features = [ "derive" ] }
serde_json = "1"
bitcoinsv = "0.2.1"
bitcoinsv = "0.2.2"

[dev-dependencies]
approx = "0.5"
6 changes: 5 additions & 1 deletion json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use std::fmt;
pub use bitcoinsv::Error;
pub use bitcoinsv::bitcoin::{BlockchainId, BlockHash, Encodable, MerkleRoot, Tx, TxHash};
pub use bitcoinsv::bitcoin::{BlockchainId, BlockHash, Encodable, Hash, MerkleRoot, Tx, TxHash};
pub use bitcoinsv::util::Amount;

/// A module used for serde serialization of bytes in hexadecimal format.
Expand Down Expand Up @@ -338,6 +338,10 @@ pub struct GetBlockHeaderResult {
#[serde(rename = "nextblockhash")]
pub next_block_hash: Option<BlockHash>,
pub status: GetBlockResultStatus,
#[serde(rename = "tx")]
pub coinbase_tx: GetRawTransactionResult,
#[serde(rename = "merkleproof")]
pub coinbase_merkle_proof: Vec<Hash>,
}

#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
Expand Down

0 comments on commit 094c43e

Please sign in to comment.