@@ -38,41 +38,35 @@ macro_rules! expect_recent_payment {
38
38
}
39
39
}
40
40
41
- macro_rules! route_payment {
42
- ( $node: expr, $path: expr, $invoice: expr) => {
43
- {
44
- // Monitor added when handling the invoice onion message.
45
- check_added_monitors( $node, 1 ) ;
46
-
47
- let mut events = $node. node. get_and_clear_pending_msg_events( ) ;
48
- assert_eq!( events. len( ) , 1 ) ;
49
- let ev = remove_first_msg_event_to_node( & $path[ 0 ] . node. get_our_node_id( ) , & mut events) ;
50
-
51
- // Use a fake payment_hash and bypass checking for the PaymentClaimable event since the
52
- // invoice contains the payment_hash but it was encrypted inside an onion message.
53
- let amount_msats = $invoice. amount_msats( ) ;
54
- let payment_hash = $invoice. payment_hash( ) ;
55
- do_pass_along_path(
56
- $node, $path, amount_msats, payment_hash, None , ev, false , false , None , false
57
- ) ;
58
- }
59
- }
41
+ fn route_bolt12_payment < ' a , ' b , ' c > (
42
+ node : & Node < ' a , ' b , ' c > , path : & [ & Node < ' a , ' b , ' c > ] , invoice : & Bolt12Invoice
43
+ ) {
44
+ // Monitor added when handling the invoice onion message.
45
+ check_added_monitors ( node, 1 ) ;
46
+
47
+ let mut events = node. node . get_and_clear_pending_msg_events ( ) ;
48
+ assert_eq ! ( events. len( ) , 1 ) ;
49
+ let ev = remove_first_msg_event_to_node ( & path[ 0 ] . node . get_our_node_id ( ) , & mut events) ;
50
+
51
+ // Use a fake payment_hash and bypass checking for the PaymentClaimable event since the
52
+ // invoice contains the payment_hash but it was encrypted inside an onion message.
53
+ let amount_msats = invoice. amount_msats ( ) ;
54
+ let payment_hash = invoice. payment_hash ( ) ;
55
+ do_pass_along_path (
56
+ node, path, amount_msats, payment_hash, None , ev, false , false , None , false
57
+ ) ;
60
58
}
61
59
62
- macro_rules! claim_payment {
63
- ( $node: expr, $path: expr) => {
64
- {
65
- let recipient = & $path[ $path. len( ) - 1 ] ;
66
- match get_event!( recipient, Event :: PaymentClaimable ) {
67
- Event :: PaymentClaimable {
68
- purpose: PaymentPurpose :: InvoicePayment {
69
- payment_preimage: Some ( payment_preimage) , ..
70
- } , ..
71
- } => claim_payment( $node, $path, payment_preimage) ,
72
- _ => panic!( ) ,
73
- } ;
74
- }
75
- }
60
+ fn claim_bolt12_payment < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , path : & [ & Node < ' a , ' b , ' c > ] ) {
61
+ let recipient = & path[ path. len ( ) - 1 ] ;
62
+ match get_event ! ( recipient, Event :: PaymentClaimable ) {
63
+ Event :: PaymentClaimable {
64
+ purpose : PaymentPurpose :: InvoicePayment {
65
+ payment_preimage : Some ( payment_preimage) , ..
66
+ } , ..
67
+ } => claim_payment ( node, path, payment_preimage) ,
68
+ _ => panic ! ( ) ,
69
+ } ;
76
70
}
77
71
78
72
fn extract_invoice_request < ' a , ' b , ' c > (
@@ -157,10 +151,10 @@ fn creates_and_pays_for_offer_using_blinded_paths() {
157
151
assert_eq ! ( path. introduction_node_id, alice_id) ;
158
152
}
159
153
160
- route_payment ! ( bob, & [ alice] , invoice) ;
154
+ route_bolt12_payment ( bob, & [ alice] , & invoice) ;
161
155
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
162
156
163
- claim_payment ! ( bob, & [ alice] ) ;
157
+ claim_bolt12_payment ( bob, & [ alice] ) ;
164
158
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
165
159
}
166
160
@@ -211,9 +205,9 @@ fn creates_and_pays_for_refund_using_blinded_paths() {
211
205
assert_eq ! ( path. introduction_node_id, alice_id) ;
212
206
}
213
207
214
- route_payment ! ( bob, & [ alice] , invoice) ;
208
+ route_bolt12_payment ( bob, & [ alice] , & invoice) ;
215
209
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
216
210
217
- claim_payment ! ( bob, & [ alice] ) ;
211
+ claim_bolt12_payment ( bob, & [ alice] ) ;
218
212
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
219
213
}
0 commit comments