@@ -15,14 +15,16 @@ use std::path::PathBuf;
15
15
use std:: { fmt, result} ;
16
16
17
17
use crate :: { bitcoin, deserialize_hex} ;
18
+ use bitcoin_private:: hex:: exts:: DisplayHex ;
18
19
use jsonrpc;
19
20
use serde;
20
21
use serde_json;
21
22
22
- use crate :: bitcoin:: hashes:: hex:: { FromHex , ToHex } ;
23
+ use crate :: bitcoin:: address:: { NetworkUnchecked , NetworkChecked } ;
24
+ use crate :: bitcoin:: hashes:: hex:: FromHex ;
23
25
use crate :: bitcoin:: secp256k1:: ecdsa:: Signature ;
24
26
use crate :: bitcoin:: {
25
- Address , Amount , Block , BlockHeader , OutPoint , PrivateKey , PublicKey , Script , Transaction ,
27
+ Address , Amount , Block , OutPoint , PrivateKey , PublicKey , Script , Transaction ,
26
28
} ;
27
29
use log:: Level :: { Debug , Trace , Warn } ;
28
30
@@ -160,19 +162,19 @@ pub trait RawTx: Sized + Clone {
160
162
161
163
impl < ' a > RawTx for & ' a Transaction {
162
164
fn raw_hex ( self ) -> String {
163
- bitcoin:: consensus:: encode:: serialize ( self ) . to_hex ( )
165
+ bitcoin:: consensus:: encode:: serialize_hex ( self )
164
166
}
165
167
}
166
168
167
169
impl < ' a > RawTx for & ' a [ u8 ] {
168
170
fn raw_hex ( self ) -> String {
169
- self . to_hex ( )
171
+ self . to_lower_hex_string ( )
170
172
}
171
173
}
172
174
173
175
impl < ' a > RawTx for & ' a Vec < u8 > {
174
176
fn raw_hex ( self ) -> String {
175
- self . to_hex ( )
177
+ self . to_lower_hex_string ( )
176
178
}
177
179
}
178
180
@@ -345,7 +347,7 @@ pub trait RpcApi: Sized {
345
347
}
346
348
//TODO(stevenroose) add getblock_txs
347
349
348
- fn get_block_header ( & self , hash : & bitcoin:: BlockHash ) -> Result < BlockHeader > {
350
+ fn get_block_header ( & self , hash : & bitcoin:: BlockHash ) -> Result < bitcoin :: block :: Header > {
349
351
let hex: String = self . call ( "getblockheader" , & [ into_json ( hash) ?, false . into ( ) ] ) ?;
350
352
deserialize_hex ( & hex)
351
353
}
@@ -640,7 +642,7 @@ pub trait RpcApi: Sized {
640
642
p2sh : Option < bool > ,
641
643
) -> Result < ( ) > {
642
644
let mut args = [
643
- script. to_hex ( ) . into ( ) ,
645
+ script. to_hex_string ( ) . into ( ) ,
644
646
opt_into_json ( label) ?,
645
647
opt_into_json ( rescan) ?,
646
648
opt_into_json ( p2sh) ?,
@@ -685,7 +687,7 @@ pub trait RpcApi: Sized {
685
687
& self ,
686
688
minconf : Option < usize > ,
687
689
maxconf : Option < usize > ,
688
- addresses : Option < & [ & Address ] > ,
690
+ addresses : Option < & [ & Address < NetworkChecked > ] > ,
689
691
include_unsafe : Option < bool > ,
690
692
query_options : Option < json:: ListUnspentQueryOptions > ,
691
693
) -> Result < Vec < json:: ListUnspentResultEntry > > {
@@ -886,12 +888,12 @@ pub trait RpcApi: Sized {
886
888
& self ,
887
889
label : Option < & str > ,
888
890
address_type : Option < json:: AddressType > ,
889
- ) -> Result < Address > {
891
+ ) -> Result < Address < NetworkUnchecked > > {
890
892
self . call ( "getnewaddress" , & [ opt_into_json ( label) ?, opt_into_json ( address_type) ?] )
891
893
}
892
894
893
895
/// 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 > > {
895
897
self . call ( "getrawchangeaddress" , & [ opt_into_json ( address_type) ?] )
896
898
}
897
899
@@ -905,7 +907,7 @@ pub trait RpcApi: Sized {
905
907
fn generate_to_address (
906
908
& self ,
907
909
block_num : u64 ,
908
- address : & Address ,
910
+ address : & Address < NetworkChecked > ,
909
911
) -> Result < Vec < bitcoin:: BlockHash > > {
910
912
self . call ( "generatetoaddress" , & [ block_num. into ( ) , address. to_string ( ) . into ( ) ] )
911
913
}
@@ -956,7 +958,7 @@ pub trait RpcApi: Sized {
956
958
957
959
fn send_to_address (
958
960
& self ,
959
- address : & Address ,
961
+ address : & Address < NetworkChecked > ,
960
962
amount : Amount ,
961
963
comment : Option < & str > ,
962
964
comment_to : Option < & str > ,
@@ -1155,7 +1157,7 @@ pub trait RpcApi: Sized {
1155
1157
] ;
1156
1158
let defaults = [
1157
1159
true . into ( ) ,
1158
- into_json ( json:: SigHashType :: from ( bitcoin:: EcdsaSighashType :: All ) ) ?,
1160
+ into_json ( json:: SigHashType :: from ( bitcoin:: sighash :: EcdsaSighashType :: All ) ) ?,
1159
1161
true . into ( ) ,
1160
1162
] ;
1161
1163
self . call ( "walletprocesspsbt" , handle_defaults ( & mut args, & defaults) )
@@ -1182,7 +1184,7 @@ pub trait RpcApi: Sized {
1182
1184
self . call ( "finalizepsbt" , handle_defaults ( & mut args, & [ true . into ( ) ] ) )
1183
1185
}
1184
1186
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 > > > {
1186
1188
let mut args = [ into_json ( descriptor) ?, opt_into_json ( range) ?] ;
1187
1189
self . call ( "deriveaddresses" , handle_defaults ( & mut args, & [ null ( ) ] ) )
1188
1190
}
@@ -1242,7 +1244,7 @@ pub trait RpcApi: Sized {
1242
1244
1243
1245
/// Submit a raw block
1244
1246
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 ( ) ;
1246
1248
self . submit_block_hex ( & block_hex)
1247
1249
}
1248
1250
0 commit comments