Skip to content

Commit

Permalink
implement get_block_txs
Browse files Browse the repository at this point in the history
  • Loading branch information
mplsgrant committed Jan 17, 2024
1 parent 1b51e3d commit e548199
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ pub trait RpcApi: Sized {
fn get_block_info(&self, hash: &bitcoin::BlockHash) -> Result<json::GetBlockResult> {
self.call("getblock", &[into_json(hash)?, 1.into()])
}
//TODO(stevenroose) add getblock_txs

fn get_block_txs(&self, hash: &bitcoin::BlockHash) -> Result<json::GetBlockTxsResult> {
self.call("getblock", &[into_json(hash)?, 3.into()])
}

fn get_block_header(&self, hash: &bitcoin::BlockHash) -> Result<bitcoin::block::Header> {
let hex: String = self.call("getblockheader", &[into_json(hash)?, false.into()])?;
Expand Down
26 changes: 26 additions & 0 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,32 @@ pub struct GetBlockResult {
pub nextblockhash: Option<bitcoin::BlockHash>,
}

#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetBlockTxsResult {
pub hash: bitcoin::BlockHash,
pub confirmations: i32,
pub size: usize,
pub strippedsize: Option<usize>,
pub weight: usize,
pub height: usize,
pub version: i32,
#[serde(default, with = "crate::serde_hex::opt")]
pub version_hex: Option<Vec<u8>>,
pub merkleroot: bitcoin::hash_types::TxMerkleNode,
pub tx: Vec<GetRawTransactionResult>,
pub time: usize,
pub mediantime: Option<usize>,
pub nonce: u32,
pub bits: String,
pub difficulty: f64,
#[serde(with = "crate::serde_hex")]
pub chainwork: Vec<u8>,
pub n_tx: usize,
pub previousblockhash: Option<bitcoin::BlockHash>,
pub nextblockhash: Option<bitcoin::BlockHash>,
}

#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetBlockHeaderResult {
Expand Down

0 comments on commit e548199

Please sign in to comment.