@@ -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;
@@ -321,8 +321,7 @@ pub trait RpcApi: Sized {
321321
322322 fn get_block ( & self , hash : & bitcoin:: BlockHash ) -> Result < Block > {
323323 let hex: String = self . call ( "getblock" , & [ into_json ( hash) ?, 0 . into ( ) ] ) ?;
324- let bytes: Vec < u8 > = FromHex :: from_hex ( & hex) ?;
325- Ok ( bitcoin:: consensus:: encode:: deserialize ( & bytes) ?)
324+ deserialize_hex ( & hex)
326325 }
327326
328327 fn get_block_hex ( & self , hash : & bitcoin:: BlockHash ) -> Result < String > {
@@ -336,8 +335,7 @@ pub trait RpcApi: Sized {
336335
337336 fn get_block_header ( & self , hash : & bitcoin:: BlockHash ) -> Result < BlockHeader > {
338337 let hex: String = self . call ( "getblockheader" , & [ into_json ( hash) ?, false . into ( ) ] ) ?;
339- let bytes: Vec < u8 > = FromHex :: from_hex ( & hex) ?;
340- Ok ( bitcoin:: consensus:: encode:: deserialize ( & bytes) ?)
338+ deserialize_hex ( & hex)
341339 }
342340
343341 fn get_block_header_info (
@@ -481,8 +479,7 @@ pub trait RpcApi: Sized {
481479 ) -> Result < Transaction > {
482480 let mut args = [ into_json ( txid) ?, into_json ( false ) ?, opt_into_json ( block_hash) ?] ;
483481 let hex: String = self . call ( "getrawtransaction" , handle_defaults ( & mut args, & [ null ( ) ] ) ) ?;
484- let bytes: Vec < u8 > = FromHex :: from_hex ( & hex) ?;
485- Ok ( bitcoin:: consensus:: encode:: deserialize ( & bytes) ?)
482+ deserialize_hex ( & hex)
486483 }
487484
488485 fn get_raw_transaction_hex (
@@ -750,8 +747,7 @@ pub trait RpcApi: Sized {
750747 replaceable : Option < bool > ,
751748 ) -> Result < Transaction > {
752749 let hex: String = self . create_raw_transaction_hex ( utxos, outs, locktime, replaceable) ?;
753- let bytes: Vec < u8 > = FromHex :: from_hex ( & hex) ?;
754- Ok ( bitcoin:: consensus:: encode:: deserialize ( & bytes) ?)
750+ deserialize_hex ( & hex)
755751 }
756752
757753 fn fund_raw_transaction < R : RawTx > (
0 commit comments