@@ -14,7 +14,7 @@ use std::iter::FromIterator;
14
14
use std:: path:: PathBuf ;
15
15
use std:: { fmt, result} ;
16
16
17
- use crate :: bitcoin;
17
+ use crate :: { bitcoin, deserialize_hex } ;
18
18
use jsonrpc;
19
19
use serde;
20
20
use serde_json;
@@ -327,8 +327,7 @@ pub trait RpcApi: Sized {
327
327
328
328
fn get_block ( & self , hash : & bitcoin:: BlockHash ) -> Result < Block > {
329
329
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)
332
331
}
333
332
334
333
fn get_block_hex ( & self , hash : & bitcoin:: BlockHash ) -> Result < String > {
@@ -342,8 +341,7 @@ pub trait RpcApi: Sized {
342
341
343
342
fn get_block_header ( & self , hash : & bitcoin:: BlockHash ) -> Result < BlockHeader > {
344
343
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)
347
345
}
348
346
349
347
fn get_block_header_info (
@@ -487,8 +485,7 @@ pub trait RpcApi: Sized {
487
485
) -> Result < Transaction > {
488
486
let mut args = [ into_json ( txid) ?, into_json ( false ) ?, opt_into_json ( block_hash) ?] ;
489
487
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)
492
489
}
493
490
494
491
fn get_raw_transaction_hex (
@@ -756,8 +753,7 @@ pub trait RpcApi: Sized {
756
753
replaceable : Option < bool > ,
757
754
) -> Result < Transaction > {
758
755
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)
761
757
}
762
758
763
759
fn fund_raw_transaction < R : RawTx > (
0 commit comments