@@ -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;
@@ -321,8 +321,7 @@ pub trait RpcApi: Sized {
321
321
322
322
fn get_block ( & self , hash : & bitcoin:: BlockHash ) -> Result < Block > {
323
323
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)
326
325
}
327
326
328
327
fn get_block_hex ( & self , hash : & bitcoin:: BlockHash ) -> Result < String > {
@@ -336,8 +335,7 @@ pub trait RpcApi: Sized {
336
335
337
336
fn get_block_header ( & self , hash : & bitcoin:: BlockHash ) -> Result < BlockHeader > {
338
337
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)
341
339
}
342
340
343
341
fn get_block_header_info (
@@ -481,8 +479,7 @@ pub trait RpcApi: Sized {
481
479
) -> Result < Transaction > {
482
480
let mut args = [ into_json ( txid) ?, into_json ( false ) ?, opt_into_json ( block_hash) ?] ;
483
481
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)
486
483
}
487
484
488
485
fn get_raw_transaction_hex (
@@ -750,8 +747,7 @@ pub trait RpcApi: Sized {
750
747
replaceable : Option < bool > ,
751
748
) -> Result < Transaction > {
752
749
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)
755
751
}
756
752
757
753
fn fund_raw_transaction < R : RawTx > (
0 commit comments