@@ -15,14 +15,16 @@ use std::path::PathBuf;
1515use std:: { fmt, result} ;
1616
1717use crate :: { bitcoin, deserialize_hex} ;
18+ use bitcoin_private:: hex:: exts:: DisplayHex ;
1819use jsonrpc;
1920use serde;
2021use serde_json;
2122
22- use crate :: bitcoin:: hashes:: hex:: { FromHex , ToHex } ;
23+ use crate :: bitcoin:: address:: { NetworkUnchecked , NetworkChecked } ;
24+ use crate :: bitcoin:: hashes:: hex:: FromHex ;
2325use crate :: bitcoin:: secp256k1:: ecdsa:: Signature ;
2426use crate :: bitcoin:: {
25- Address , Amount , Block , BlockHeader , OutPoint , PrivateKey , PublicKey , Script , Transaction ,
27+ Address , Amount , Block , OutPoint , PrivateKey , PublicKey , Script , Transaction ,
2628} ;
2729use log:: Level :: { Debug , Trace , Warn } ;
2830
@@ -160,19 +162,19 @@ pub trait RawTx: Sized + Clone {
160162
161163impl < ' a > RawTx for & ' a Transaction {
162164 fn raw_hex ( self ) -> String {
163- bitcoin:: consensus:: encode:: serialize ( self ) . to_hex ( )
165+ bitcoin:: consensus:: encode:: serialize_hex ( self )
164166 }
165167}
166168
167169impl < ' a > RawTx for & ' a [ u8 ] {
168170 fn raw_hex ( self ) -> String {
169- self . to_hex ( )
171+ self . to_lower_hex_string ( )
170172 }
171173}
172174
173175impl < ' a > RawTx for & ' a Vec < u8 > {
174176 fn raw_hex ( self ) -> String {
175- self . to_hex ( )
177+ self . to_lower_hex_string ( )
176178 }
177179}
178180
@@ -345,7 +347,7 @@ pub trait RpcApi: Sized {
345347 }
346348 //TODO(stevenroose) add getblock_txs
347349
348- fn get_block_header ( & self , hash : & bitcoin:: BlockHash ) -> Result < BlockHeader > {
350+ fn get_block_header ( & self , hash : & bitcoin:: BlockHash ) -> Result < bitcoin :: block :: Header > {
349351 let hex: String = self . call ( "getblockheader" , & [ into_json ( hash) ?, false . into ( ) ] ) ?;
350352 deserialize_hex ( & hex)
351353 }
@@ -640,7 +642,7 @@ pub trait RpcApi: Sized {
640642 p2sh : Option < bool > ,
641643 ) -> Result < ( ) > {
642644 let mut args = [
643- script. to_hex ( ) . into ( ) ,
645+ script. to_hex_string ( ) . into ( ) ,
644646 opt_into_json ( label) ?,
645647 opt_into_json ( rescan) ?,
646648 opt_into_json ( p2sh) ?,
@@ -685,7 +687,7 @@ pub trait RpcApi: Sized {
685687 & self ,
686688 minconf : Option < usize > ,
687689 maxconf : Option < usize > ,
688- addresses : Option < & [ & Address ] > ,
690+ addresses : Option < & [ & Address < NetworkChecked > ] > ,
689691 include_unsafe : Option < bool > ,
690692 query_options : Option < json:: ListUnspentQueryOptions > ,
691693 ) -> Result < Vec < json:: ListUnspentResultEntry > > {
@@ -886,12 +888,12 @@ pub trait RpcApi: Sized {
886888 & self ,
887889 label : Option < & str > ,
888890 address_type : Option < json:: AddressType > ,
889- ) -> Result < Address > {
891+ ) -> Result < Address < NetworkUnchecked > > {
890892 self . call ( "getnewaddress" , & [ opt_into_json ( label) ?, opt_into_json ( address_type) ?] )
891893 }
892894
893895 /// Generate new address for receiving change
894- fn get_raw_change_address ( & self , address_type : Option < json:: AddressType > ) -> Result < Address > {
896+ fn get_raw_change_address ( & self , address_type : Option < json:: AddressType > ) -> Result < Address < NetworkUnchecked > > {
895897 self . call ( "getrawchangeaddress" , & [ opt_into_json ( address_type) ?] )
896898 }
897899
@@ -905,7 +907,7 @@ pub trait RpcApi: Sized {
905907 fn generate_to_address (
906908 & self ,
907909 block_num : u64 ,
908- address : & Address ,
910+ address : & Address < NetworkChecked > ,
909911 ) -> Result < Vec < bitcoin:: BlockHash > > {
910912 self . call ( "generatetoaddress" , & [ block_num. into ( ) , address. to_string ( ) . into ( ) ] )
911913 }
@@ -956,7 +958,7 @@ pub trait RpcApi: Sized {
956958
957959 fn send_to_address (
958960 & self ,
959- address : & Address ,
961+ address : & Address < NetworkChecked > ,
960962 amount : Amount ,
961963 comment : Option < & str > ,
962964 comment_to : Option < & str > ,
@@ -1155,7 +1157,7 @@ pub trait RpcApi: Sized {
11551157 ] ;
11561158 let defaults = [
11571159 true . into ( ) ,
1158- into_json ( json:: SigHashType :: from ( bitcoin:: EcdsaSighashType :: All ) ) ?,
1160+ into_json ( json:: SigHashType :: from ( bitcoin:: sighash :: EcdsaSighashType :: All ) ) ?,
11591161 true . into ( ) ,
11601162 ] ;
11611163 self . call ( "walletprocesspsbt" , handle_defaults ( & mut args, & defaults) )
@@ -1182,7 +1184,7 @@ pub trait RpcApi: Sized {
11821184 self . call ( "finalizepsbt" , handle_defaults ( & mut args, & [ true . into ( ) ] ) )
11831185 }
11841186
1185- fn derive_addresses ( & self , descriptor : & str , range : Option < [ u32 ; 2 ] > ) -> Result < Vec < Address > > {
1187+ fn derive_addresses ( & self , descriptor : & str , range : Option < [ u32 ; 2 ] > ) -> Result < Vec < Address < NetworkUnchecked > > > {
11861188 let mut args = [ into_json ( descriptor) ?, opt_into_json ( range) ?] ;
11871189 self . call ( "deriveaddresses" , handle_defaults ( & mut args, & [ null ( ) ] ) )
11881190 }
@@ -1242,7 +1244,7 @@ pub trait RpcApi: Sized {
12421244
12431245 /// Submit a raw block
12441246 fn submit_block_bytes ( & self , block_bytes : & [ u8 ] ) -> Result < ( ) > {
1245- let block_hex: String = block_bytes. to_hex ( ) ;
1247+ let block_hex: String = block_bytes. to_lower_hex_string ( ) ;
12461248 self . submit_block_hex ( & block_hex)
12471249 }
12481250
0 commit comments