This repository was archived by the owner on Nov 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -845,6 +845,11 @@ pub trait RpcApi: Sized {
845845 self . call ( "getnewaddress" , & [ opt_into_json ( label) ?, opt_into_json ( address_type) ?] )
846846 }
847847
848+ /// Generate new address for receiving change
849+ fn get_raw_change_address ( & self , address_type : Option < json:: AddressType > ) -> Result < Address > {
850+ self . call ( "getrawchangeaddress" , & [ opt_into_json ( address_type) ?] )
851+ }
852+
848853 fn get_address_info ( & self , address : & Address ) -> Result < json:: GetAddressInfoResult > {
849854 self . call ( "getaddressinfo" , & [ address. to_string ( ) . into ( ) ] )
850855 }
Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ fn main() {
136136 test_get_mining_info ( & cl) ;
137137 test_get_blockchain_info ( & cl) ;
138138 test_get_new_address ( & cl) ;
139+ test_get_raw_change_address ( & cl) ;
139140 test_dump_private_key ( & cl) ;
140141 test_generate ( & cl) ;
141142 test_get_balance_generate_to_address ( & cl) ;
@@ -238,6 +239,17 @@ fn test_get_new_address(cl: &Client) {
238239 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
239240}
240241
242+ fn test_get_raw_change_address ( cl : & Client ) {
243+ let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: Legacy ) ) . unwrap ( ) ;
244+ assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2pkh ) ) ;
245+
246+ let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) ;
247+ assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
248+
249+ let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) ;
250+ assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
251+ }
252+
241253fn test_dump_private_key ( cl : & Client ) {
242254 let addr = cl. get_new_address ( None , Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) ;
243255 let sk = cl. dump_private_key ( & addr) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments