@@ -10,14 +10,17 @@ use corepc_types::{
1010 bitcoin:: {
1111 block:: Header , consensus:: encode:: deserialize_hex, Block , BlockHash , Transaction , Txid ,
1212 } ,
13- model:: { GetBlockCount , GetBlockFilter , GetBlockVerboseOne , GetRawMempool } ,
13+ model:: { GetBlockCount , GetBlockFilter , GetRawMempool } ,
1414} ;
1515use jsonrpc:: {
1616 serde,
1717 serde_json:: { self , json} ,
1818 Transport ,
1919} ;
2020
21+ #[ cfg( feature = "28_0" ) ]
22+ pub mod v28;
23+
2124/// Client authentication methods for the Bitcoin Core JSON-RPC server
2225#[ derive( Clone , Debug , Hash , Eq , PartialEq , Ord , PartialOrd ) ]
2326pub enum Auth {
@@ -142,21 +145,6 @@ impl Client {
142145 Ok ( block)
143146 }
144147
145- /// Retrieves the verbose JSON representation of a block (verbosity 1)
146- ///
147- /// # Arguments
148- /// * `block_hash`: The hash of the block to retrieve.
149- ///
150- /// # Returns
151- /// The verbose block data as a `GetBlockVerboseOne` struct.
152- pub fn get_block_verbose ( & self , block_hash : & BlockHash ) -> Result < GetBlockVerboseOne , Error > {
153- let block: corepc_types:: v30:: GetBlockVerboseOne =
154- self . call ( "getblock" , & [ json ! ( block_hash) , json ! ( 1 ) ] ) ?;
155- let block_model = block. into_model ( ) ?;
156-
157- Ok ( block_model)
158- }
159-
160148 /// Retrieves the hash of the tip of the best block chain.
161149 ///
162150 /// # Returns
@@ -238,6 +226,52 @@ impl Client {
238226 }
239227}
240228
229+ #[ cfg( not( feature = "28_0" ) ) ]
230+ use corepc_types:: {
231+ model:: { GetBlockHeaderVerbose , GetBlockVerboseOne } ,
232+ v30,
233+ } ;
234+
235+ #[ cfg( not( feature = "28_0" ) ) ]
236+ impl Client {
237+ /// Retrieves the verbose JSON representation of a block header (verbosity 1).
238+ ///
239+ /// # Arguments
240+ ///
241+ /// * `block_hash`: The hash of the block to retrieve.
242+ ///
243+ /// # Returns
244+ ///
245+ /// The verbose header as a `GetBlockHeaderVerbose` struct.
246+ pub fn get_block_header_verbose (
247+ & self ,
248+ hash : & BlockHash ,
249+ ) -> Result < GetBlockHeaderVerbose , Error > {
250+ let header_info: v30:: GetBlockHeaderVerbose =
251+ self . call ( "getblockheader" , & [ json ! ( hash) ] ) ?;
252+ header_info
253+ . into_model ( )
254+ . map_err ( Error :: GetBlockHeaderVerboseError )
255+ }
256+
257+ /// Retrieves the verbose JSON representation of a block (verbosity 1).
258+ ///
259+ /// # Arguments
260+ ///
261+ /// * `block_hash`: The hash of the block to retrieve.
262+ ///
263+ /// # Returns
264+ ///
265+ /// The verbose block data as a `GetBlockVerboseOne` struct.
266+ pub fn get_block_verbose ( & self , hash : & BlockHash ) -> Result < GetBlockVerboseOne , Error > {
267+ let block_info: v30:: GetBlockVerboseOne =
268+ self . call ( "getblock" , & [ json ! ( hash) , json ! ( 1 ) ] ) ?;
269+ block_info
270+ . into_model ( )
271+ . map_err ( Error :: GetBlockVerboseOneError )
272+ }
273+ }
274+
241275#[ cfg( test) ]
242276mod test_auth {
243277 use super :: * ;
0 commit comments