@@ -47,7 +47,7 @@ use crate::blinded_path::IntroductionNode;
47
47
use crate :: blinded_path:: message:: BlindedMessagePath ;
48
48
use crate :: blinded_path:: payment:: { Bolt12OfferContext , Bolt12RefundContext , PaymentContext } ;
49
49
use crate :: blinded_path:: message:: { MessageContext , OffersContext } ;
50
- use crate :: events:: { ClosureReason , Event , HTLCDestination , PaymentFailureReason , PaymentPurpose } ;
50
+ use crate :: events:: { ClosureReason , Event , HTLCDestination , PaidInvoice , PaymentFailureReason , PaymentPurpose } ;
51
51
use crate :: ln:: channelmanager:: { Bolt12PaymentError , MAX_SHORT_LIVED_RELATIVE_EXPIRY , PaymentId , RecentPaymentDetails , RecipientOnionFields , Retry , self } ;
52
52
use crate :: types:: features:: Bolt12InvoiceFeatures ;
53
53
use crate :: ln:: functional_test_utils:: * ;
@@ -168,7 +168,7 @@ fn route_bolt12_payment<'a, 'b, 'c>(
168
168
}
169
169
170
170
fn claim_bolt12_payment < ' a , ' b , ' c > (
171
- node : & Node < ' a , ' b , ' c > , path : & [ & Node < ' a , ' b , ' c > ] , expected_payment_context : PaymentContext
171
+ node : & Node < ' a , ' b , ' c > , path : & [ & Node < ' a , ' b , ' c > ] , expected_payment_context : PaymentContext , invoice : & Bolt12Invoice
172
172
) {
173
173
let recipient = & path[ path. len ( ) - 1 ] ;
174
174
let payment_purpose = match get_event ! ( recipient, Event :: PaymentClaimable ) {
@@ -188,7 +188,11 @@ fn claim_bolt12_payment<'a, 'b, 'c>(
188
188
} ,
189
189
_ => panic ! ( "Unexpected payment purpose: {:?}" , payment_purpose) ,
190
190
}
191
- claim_payment ( node, path, payment_preimage) ;
191
+ if let Some ( inv) = claim_payment ( node, path, payment_preimage) {
192
+ assert_eq ! ( inv, PaidInvoice :: Bolt12Invoice ( invoice. to_owned( ) ) ) ;
193
+ } else {
194
+ panic ! ( "Expected PaidInvoice::Bolt12Invoice" ) ;
195
+ } ;
192
196
}
193
197
194
198
fn extract_offer_nonce < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , message : & OnionMessage ) -> Nonce {
@@ -597,7 +601,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
597
601
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
598
602
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
599
603
600
- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context) ;
604
+ claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice ) ;
601
605
expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
602
606
}
603
607
@@ -680,7 +684,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
680
684
route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
681
685
expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
682
686
683
- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context) ;
687
+ claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice ) ;
684
688
expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
685
689
}
686
690
@@ -747,7 +751,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
747
751
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
748
752
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
749
753
750
- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
754
+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
751
755
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
752
756
}
753
757
@@ -803,7 +807,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
803
807
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
804
808
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
805
809
806
- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
810
+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
807
811
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
808
812
}
809
813
@@ -857,7 +861,7 @@ fn pays_for_offer_without_blinded_paths() {
857
861
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
858
862
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
859
863
860
- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
864
+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
861
865
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
862
866
}
863
867
@@ -900,7 +904,7 @@ fn pays_for_refund_without_blinded_paths() {
900
904
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
901
905
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
902
906
903
- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
907
+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
904
908
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
905
909
}
906
910
@@ -1138,7 +1142,7 @@ fn creates_and_pays_for_offer_with_retry() {
1138
1142
}
1139
1143
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
1140
1144
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
1141
- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
1145
+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
1142
1146
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
1143
1147
}
1144
1148
@@ -1209,7 +1213,7 @@ fn pays_bolt12_invoice_asynchronously() {
1209
1213
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
1210
1214
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
1211
1215
1212
- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
1216
+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
1213
1217
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
1214
1218
1215
1219
assert_eq ! (
@@ -1289,7 +1293,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
1289
1293
route_bolt12_payment ( bob, & [ alice] , & invoice) ;
1290
1294
expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
1291
1295
1292
- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
1296
+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
1293
1297
expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
1294
1298
}
1295
1299
@@ -2145,7 +2149,7 @@ fn fails_paying_invoice_more_than_once() {
2145
2149
assert ! ( david. node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
2146
2150
2147
2151
// Complete paying the first invoice
2148
- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context) ;
2152
+ claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice1 ) ;
2149
2153
expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
2150
2154
}
2151
2155
0 commit comments