@@ -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) ; 
@@ -1044,7 +1055,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
10441055	assert_ne ! ( invoice. signing_pubkey( ) ,  david_id) ; 
10451056	assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ; 
10461057
1047- 	assert_eq ! ( reply_path. unwrap ( ) . introduction_node,  IntroductionNode :: NodeId ( charlie_id) ) ; 
1058+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( charlie_id) ) ; 
10481059
10491060	// Send, extract and verify the second Invoice Request message 
10501061	let  onion_message = david. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ; 
@@ -1059,7 +1070,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
10591070	assert_ne ! ( invoice. signing_pubkey( ) ,  david_id) ; 
10601071	assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ; 
10611072
1062- 	assert_eq ! ( reply_path. unwrap ( ) . introduction_node,  IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ; 
1073+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( nodes[ 6 ] . node. get_our_node_id( ) ) ) ; 
10631074} 
10641075
10651076/// Checks that a deferred invoice can be paid asynchronously from an Event::InvoiceReceived. 
@@ -1196,12 +1207,13 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
11961207	let  onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ; 
11971208	bob. onion_messenger . handle_onion_message ( & alice_id,  & onion_message) ; 
11981209
1199- 	let  ( invoice,  _ )  = extract_invoice ( bob,  & onion_message) ; 
1210+ 	let  ( invoice,  reply_path )  = extract_invoice ( bob,  & onion_message) ; 
12001211	assert_ne ! ( invoice. signing_pubkey( ) ,  alice_id) ; 
12011212	assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ; 
12021213	for  ( _,  path)  in  invoice. payment_paths ( )  { 
12031214		assert_eq ! ( path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
12041215	} 
1216+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
12051217
12061218	route_bolt12_payment ( bob,  & [ alice] ,  & invoice) ; 
12071219	expect_recent_payment ! ( bob,  RecentPaymentDetails :: Pending ,  payment_id) ; 
@@ -1245,13 +1257,14 @@ fn creates_refund_with_blinded_path_using_unannounced_introduction_node() {
12451257
12461258	let  onion_message = alice. onion_messenger . next_onion_message_for_peer ( bob_id) . unwrap ( ) ; 
12471259
1248- 	let  ( invoice,  _ )  = extract_invoice ( bob,  & onion_message) ; 
1260+ 	let  ( invoice,  reply_path )  = extract_invoice ( bob,  & onion_message) ; 
12491261	assert_eq ! ( invoice,  expected_invoice) ; 
12501262	assert_ne ! ( invoice. signing_pubkey( ) ,  alice_id) ; 
12511263	assert ! ( !invoice. payment_paths( ) . is_empty( ) ) ; 
12521264	for  ( _,  path)  in  invoice. payment_paths ( )  { 
12531265		assert_eq ! ( path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
12541266	} 
1267+ 	assert_eq ! ( reply_path. introduction_node,  IntroductionNode :: NodeId ( bob_id) ) ; 
12551268} 
12561269
12571270/// Fails creating or paying an offer when a blinded path cannot be created because no peers are 
0 commit comments