@@ -47,7 +47,7 @@ use crate::blinded_path::IntroductionNode;
4747use crate :: blinded_path:: message:: BlindedMessagePath ;
4848use crate :: blinded_path:: payment:: { Bolt12OfferContext , Bolt12RefundContext , PaymentContext } ;
4949use crate :: blinded_path:: message:: OffersContext ;
50- use crate :: events:: { ClosureReason , Event , HTLCDestination , PaymentFailureReason , PaymentPurpose } ;
50+ use crate :: events:: { ClosureReason , Event , HTLCDestination , PaidBolt12Invoice , PaymentFailureReason , PaymentPurpose } ;
5151use crate :: ln:: channelmanager:: { Bolt12PaymentError , MAX_SHORT_LIVED_RELATIVE_EXPIRY , PaymentId , RecentPaymentDetails , RecipientOnionFields , Retry , self } ;
5252use crate :: types:: features:: Bolt12InvoiceFeatures ;
5353use crate :: ln:: functional_test_utils:: * ;
@@ -167,7 +167,7 @@ fn route_bolt12_payment<'a, 'b, 'c>(
167167}
168168
169169fn claim_bolt12_payment < ' a , ' b , ' c > (
170- node : & Node < ' a , ' b , ' c > , path : & [ & Node < ' a , ' b , ' c > ] , expected_payment_context : PaymentContext
170+ node : & Node < ' a , ' b , ' c > , path : & [ & Node < ' a , ' b , ' c > ] , expected_payment_context : PaymentContext , invoice : & Bolt12Invoice
171171) {
172172 let recipient = & path[ path. len ( ) - 1 ] ;
173173 let payment_purpose = match get_event ! ( recipient, Event :: PaymentClaimable ) {
@@ -187,7 +187,11 @@ fn claim_bolt12_payment<'a, 'b, 'c>(
187187 } ,
188188 _ => panic ! ( "Unexpected payment purpose: {:?}" , payment_purpose) ,
189189 }
190- claim_payment ( node, path, payment_preimage) ;
190+ if let Some ( inv) = claim_payment ( node, path, payment_preimage) {
191+ assert_eq ! ( inv, PaidBolt12Invoice :: Bolt12Invoice ( invoice. to_owned( ) ) ) ;
192+ } else {
193+ panic ! ( "Expected PaidInvoice::Bolt12Invoice" ) ;
194+ } ;
191195}
192196
193197fn extract_offer_nonce < ' a , ' b , ' c > ( node : & Node < ' a , ' b , ' c > , message : & OnionMessage ) -> Nonce {
@@ -591,7 +595,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
591595 route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
592596 expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
593597
594- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context) ;
598+ claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice ) ;
595599 expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
596600}
597601
@@ -674,7 +678,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
674678 route_bolt12_payment ( david, & [ charlie, bob, alice] , & invoice) ;
675679 expect_recent_payment ! ( david, RecentPaymentDetails :: Pending , payment_id) ;
676680
677- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context) ;
681+ claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice ) ;
678682 expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
679683}
680684
@@ -741,7 +745,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
741745 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
742746 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
743747
744- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
748+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
745749 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
746750}
747751
@@ -797,7 +801,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
797801 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
798802 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
799803
800- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
804+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
801805 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
802806}
803807
@@ -851,7 +855,7 @@ fn pays_for_offer_without_blinded_paths() {
851855 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
852856 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
853857
854- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
858+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
855859 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
856860}
857861
@@ -894,7 +898,7 @@ fn pays_for_refund_without_blinded_paths() {
894898 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
895899 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
896900
897- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
901+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
898902 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
899903}
900904
@@ -1132,7 +1136,7 @@ fn creates_and_pays_for_offer_with_retry() {
11321136 }
11331137 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
11341138 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
1135- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
1139+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
11361140 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
11371141}
11381142
@@ -1203,7 +1207,7 @@ fn pays_bolt12_invoice_asynchronously() {
12031207 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
12041208 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
12051209
1206- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
1210+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
12071211 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
12081212
12091213 assert_eq ! (
@@ -1283,7 +1287,7 @@ fn creates_offer_with_blinded_path_using_unannounced_introduction_node() {
12831287 route_bolt12_payment ( bob, & [ alice] , & invoice) ;
12841288 expect_recent_payment ! ( bob, RecentPaymentDetails :: Pending , payment_id) ;
12851289
1286- claim_bolt12_payment ( bob, & [ alice] , payment_context) ;
1290+ claim_bolt12_payment ( bob, & [ alice] , payment_context, & invoice ) ;
12871291 expect_recent_payment ! ( bob, RecentPaymentDetails :: Fulfilled , payment_id) ;
12881292}
12891293
@@ -2139,7 +2143,7 @@ fn fails_paying_invoice_more_than_once() {
21392143 assert ! ( david. node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
21402144
21412145 // Complete paying the first invoice
2142- claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context) ;
2146+ claim_bolt12_payment ( david, & [ charlie, bob, alice] , payment_context, & invoice1 ) ;
21432147 expect_recent_payment ! ( david, RecentPaymentDetails :: Fulfilled , payment_id) ;
21442148}
21452149
0 commit comments