@@ -67,7 +67,7 @@ async fn test_onchain_withdraw_to_static_address(
6767 let bob_address = bob
6868 . sdk
6969 . receive_payment ( ReceivePaymentRequest {
70- payment_method : ReceivePaymentMethod :: BitcoinAddress ,
70+ payment_method : ReceivePaymentMethod :: BitcoinAddress { new_address : None } ,
7171 } )
7272 . await ?
7373 . payment_request ;
@@ -156,7 +156,7 @@ async fn test_deposit_fee_manual_claim(
156156 let addr = bob
157157 . sdk
158158 . receive_payment ( ReceivePaymentRequest {
159- payment_method : ReceivePaymentMethod :: BitcoinAddress ,
159+ payment_method : ReceivePaymentMethod :: BitcoinAddress { new_address : None } ,
160160 } )
161161 . await ?
162162 . payment_request ;
@@ -253,7 +253,7 @@ async fn test_send_all_to_bitcoin_address(
253253 let bob_address = bob
254254 . sdk
255255 . receive_payment ( ReceivePaymentRequest {
256- payment_method : ReceivePaymentMethod :: BitcoinAddress ,
256+ payment_method : ReceivePaymentMethod :: BitcoinAddress { new_address : None } ,
257257 } )
258258 . await ?
259259 . payment_request ;
@@ -342,7 +342,7 @@ async fn test_deposit_fee_refund(#[future] bob_no_fee_sdk: Result<SdkInstance>)
342342 let addr = bob
343343 . sdk
344344 . receive_payment ( ReceivePaymentRequest {
345- payment_method : ReceivePaymentMethod :: BitcoinAddress ,
345+ payment_method : ReceivePaymentMethod :: BitcoinAddress { new_address : None } ,
346346 } )
347347 . await ?
348348 . payment_request ;
@@ -450,7 +450,7 @@ async fn test_deposit_low_amount_refund_fee_rate(
450450 let bob_address = bob
451451 . sdk
452452 . receive_payment ( ReceivePaymentRequest {
453- payment_method : ReceivePaymentMethod :: BitcoinAddress ,
453+ payment_method : ReceivePaymentMethod :: BitcoinAddress { new_address : None } ,
454454 } )
455455 . await ?
456456 . payment_request ;
@@ -538,7 +538,9 @@ async fn test_deposits_to_multiple_addresses(
538538 let addr = alice
539539 . sdk
540540 . receive_payment ( ReceivePaymentRequest {
541- payment_method : ReceivePaymentMethod :: BitcoinAddress ,
541+ payment_method : ReceivePaymentMethod :: BitcoinAddress {
542+ new_address : Some ( true ) ,
543+ } ,
542544 } )
543545 . await ?
544546 . payment_request ;
@@ -551,7 +553,35 @@ async fn test_deposits_to_multiple_addresses(
551553 assert_eq ! (
552554 unique. len( ) ,
553555 addresses. len( ) ,
554- "Every rotated address should be unique"
556+ "Every new address should be unique"
557+ ) ;
558+
559+ // Calling with new_address=false (or None) should return the same address.
560+ let reused_1 = alice
561+ . sdk
562+ . receive_payment ( ReceivePaymentRequest {
563+ payment_method : ReceivePaymentMethod :: BitcoinAddress {
564+ new_address : Some ( false ) ,
565+ } ,
566+ } )
567+ . await ?
568+ . payment_request ;
569+ let reused_2 = alice
570+ . sdk
571+ . receive_payment ( ReceivePaymentRequest {
572+ payment_method : ReceivePaymentMethod :: BitcoinAddress { new_address : None } ,
573+ } )
574+ . await ?
575+ . payment_request ;
576+ assert_eq ! (
577+ reused_1, reused_2,
578+ "new_address=false and None should return the same address"
579+ ) ;
580+ // The reused address should match the last one obtained with new_address=true.
581+ assert_eq ! (
582+ reused_1,
583+ * addresses. last( ) . unwrap( ) ,
584+ "new_address=false should return the latest address"
555585 ) ;
556586
557587 let first_addr = & addresses[ 0 ] ;
0 commit comments