99
1010use crate :: blinded_path:: message:: { MessageContext , OffersContext } ;
1111use crate :: events:: { Event , HTLCDestination , MessageSendEventsProvider , PaymentFailureReason } ;
12- use crate :: ln:: blinded_payment_tests:: { blinded_payment_path, get_blinded_route_parameters} ;
13- use crate :: ln:: channelmanager;
12+ use crate :: ln:: blinded_payment_tests:: get_blinded_route_parameters;
1413use crate :: ln:: channelmanager:: { PaymentId , RecipientOnionFields } ;
1514use crate :: ln:: functional_test_utils:: * ;
16- use crate :: ln:: inbound_payment;
1715use crate :: ln:: msgs:: ChannelMessageHandler ;
1816use crate :: ln:: msgs:: OnionMessageHandler ;
1917use crate :: ln:: offers_tests;
@@ -29,11 +27,8 @@ use crate::onion_message::messenger::{Destination, MessageRouter, MessageSendIns
2927use crate :: onion_message:: offers:: OffersMessage ;
3028use crate :: onion_message:: packet:: ParsedOnionMessageContents ;
3129use crate :: prelude:: * ;
32- use crate :: routing:: router:: { PaymentParameters , RouteParameters } ;
33- use crate :: sign:: NodeSigner ;
3430use crate :: types:: features:: Bolt12InvoiceFeatures ;
3531use crate :: types:: payment:: { PaymentPreimage , PaymentSecret } ;
36- use crate :: util:: config:: UserConfig ;
3732use bitcoin:: secp256k1;
3833use bitcoin:: secp256k1:: Secp256k1 ;
3934
@@ -67,168 +62,6 @@ fn create_static_invoice<T: secp256k1::Signing + secp256k1::Verification>(
6762 ( offer, static_invoice)
6863}
6964
70- #[ test]
71- fn blinded_keysend ( ) {
72- let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
73- let node_cfgs = create_node_cfgs ( 3 , & chanmon_cfgs) ;
74- let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
75- let mut nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
76- create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 1_000_000 , 0 ) ;
77- let chan_upd_1_2 =
78- create_announced_chan_between_nodes_with_value ( & nodes, 1 , 2 , 1_000_000 , 0 ) . 0 . contents ;
79-
80- let inbound_payment_key = nodes[ 2 ] . keys_manager . get_inbound_payment_key ( ) ;
81- let payment_secret = inbound_payment:: create_for_spontaneous_payment (
82- & inbound_payment_key,
83- None ,
84- u32:: MAX ,
85- nodes[ 2 ] . node . duration_since_epoch ( ) . as_secs ( ) ,
86- None ,
87- )
88- . unwrap ( ) ;
89-
90- let amt_msat = 5000 ;
91- let keysend_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
92- let route_params = get_blinded_route_parameters (
93- amt_msat,
94- payment_secret,
95- 1 ,
96- 1_0000_0000 ,
97- nodes. iter ( ) . skip ( 1 ) . map ( |n| n. node . get_our_node_id ( ) ) . collect ( ) ,
98- & [ & chan_upd_1_2] ,
99- & chanmon_cfgs[ 2 ] . keys_manager ,
100- ) ;
101-
102- let payment_hash = nodes[ 0 ]
103- . node
104- . send_spontaneous_payment (
105- Some ( keysend_preimage) ,
106- RecipientOnionFields :: spontaneous_empty ( ) ,
107- PaymentId ( keysend_preimage. 0 ) ,
108- route_params,
109- Retry :: Attempts ( 0 ) ,
110- )
111- . unwrap ( ) ;
112- check_added_monitors ( & nodes[ 0 ] , 1 ) ;
113-
114- let expected_route: & [ & [ & Node ] ] = & [ & [ & nodes[ 1 ] , & nodes[ 2 ] ] ] ;
115- let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
116- assert_eq ! ( events. len( ) , 1 ) ;
117-
118- let ev = remove_first_msg_event_to_node ( & nodes[ 1 ] . node . get_our_node_id ( ) , & mut events) ;
119- pass_along_path (
120- & nodes[ 0 ] ,
121- expected_route[ 0 ] ,
122- amt_msat,
123- payment_hash,
124- Some ( payment_secret) ,
125- ev. clone ( ) ,
126- true ,
127- Some ( keysend_preimage) ,
128- ) ;
129- claim_payment_along_route ( ClaimAlongRouteArgs :: new (
130- & nodes[ 0 ] ,
131- expected_route,
132- keysend_preimage,
133- ) ) ;
134- }
135-
136- #[ test]
137- fn blinded_mpp_keysend ( ) {
138- let chanmon_cfgs = create_chanmon_cfgs ( 4 ) ;
139- let node_cfgs = create_node_cfgs ( 4 , & chanmon_cfgs) ;
140- let node_chanmgrs = create_node_chanmgrs ( 4 , & node_cfgs, & [ None , None , None , None ] ) ;
141- let nodes = create_network ( 4 , & node_cfgs, & node_chanmgrs) ;
142-
143- create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
144- create_announced_chan_between_nodes ( & nodes, 0 , 2 ) ;
145- let chan_1_3 = create_announced_chan_between_nodes ( & nodes, 1 , 3 ) ;
146- let chan_2_3 = create_announced_chan_between_nodes ( & nodes, 2 , 3 ) ;
147-
148- let inbound_payment_key = nodes[ 3 ] . keys_manager . get_inbound_payment_key ( ) ;
149- let payment_secret = inbound_payment:: create_for_spontaneous_payment (
150- & inbound_payment_key,
151- None ,
152- u32:: MAX ,
153- nodes[ 3 ] . node . duration_since_epoch ( ) . as_secs ( ) ,
154- None ,
155- )
156- . unwrap ( ) ;
157-
158- let amt_msat = 15_000_000 ;
159- let keysend_preimage = PaymentPreimage ( [ 42 ; 32 ] ) ;
160- let route_params = {
161- let pay_params = PaymentParameters :: blinded ( vec ! [
162- blinded_payment_path(
163- payment_secret,
164- 1 ,
165- 1_0000_0000 ,
166- vec![ nodes[ 1 ] . node. get_our_node_id( ) , nodes[ 3 ] . node. get_our_node_id( ) ] ,
167- & [ & chan_1_3. 0 . contents] ,
168- & chanmon_cfgs[ 3 ] . keys_manager,
169- ) ,
170- blinded_payment_path(
171- payment_secret,
172- 1 ,
173- 1_0000_0000 ,
174- vec![ nodes[ 2 ] . node. get_our_node_id( ) , nodes[ 3 ] . node. get_our_node_id( ) ] ,
175- & [ & chan_2_3. 0 . contents] ,
176- & chanmon_cfgs[ 3 ] . keys_manager,
177- ) ,
178- ] )
179- . with_bolt12_features ( channelmanager:: provided_bolt12_invoice_features (
180- & UserConfig :: default ( ) ,
181- ) )
182- . unwrap ( ) ;
183- RouteParameters :: from_payment_params_and_value ( pay_params, amt_msat)
184- } ;
185-
186- let payment_hash = nodes[ 0 ]
187- . node
188- . send_spontaneous_payment (
189- Some ( keysend_preimage) ,
190- RecipientOnionFields :: spontaneous_empty ( ) ,
191- PaymentId ( keysend_preimage. 0 ) ,
192- route_params,
193- Retry :: Attempts ( 0 ) ,
194- )
195- . unwrap ( ) ;
196- check_added_monitors ! ( nodes[ 0 ] , 2 ) ;
197-
198- let expected_route: & [ & [ & Node ] ] = & [ & [ & nodes[ 1 ] , & nodes[ 3 ] ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] ] ;
199- let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
200- assert_eq ! ( events. len( ) , 2 ) ;
201-
202- let ev = remove_first_msg_event_to_node ( & nodes[ 1 ] . node . get_our_node_id ( ) , & mut events) ;
203- pass_along_path (
204- & nodes[ 0 ] ,
205- expected_route[ 0 ] ,
206- amt_msat,
207- payment_hash. clone ( ) ,
208- Some ( payment_secret) ,
209- ev. clone ( ) ,
210- false ,
211- Some ( keysend_preimage) ,
212- ) ;
213-
214- let ev = remove_first_msg_event_to_node ( & nodes[ 2 ] . node . get_our_node_id ( ) , & mut events) ;
215- pass_along_path (
216- & nodes[ 0 ] ,
217- expected_route[ 1 ] ,
218- amt_msat,
219- payment_hash. clone ( ) ,
220- Some ( payment_secret) ,
221- ev. clone ( ) ,
222- true ,
223- Some ( keysend_preimage) ,
224- ) ;
225- claim_payment_along_route ( ClaimAlongRouteArgs :: new (
226- & nodes[ 0 ] ,
227- expected_route,
228- keysend_preimage,
229- ) ) ;
230- }
231-
23265#[ test]
23366fn invalid_keysend_payment_secret ( ) {
23467 let chanmon_cfgs = create_chanmon_cfgs ( 3 ) ;
0 commit comments