@@ -122,6 +122,8 @@ pub(crate) enum PendingOutboundPayment {
122
122
/// Filled in for any payment which moved to `Fulfilled` on LDK 0.0.104 or later.
123
123
payment_hash : Option < PaymentHash > ,
124
124
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 > ,
125
127
} ,
126
128
/// When we've decided to give up retrying a payment, we mark it as abandoned so we can eventually
127
129
/// generate a `PaymentFailed` event when all HTLCs have irrevocably failed.
@@ -131,6 +133,9 @@ pub(crate) enum PendingOutboundPayment {
131
133
/// Will be `None` if the payment was serialized before 0.0.115 or if downgrading to 0.0.124
132
134
/// or later with a reason that was added after.
133
135
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 > ,
134
139
} ,
135
140
}
136
141
@@ -210,6 +215,15 @@ impl PendingOutboundPayment {
210
215
}
211
216
}
212
217
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
+
213
227
fn payment_hash ( & self ) -> Option < PaymentHash > {
214
228
match self {
215
229
PendingOutboundPayment :: Legacy { .. } => None ,
@@ -236,7 +250,8 @@ impl PendingOutboundPayment {
236
250
PendingOutboundPayment :: StaticInvoiceReceived { .. } => { debug_assert ! ( false ) ; return ; } ,
237
251
} ) ;
238
252
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 } ;
240
255
}
241
256
242
257
fn mark_abandoned ( & mut self , reason : PaymentFailureReason ) {
@@ -248,6 +263,7 @@ impl PendingOutboundPayment {
248
263
} ,
249
264
_ => new_hash_set ( ) ,
250
265
} ;
266
+ let total_msat = self . total_msat ( ) ;
251
267
match self {
252
268
Self :: Retryable { payment_hash, .. } |
253
269
Self :: InvoiceReceived { payment_hash, .. } |
@@ -257,6 +273,7 @@ impl PendingOutboundPayment {
257
273
session_privs,
258
274
payment_hash : * payment_hash,
259
275
reason : Some ( reason) ,
276
+ total_msat,
260
277
} ;
261
278
} ,
262
279
_ => { }
@@ -1928,10 +1945,12 @@ impl OutboundPayments {
1928
1945
let payment_hash = PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 ) . to_byte_array ( ) ) ;
1929
1946
log_info ! ( logger, "Payment with id {} and hash {} sent!" , payment_id, payment_hash) ;
1930
1947
let fee_paid_msat = payment. get ( ) . get_pending_fee_msat ( ) ;
1948
+ let amount_msat = payment. get ( ) . total_msat ( ) ;
1931
1949
pending_events. push_back ( ( events:: Event :: PaymentSent {
1932
1950
payment_id : Some ( payment_id) ,
1933
1951
payment_preimage,
1934
1952
payment_hash,
1953
+ amount_msat,
1935
1954
fee_paid_msat,
1936
1955
} , Some ( ev_completion_action. clone ( ) ) ) ) ;
1937
1956
payment. get_mut ( ) . mark_fulfilled ( ) ;
@@ -2362,6 +2381,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
2362
2381
( 0 , session_privs, required) ,
2363
2382
( 1 , payment_hash, option) ,
2364
2383
( 3 , timer_ticks_without_htlcs, ( default_value, 0 ) ) ,
2384
+ ( 5 , total_msat, option) ,
2365
2385
} ,
2366
2386
( 2 , Retryable ) => {
2367
2387
( 0 , session_privs, required) ,
@@ -2386,6 +2406,7 @@ impl_writeable_tlv_based_enum_upgradable!(PendingOutboundPayment,
2386
2406
( 0 , session_privs, required) ,
2387
2407
( 1 , reason, upgradable_option) ,
2388
2408
( 2 , payment_hash, required) ,
2409
+ ( 3 , total_msat, option) ,
2389
2410
} ,
2390
2411
( 5 , AwaitingInvoice ) => {
2391
2412
( 0 , expiration, required) ,
0 commit comments