@@ -122,6 +122,8 @@ pub(crate) enum PendingOutboundPayment {
122122 /// Filled in for any payment which moved to `Fulfilled` on LDK 0.0.104 or later.
123123 payment_hash : Option < PaymentHash > ,
124124 timer_ticks_without_htlcs : u8 ,
125+ /// The total payment amount across all paths, used to be able to issue `PaymentSent`.
126+ total_msat : Option < u64 > ,
125127 } ,
126128 /// When we've decided to give up retrying a payment, we mark it as abandoned so we can eventually
127129 /// generate a `PaymentFailed` event when all HTLCs have irrevocably failed.
@@ -131,6 +133,9 @@ pub(crate) enum PendingOutboundPayment {
131133 /// Will be `None` if the payment was serialized before 0.0.115 or if downgrading to 0.0.124
132134 /// or later with a reason that was added after.
133135 reason : Option < PaymentFailureReason > ,
136+ /// The total payment amount across all paths, used to be able to issue `PaymentSent` if
137+ /// an HTLC still happens to succeed after we marked the payment as abandoned.
138+ total_msat : Option < u64 > ,
134139 } ,
135140}
136141
@@ -210,6 +215,15 @@ impl PendingOutboundPayment {
210215 }
211216 }
212217
218+ fn total_msat ( & self ) -> Option < u64 > {
219+ match self {
220+ PendingOutboundPayment :: Retryable { total_msat, .. } => Some ( * total_msat) ,
221+ PendingOutboundPayment :: Fulfilled { total_msat, .. } => * total_msat,
222+ PendingOutboundPayment :: Abandoned { total_msat, .. } => * total_msat,
223+ _ => None ,
224+ }
225+ }
226+
213227 fn payment_hash ( & self ) -> Option < PaymentHash > {
214228 match self {
215229 PendingOutboundPayment :: Legacy { .. } => None ,
@@ -236,7 +250,8 @@ impl PendingOutboundPayment {
236250 PendingOutboundPayment :: StaticInvoiceReceived { .. } => { debug_assert ! ( false ) ; return ; } ,
237251 } ) ;
238252 let payment_hash = self . payment_hash ( ) ;
239- * self = PendingOutboundPayment :: Fulfilled { session_privs, payment_hash, timer_ticks_without_htlcs : 0 } ;
253+ let total_msat = self . total_msat ( ) ;
254+ * self = PendingOutboundPayment :: Fulfilled { session_privs, payment_hash, timer_ticks_without_htlcs : 0 , total_msat } ;
240255 }
241256
242257 fn mark_abandoned ( & mut self , reason : PaymentFailureReason ) {
@@ -248,6 +263,7 @@ impl PendingOutboundPayment {
248263 } ,
249264 _ => new_hash_set ( ) ,
250265 } ;
266+ let total_msat = self . total_msat ( ) ;
251267 match self {
252268 Self :: Retryable { payment_hash, .. } |
253269 Self :: InvoiceReceived { payment_hash, .. } |
@@ -257,6 +273,7 @@ impl PendingOutboundPayment {
257273 session_privs,
258274 payment_hash : * payment_hash,
259275 reason : Some ( reason) ,
276+ total_msat,
260277 } ;
261278 } ,
262279 _ => { }
@@ -1928,10 +1945,12 @@ impl OutboundPayments {
19281945 let payment_hash = PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 ) . to_byte_array ( ) ) ;
19291946 log_info ! ( logger, "Payment with id {} and hash {} sent!" , payment_id, payment_hash) ;
19301947 let fee_paid_msat = payment. get ( ) . get_pending_fee_msat ( ) ;
1948+ let amount_msat = payment. get ( ) . total_msat ( ) ;
19311949 pending_events. push_back ( ( events:: Event :: PaymentSent {
19321950 payment_id : Some ( payment_id) ,
19331951 payment_preimage,
19341952 payment_hash,
1953+ amount_msat,
19351954 fee_paid_msat,
19361955 } , Some ( ev_completion_action. clone ( ) ) ) ) ;
19371956 payment. get_mut ( ) . mark_fulfilled ( ) ;
@@ -2362,6 +2381,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
23622381 ( 0 , session_privs, required) ,
23632382 ( 1 , payment_hash, option) ,
23642383 ( 3 , timer_ticks_without_htlcs, ( default_value, 0 ) ) ,
2384+ ( 5 , total_msat, option) ,
23652385 } ,
23662386 ( 2 , Retryable ) => {
23672387 ( 0 , session_privs, required) ,
@@ -2386,6 +2406,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
23862406 ( 0 , session_privs, required) ,
23872407 ( 1 , reason, upgradable_option) ,
23882408 ( 2 , payment_hash, required) ,
2409+ ( 3 , total_msat, option) ,
23892410 } ,
23902411 ( 5 , AwaitingInvoice ) => {
23912412 ( 0 , expiration, required) ,
0 commit comments