@@ -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 {
@@ -154,6 +161,10 @@ impl PaymentDetails {
154161 update_if_necessary ! ( self . amount_msat, amount_opt) ;
155162 }
156163
164+ if let Some ( fee_paid_msat_opt) = update. fee_paid_msat {
165+ update_if_necessary ! ( self . fee_paid_msat, fee_paid_msat_opt) ;
166+ }
167+
157168 if let Some ( status) = update. status {
158169 update_if_necessary ! ( self . status, status) ;
159170 }
@@ -192,6 +203,7 @@ impl Writeable for PaymentDetails {
192203 ( 4 , None :: <Option <PaymentSecret >>, required) ,
193204 ( 5 , self . latest_update_timestamp, required) ,
194205 ( 6 , self . amount_msat, required) ,
206+ ( 7 , self . fee_paid_msat, option) ,
195207 ( 8 , self . direction, required) ,
196208 ( 10 , self . status, required)
197209 } ) ;
@@ -213,6 +225,7 @@ impl Readable for PaymentDetails {
213225 ( 4 , secret, required) ,
214226 ( 5 , latest_update_timestamp, ( default_value, unix_time_secs) ) ,
215227 ( 6 , amount_msat, required) ,
228+ ( 7 , fee_paid_msat, option) ,
216229 ( 8 , direction, required) ,
217230 ( 10 , status, required)
218231 } ) ;
@@ -253,7 +266,15 @@ impl Readable for PaymentDetails {
253266 }
254267 } ;
255268
256- Ok ( PaymentDetails { id, kind, amount_msat, direction, status, latest_update_timestamp } )
269+ Ok ( PaymentDetails {
270+ id,
271+ kind,
272+ amount_msat,
273+ fee_paid_msat,
274+ direction,
275+ status,
276+ latest_update_timestamp,
277+ } )
257278 }
258279}
259280
@@ -479,6 +500,7 @@ pub(crate) struct PaymentDetailsUpdate {
479500 pub preimage : Option < Option < PaymentPreimage > > ,
480501 pub secret : Option < Option < PaymentSecret > > ,
481502 pub amount_msat : Option < Option < u64 > > ,
503+ pub fee_paid_msat : Option < Option < u64 > > ,
482504 pub direction : Option < PaymentDirection > ,
483505 pub status : Option < PaymentStatus > ,
484506 pub confirmation_status : Option < ConfirmationStatus > ,
@@ -492,6 +514,7 @@ impl PaymentDetailsUpdate {
492514 preimage : None ,
493515 secret : None ,
494516 amount_msat : None ,
517+ fee_paid_msat : None ,
495518 direction : None ,
496519 status : None ,
497520 confirmation_status : None ,
@@ -521,6 +544,7 @@ impl From<&PaymentDetails> for PaymentDetailsUpdate {
521544 preimage : Some ( preimage) ,
522545 secret : Some ( secret) ,
523546 amount_msat : Some ( value. amount_msat ) ,
547+ fee_paid_msat : Some ( value. fee_paid_msat ) ,
524548 direction : Some ( value. direction ) ,
525549 status : Some ( value. status ) ,
526550 confirmation_status,
@@ -708,8 +732,14 @@ mod tests {
708732 . is_err( ) ) ;
709733
710734 let kind = PaymentKind :: Bolt11 { hash, preimage : None , secret : None } ;
711- let payment =
712- PaymentDetails :: new ( id, kind, None , PaymentDirection :: Inbound , PaymentStatus :: Pending ) ;
735+ let payment = PaymentDetails :: new (
736+ id,
737+ kind,
738+ None ,
739+ None ,
740+ PaymentDirection :: Inbound ,
741+ PaymentStatus :: Pending ,
742+ ) ;
713743
714744 assert_eq ! ( Ok ( false ) , payment_store. insert( payment. clone( ) ) ) ;
715745 assert ! ( payment_store. get( & id) . is_some( ) ) ;
0 commit comments