From ec5da3f9130aaf1669c99c3368f22b414d5c25e7 Mon Sep 17 00:00:00 2001 From: mpls Date: Tue, 16 Jan 2024 19:05:22 -0600 Subject: [PATCH] implement get_block_txs --- client/src/client.rs | 5 ++++- json/src/lib.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/client/src/client.rs b/client/src/client.rs index e0d2570a..98411546 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -343,7 +343,10 @@ pub trait RpcApi: Sized { fn get_block_info(&self, hash: &bitcoin::BlockHash) -> Result { self.call("getblock", &[into_json(hash)?, 1.into()]) } - //TODO(stevenroose) add getblock_txs + + fn get_block_txs(&self, hash: &bitcoin::BlockHash) -> Result { + self.call("getblock", &[into_json(hash)?, 3.into()]) + } fn get_block_header(&self, hash: &bitcoin::BlockHash) -> Result { let hex: String = self.call("getblockheader", &[into_json(hash)?, false.into()])?; diff --git a/json/src/lib.rs b/json/src/lib.rs index 3574ef1b..1744e662 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -217,6 +217,32 @@ pub struct GetBlockResult { pub nextblockhash: Option, } +#[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, + pub weight: usize, + pub height: usize, + pub version: i32, + #[serde(default, with = "crate::serde_hex::opt")] + pub version_hex: Option>, + pub merkleroot: bitcoin::hash_types::TxMerkleNode, + pub tx: Vec, + pub time: usize, + pub mediantime: Option, + pub nonce: u32, + pub bits: String, + pub difficulty: f64, + #[serde(with = "crate::serde_hex")] + pub chainwork: Vec, + pub n_tx: usize, + pub previousblockhash: Option, + pub nextblockhash: Option, +} + #[derive(Clone, PartialEq, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct GetBlockHeaderResult {