@@ -14,7 +14,7 @@ use std::iter::FromIterator;
1414use std:: path:: PathBuf ;
1515use std:: { fmt, result} ;
1616
17- use crate :: bitcoin;
17+ use crate :: { bitcoin, deserialize_hex } ;
1818use jsonrpc;
1919use serde;
2020use serde_json;
@@ -327,8 +327,7 @@ pub trait RpcApi: Sized {
327327
328328 fn get_block ( & self , hash : & bitcoin:: BlockHash ) -> Result < Block > {
329329 let hex: String = self . call ( "getblock" , & [ into_json ( hash) ?, 0 . into ( ) ] ) ?;
330- let bytes: Vec < u8 > = FromHex :: from_hex ( & hex) ?;
331- Ok ( bitcoin:: consensus:: encode:: deserialize ( & bytes) ?)
330+ deserialize_hex ( & hex)
332331 }
333332
334333 fn get_block_hex ( & self , hash : & bitcoin:: BlockHash ) -> Result < String > {
@@ -342,8 +341,7 @@ pub trait RpcApi: Sized {
342341
343342 fn get_block_header ( & self , hash : & bitcoin:: BlockHash ) -> Result < BlockHeader > {
344343 let hex: String = self . call ( "getblockheader" , & [ into_json ( hash) ?, false . into ( ) ] ) ?;
345- let bytes: Vec < u8 > = FromHex :: from_hex ( & hex) ?;
346- Ok ( bitcoin:: consensus:: encode:: deserialize ( & bytes) ?)
344+ deserialize_hex ( & hex)
347345 }
348346
349347 fn get_block_header_info (
@@ -487,8 +485,7 @@ pub trait RpcApi: Sized {
487485 ) -> Result < Transaction > {
488486 let mut args = [ into_json ( txid) ?, into_json ( false ) ?, opt_into_json ( block_hash) ?] ;
489487 let hex: String = self . call ( "getrawtransaction" , handle_defaults ( & mut args, & [ null ( ) ] ) ) ?;
490- let bytes: Vec < u8 > = FromHex :: from_hex ( & hex) ?;
491- Ok ( bitcoin:: consensus:: encode:: deserialize ( & bytes) ?)
488+ deserialize_hex ( & hex)
492489 }
493490
494491 fn get_raw_transaction_hex (
@@ -756,8 +753,7 @@ pub trait RpcApi: Sized {
756753 replaceable : Option < bool > ,
757754 ) -> Result < Transaction > {
758755 let hex: String = self . create_raw_transaction_hex ( utxos, outs, locktime, replaceable) ?;
759- let bytes: Vec < u8 > = FromHex :: from_hex ( & hex) ?;
760- Ok ( bitcoin:: consensus:: encode:: deserialize ( & bytes) ?)
756+ deserialize_hex ( & hex)
761757 }
762758
763759 fn fund_raw_transaction < R : RawTx > (
0 commit comments