@@ -42,6 +42,13 @@ pub struct PaymentDetails {
4242 pub kind : PaymentKind ,
4343 /// The amount transferred.
4444 pub amount_msat : Option < u64 > ,
45+ /// The fees that were paid for this payment.
46+ ///
47+ /// For Lightning payments, this will only be updated for outbound payments once they
48+ /// succeeded.
49+ ///
50+ /// Will be `None` for Lightning payments made with LDK Node v0.4.x and earlier.
51+ pub fee_paid_msat : Option < u64 > ,
4552 /// The direction of the payment.
4653 pub direction : PaymentDirection ,
4754 /// The status of the payment.
@@ -52,14 +59,14 @@ pub struct PaymentDetails {
5259
5360impl PaymentDetails {
5461 pub ( crate ) fn new (
55- id : PaymentId , kind : PaymentKind , amount_msat : Option < u64 > , direction : PaymentDirection ,
56- status : PaymentStatus ,
62+ id : PaymentId , kind : PaymentKind , amount_msat : Option < u64 > , fee_paid_msat : Option < u64 > ,
63+ direction : PaymentDirection , status : PaymentStatus ,
5764 ) -> Self {
5865 let latest_update_timestamp = SystemTime :: now ( )
5966 . duration_since ( UNIX_EPOCH )
6067 . unwrap_or ( Duration :: from_secs ( 0 ) )
6168 . as_secs ( ) ;
62- Self { id, kind, amount_msat, direction, status, latest_update_timestamp }
69+ Self { id, kind, amount_msat, fee_paid_msat , direction, status, latest_update_timestamp }
6370 }
6471
6572 pub ( crate ) fn update ( & mut self , update : & PaymentDetailsUpdate ) -> bool {
@@ -192,6 +199,7 @@ impl Writeable for PaymentDetails {
192199 ( 4 , None :: <Option <PaymentSecret >>, required) ,
193200 ( 5 , self . latest_update_timestamp, required) ,
194201 ( 6 , self . amount_msat, required) ,
202+ ( 7 , self . fee_paid_msat, option) ,
195203 ( 8 , self . direction, required) ,
196204 ( 10 , self . status, required)
197205 } ) ;
@@ -213,6 +221,7 @@ impl Readable for PaymentDetails {
213221 ( 4 , secret, required) ,
214222 ( 5 , latest_update_timestamp, ( default_value, unix_time_secs) ) ,
215223 ( 6 , amount_msat, required) ,
224+ ( 7 , fee_paid_msat, option) ,
216225 ( 8 , direction, required) ,
217226 ( 10 , status, required)
218227 } ) ;
@@ -253,7 +262,15 @@ impl Readable for PaymentDetails {
253262 }
254263 } ;
255264
256- Ok ( PaymentDetails { id, kind, amount_msat, direction, status, latest_update_timestamp } )
265+ Ok ( PaymentDetails {
266+ id,
267+ kind,
268+ amount_msat,
269+ fee_paid_msat,
270+ direction,
271+ status,
272+ latest_update_timestamp,
273+ } )
257274 }
258275}
259276
@@ -302,8 +319,6 @@ pub enum PaymentKind {
302319 txid : Txid ,
303320 /// The confirmation status of this payment.
304321 status : ConfirmationStatus ,
305- /// The on-chain fees that were paid for this payment.
306- fee_msat : u64 ,
307322 } ,
308323 /// A [BOLT 11] payment.
309324 ///
@@ -396,7 +411,6 @@ impl_writeable_tlv_based_enum!(PaymentKind,
396411 ( 0 , Onchain ) => {
397412 ( 0 , txid, required) ,
398413 ( 2 , status, required) ,
399- ( 4 , fee_msat, required) ,
400414 } ,
401415 ( 2 , Bolt11 ) => {
402416 ( 0 , hash, required) ,
@@ -482,6 +496,7 @@ pub(crate) struct PaymentDetailsUpdate {
482496 pub preimage : Option < Option < PaymentPreimage > > ,
483497 pub secret : Option < Option < PaymentSecret > > ,
484498 pub amount_msat : Option < Option < u64 > > ,
499+ pub fee_paid_msat : Option < Option < u64 > > ,
485500 pub direction : Option < PaymentDirection > ,
486501 pub status : Option < PaymentStatus > ,
487502 pub confirmation_status : Option < ConfirmationStatus > ,
@@ -495,6 +510,7 @@ impl PaymentDetailsUpdate {
495510 preimage : None ,
496511 secret : None ,
497512 amount_msat : None ,
513+ fee_paid_msat : None ,
498514 direction : None ,
499515 status : None ,
500516 confirmation_status : None ,
@@ -524,6 +540,7 @@ impl From<&PaymentDetails> for PaymentDetailsUpdate {
524540 preimage : Some ( preimage) ,
525541 secret : Some ( secret) ,
526542 amount_msat : Some ( value. amount_msat ) ,
543+ fee_paid_msat : Some ( value. fee_paid_msat ) ,
527544 direction : Some ( value. direction ) ,
528545 status : Some ( value. status ) ,
529546 confirmation_status,
@@ -711,8 +728,14 @@ mod tests {
711728 . is_err( ) ) ;
712729
713730 let kind = PaymentKind :: Bolt11 { hash, preimage : None , secret : None } ;
714- let payment =
715- PaymentDetails :: new ( id, kind, None , PaymentDirection :: Inbound , PaymentStatus :: Pending ) ;
731+ let payment = PaymentDetails :: new (
732+ id,
733+ kind,
734+ None ,
735+ None ,
736+ PaymentDirection :: Inbound ,
737+ PaymentStatus :: Pending ,
738+ ) ;
716739
717740 assert_eq ! ( Ok ( false ) , payment_store. insert( payment. clone( ) ) ) ;
718741 assert ! ( payment_store. get( & id) . is_some( ) ) ;
0 commit comments