@@ -205,12 +205,12 @@ fn extract_invoice_request<'a, 'b, 'c>(
205205	} 
206206} 
207207
208- fn  extract_invoice < ' a ,  ' b ,  ' c > ( node :  & Node < ' a ,  ' b ,  ' c > ,  message :  & OnionMessage )  -> ( Bolt12Invoice ,  Option < BlindedPath > )  { 
208+ fn  extract_invoice < ' a ,  ' b ,  ' c > ( node :  & Node < ' a ,  ' b ,  ' c > ,  message :  & OnionMessage )  -> ( Bolt12Invoice ,  BlindedPath )  { 
209209	match  node. onion_messenger . peel_onion_message ( message)  { 
210210		Ok ( PeeledOnion :: Receive ( message,  _,  reply_path) )  => match  message { 
211211			ParsedOnionMessageContents :: Offers ( offers_message)  => match  offers_message { 
212212				OffersMessage :: InvoiceRequest ( invoice_request)  => panic ! ( "Unexpected invoice_request: {:?}" ,  invoice_request) , 
213- 				OffersMessage :: Invoice ( invoice)  => ( invoice,  reply_path) , 
213+ 				OffersMessage :: Invoice ( invoice)  => ( invoice,  reply_path. unwrap ( ) ) , 
214214				#[ cfg( async_payments) ]  
215215				OffersMessage :: StaticInvoice ( invoice)  => panic ! ( "Unexpected static invoice: {:?}" ,  invoice) , 
216216				OffersMessage :: InvoiceError ( error)  => panic ! ( "Unexpected invoice_error: {:?}" ,  error) , 
@@ -494,15 +494,15 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
494494	features. set_onion_messages_optional ( ) ; 
495495	features. set_route_blinding_optional ( ) ; 
496496
497- 	let  chanmon_cfgs = create_chanmon_cfgs ( 6 ) ; 
498- 	let  node_cfgs = create_node_cfgs ( 6 ,  & chanmon_cfgs) ; 
497+ 	let  chanmon_cfgs = create_chanmon_cfgs ( 7 ) ; 
498+ 	let  node_cfgs = create_node_cfgs ( 7 ,  & chanmon_cfgs) ; 
499499
500500	* node_cfgs[ 1 ] . override_init_features . borrow_mut ( )  = Some ( features) ; 
501501
502502	let  node_chanmgrs = create_node_chanmgrs ( 
503- 		6 ,  & node_cfgs,  & [ None ,  Some ( accept_forward_cfg) ,  None ,  None ,  None ,  None ] 
503+ 		7 ,  & node_cfgs,  & [ None ,  Some ( accept_forward_cfg) ,   None ,  None ,  None ,  None ,  None ] 
504504	) ; 
505- 	let  nodes = create_network ( 6 ,  & node_cfgs,  & node_chanmgrs) ; 
505+ 	let  nodes = create_network ( 7 ,  & node_cfgs,  & node_chanmgrs) ; 
506506
507507	create_unannounced_chan_between_nodes_with_value ( & nodes,  0 ,  1 ,  10_000_000 ,  1_000_000_000 ) ; 
508508	create_unannounced_chan_between_nodes_with_value ( & nodes,  2 ,  3 ,  10_000_000 ,  1_000_000_000 ) ; 
@@ -512,6 +512,12 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
512512	create_announced_chan_between_nodes_with_value ( & nodes,  2 ,  4 ,  10_000_000 ,  1_000_000_000 ) ; 
513513	create_announced_chan_between_nodes_with_value ( & nodes,  2 ,  5 ,  10_000_000 ,  1_000_000_000 ) ; 
514514
515+ 	// Create an announced channel between Bob and node[6] to ensure that in the event of a tie 
516+ 	// between Bob and Charlie for becoming the introduction node candidate, Bob is deterministically 
517+ 	// preferred over Charlie. 
518+ 	create_announced_chan_between_nodes_with_value ( & nodes,  1 ,  6 ,  10_000_000 ,  1_000_000_000 ) ; 
519+ 
520+ 
515521	let  ( alice,  bob,  charlie,  david)  = ( & nodes[ 0 ] ,  & nodes[ 1 ] ,  & nodes[ 2 ] ,  & nodes[ 3 ] ) ; 
516522	let  alice_id = alice. node . get_our_node_id ( ) ; 
517523	let  bob_id = bob. node . get_our_node_id ( ) ; 
@@ -566,13 +572,14 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
566572	let  onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ; 
567573	david. onion_messenger . handle_onion_message ( & charlie_id,  & onion_message) ; 
568574
569- 	let  ( invoice,  _ )  = extract_invoice ( david,  & onion_message) ; 
575+ 	let  ( invoice,  reply_path )  = extract_invoice ( david,  & onion_message) ; 
570576	assert_eq ! ( invoice. amount_msats( ) ,  10_000_000 ) ; 
571577	assert_ne ! ( invoice. signing_pubkey( ) ,  alice_id) ; 
572578	assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ; 
573579	for  ( _,  path)  in  invoice. payment_paths ( )  { 
574580		assert_eq ! ( path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
575581	} 
582+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
576583
577584	route_bolt12_payment ( david,  & [ charlie,  bob,  alice] ,  & invoice) ; 
578585	expect_recent_payment ! ( david,  RecentPaymentDetails :: Pending ,  payment_id) ; 
@@ -645,7 +652,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
645652	let  onion_message = charlie. onion_messenger . next_onion_message_for_peer ( david_id) . unwrap ( ) ; 
646653	david. onion_messenger . handle_onion_message ( & charlie_id,  & onion_message) ; 
647654
648- 	let  ( invoice,  _ )  = extract_invoice ( david,  & onion_message) ; 
655+ 	let  ( invoice,  reply_path )  = extract_invoice ( david,  & onion_message) ; 
649656	assert_eq ! ( invoice,  expected_invoice) ; 
650657
651658	assert_eq ! ( invoice. amount_msats( ) ,  10_000_000 ) ; 
@@ -654,6 +661,8 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
654661	for  ( _,  path)  in  invoice. payment_paths ( )  { 
655662		assert_eq ! ( path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
656663	} 
664+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
665+ 
657666
658667	route_bolt12_payment ( david,  & [ charlie,  bob,  alice] ,  & invoice) ; 
659668	expect_recent_payment ! ( david,  RecentPaymentDetails :: Pending ,  payment_id) ; 
@@ -712,13 +721,14 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
712721	let  onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ; 
713722	bob. onion_messenger . handle_onion_message ( & alice_id,  & onion_message) ; 
714723
715- 	let  ( invoice,  _ )  = extract_invoice ( bob,  & onion_message) ; 
724+ 	let  ( invoice,  reply_path )  = extract_invoice ( bob,  & onion_message) ; 
716725	assert_eq ! ( invoice. amount_msats( ) ,  10_000_000 ) ; 
717726	assert_ne ! ( invoice. signing_pubkey( ) ,  alice_id) ; 
718727	assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ; 
719728	for  ( _,  path)  in  invoice. payment_paths ( )  { 
720729		assert_eq ! ( path. introduction_node,  IntroductionNode :: NodeId ( alice_id) ) ; 
721730	} 
731+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( alice_id) ) ; 
722732
723733	route_bolt12_payment ( bob,  & [ alice] ,  & invoice) ; 
724734	expect_recent_payment ! ( bob,  RecentPaymentDetails :: Pending ,  payment_id) ; 
@@ -765,7 +775,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
765775	let  onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ; 
766776	bob. onion_messenger . handle_onion_message ( & alice_id,  & onion_message) ; 
767777
768- 	let  ( invoice,  _ )  = extract_invoice ( bob,  & onion_message) ; 
778+ 	let  ( invoice,  reply_path )  = extract_invoice ( bob,  & onion_message) ; 
769779	assert_eq ! ( invoice,  expected_invoice) ; 
770780
771781	assert_eq ! ( invoice. amount_msats( ) ,  10_000_000 ) ; 
@@ -774,6 +784,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
774784	for  ( _,  path)  in  invoice. payment_paths ( )  { 
775785		assert_eq ! ( path. introduction_node,  IntroductionNode :: NodeId ( alice_id) ) ; 
776786	} 
787+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( alice_id) ) ; 
777788
778789	route_bolt12_payment ( bob,  & [ alice] ,  & invoice) ; 
779790	expect_recent_payment ! ( bob,  RecentPaymentDetails :: Pending ,  payment_id) ; 
@@ -1030,7 +1041,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
10301041	let  onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ; 
10311042
10321043	let  ( _,  reply_path)  = extract_invoice ( alice,  & onion_message) ; 
1033- 	assert_eq ! ( reply_path. unwrap ( ) . introduction_node,  IntroductionNode :: NodeId ( charlie_id) ) ; 
1044+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( charlie_id) ) ; 
10341045
10351046	// Send, extract and verify the second Invoice Request message 
10361047	let  onion_message = david. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ; 
@@ -1039,7 +1050,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
10391050	let  onion_message = bob. onion_messenger . next_onion_message_for_peer ( alice_id) . unwrap ( ) ; 
10401051
10411052	let  ( _,  reply_path)  = extract_invoice ( alice,  & onion_message) ; 
1042- 	assert_eq ! ( reply_path. unwrap ( ) . introduction_node,  IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ; 
1053+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ; 
10431054} 
10441055
10451056/// Checks that a deferred invoice can be paid asynchronously from an Event::InvoiceReceived. 
@@ -1176,12 +1187,13 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
11761187	let  onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ; 
11771188	bob. onion_messenger . handle_onion_message ( & alice_id,  & onion_message) ; 
11781189
1179- 	let  ( invoice,  _ )  = extract_invoice ( bob,  & onion_message) ; 
1190+ 	let  ( invoice,  reply_path )  = extract_invoice ( bob,  & onion_message) ; 
11801191	assert_ne ! ( invoice. signing_pubkey( ) ,  alice_id) ; 
11811192	assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ; 
11821193	for  ( _,  path)  in  invoice. payment_paths ( )  { 
11831194		assert_eq ! ( path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
11841195	} 
1196+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
11851197
11861198	route_bolt12_payment ( bob,  & [ alice] ,  & invoice) ; 
11871199	expect_recent_payment ! ( bob,  RecentPaymentDetails :: Pending ,  payment_id) ; 
@@ -1225,13 +1237,14 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
12251237
12261238	let  onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ; 
12271239
1228- 	let  ( invoice,  _ )  = extract_invoice ( bob,  & onion_message) ; 
1240+ 	let  ( invoice,  reply_path )  = extract_invoice ( bob,  & onion_message) ; 
12291241	assert_eq ! ( invoice,  expected_invoice) ; 
12301242	assert_ne ! ( invoice. signing_pubkey( ) ,  alice_id) ; 
12311243	assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ; 
12321244	for  ( _,  path)  in  invoice. payment_paths ( )  { 
12331245		assert_eq ! ( path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
12341246	} 
1247+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
12351248} 
12361249
12371250/// Fails creating or paying an offer when a blinded path cannot be created because no peers are 
0 commit comments