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 @@ -886,6 +886,11 @@ pub trait RpcApi: Sized {
886886 self . call ( "getnewaddress" , & [ opt_into_json ( label) ?, opt_into_json ( address_type) ?] )
887887 }
888888
889+ /// Generate new address for receiving change
890+ fn get_raw_change_address ( & self , address_type : Option < json:: AddressType > ) -> Result < Address > {
891+ self . call ( "getrawchangeaddress" , & [ opt_into_json ( address_type) ?] )
892+ }
893+
889894 fn get_address_info ( & self , address : & Address ) -> Result < json:: GetAddressInfoResult > {
890895 self . call ( "getaddressinfo" , & [ address. to_string ( ) . into ( ) ] )
891896 }
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) ;
@@ -241,6 +242,17 @@ fn test_get_new_address(cl: &Client) {
241242 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
242243}
243244
245+ fn test_get_raw_change_address ( cl : & Client ) {
246+ let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: Legacy ) ) . unwrap ( ) ;
247+ assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2pkh ) ) ;
248+
249+ let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) ;
250+ assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
251+
252+ let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) ;
253+ assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
254+ }
255+
244256fn test_dump_private_key ( cl : & Client ) {
245257 let addr = cl. get_new_address ( None , Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) ;
246258 let sk = cl. dump_private_key ( & addr) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments