@@ -6,6 +6,7 @@ use crate::logger::{log_error, Logger};
66use crate :: types:: DynStore ;
77use crate :: Error ;
88
9+ use lightning:: chain:: BestBlock ;
910use lightning:: ln:: channelmanager:: PaymentId ;
1011use lightning:: ln:: msgs:: DecodeError ;
1112use lightning:: ln:: { PaymentHash , PaymentPreimage , PaymentSecret } ;
@@ -37,6 +38,14 @@ pub struct PaymentDetails {
3738 pub status : PaymentStatus ,
3839 /// The timestamp, in seconds since start of the UNIX epoch, when this entry was last updated.
3940 pub latest_update_timestamp : u64 ,
41+ /// The transaction id of the payment.
42+ ///
43+ /// This field is only set if the payment is on-chain.
44+ pub txid : Option < bitcoin:: Txid > ,
45+ /// The best known block which the transaction was included in.
46+ ///
47+ /// This field is only set if the payment is on-chain.
48+ pub best_block : Option < BestBlock > ,
4049}
4150
4251impl PaymentDetails {
@@ -48,7 +57,16 @@ impl PaymentDetails {
4857 . duration_since ( UNIX_EPOCH )
4958 . unwrap_or ( Duration :: from_secs ( 0 ) )
5059 . as_secs ( ) ;
51- Self { id, kind, amount_msat, direction, status, latest_update_timestamp }
60+ Self {
61+ id,
62+ kind,
63+ amount_msat,
64+ direction,
65+ status,
66+ latest_update_timestamp,
67+ txid : None ,
68+ best_block : None ,
69+ }
5270 }
5371}
5472
@@ -67,7 +85,9 @@ impl Writeable for PaymentDetails {
6785 ( 5 , self . latest_update_timestamp, required) ,
6886 ( 6 , self . amount_msat, required) ,
6987 ( 8 , self . direction, required) ,
70- ( 10 , self . status, required)
88+ ( 10 , self . status, required) ,
89+ ( 11 , self . txid, option) ,
90+ ( 13 , self . best_block, option) ,
7191 } ) ;
7292 Ok ( ( ) )
7393 }
@@ -88,7 +108,9 @@ impl Readable for PaymentDetails {
88108 ( 5 , latest_update_timestamp, ( default_value, unix_time_secs) ) ,
89109 ( 6 , amount_msat, required) ,
90110 ( 8 , direction, required) ,
91- ( 10 , status, required)
111+ ( 10 , status, required) ,
112+ ( 11 , txid, option) ,
113+ ( 13 , best_block, option) ,
92114 } ) ;
93115
94116 let id: PaymentId = id. 0 . ok_or ( DecodeError :: InvalidValue ) ?;
@@ -127,7 +149,16 @@ impl Readable for PaymentDetails {
127149 }
128150 } ;
129151
130- Ok ( PaymentDetails { id, kind, amount_msat, direction, status, latest_update_timestamp } )
152+ Ok ( PaymentDetails {
153+ id,
154+ kind,
155+ amount_msat,
156+ direction,
157+ status,
158+ latest_update_timestamp,
159+ txid,
160+ best_block,
161+ } )
131162 }
132163}
133164
@@ -293,6 +324,8 @@ pub(crate) struct PaymentDetailsUpdate {
293324 pub amount_msat : Option < Option < u64 > > ,
294325 pub direction : Option < PaymentDirection > ,
295326 pub status : Option < PaymentStatus > ,
327+ pub txid : Option < bitcoin:: Txid > ,
328+ pub best_block : Option < BestBlock > ,
296329}
297330
298331impl PaymentDetailsUpdate {
@@ -305,6 +338,8 @@ impl PaymentDetailsUpdate {
305338 amount_msat : None ,
306339 direction : None ,
307340 status : None ,
341+ txid : None ,
342+ best_block : None ,
308343 }
309344 }
310345}
@@ -415,6 +450,14 @@ where
415450 payment. status = status;
416451 }
417452
453+ if let Some ( txid) = update. txid {
454+ payment. txid = Some ( txid) ;
455+ }
456+
457+ if let Some ( best_block) = update. best_block {
458+ payment. best_block = Some ( best_block) ;
459+ }
460+
418461 payment. latest_update_timestamp = SystemTime :: now ( )
419462 . duration_since ( UNIX_EPOCH )
420463 . unwrap_or ( Duration :: from_secs ( 0 ) )
0 commit comments