@@ -46,13 +46,21 @@ use std::time::Duration;
4646pub enum Event {
4747 /// A sent payment was successful.
4848 PaymentSuccessful {
49+ /// A local identifier used to track the payment.
50+ ///
51+ /// Will only be `None` for events serialized with LDK Node v0.2.1 or prior.
52+ payment_id : Option < PaymentId > ,
4953 /// The hash of the payment.
5054 payment_hash : PaymentHash ,
5155 /// The total fee which was spent at intermediate hops in this payment.
5256 fee_paid_msat : Option < u64 > ,
5357 } ,
5458 /// A sent payment has failed.
5559 PaymentFailed {
60+ /// A local identifier used to track the payment.
61+ ///
62+ /// Will only be `None` for events serialized with LDK Node v0.2.1 or prior.
63+ payment_id : Option < PaymentId > ,
5664 /// The hash of the payment.
5765 payment_hash : PaymentHash ,
5866 /// The reason why the payment failed.
@@ -62,6 +70,10 @@ pub enum Event {
6270 } ,
6371 /// A payment has been received.
6472 PaymentReceived {
73+ /// A local identifier used to track the payment.
74+ ///
75+ /// Will only be `None` for events serialized with LDK Node v0.2.1 or prior.
76+ payment_id : Option < PaymentId > ,
6577 /// The hash of the payment.
6678 payment_hash : PaymentHash ,
6779 /// The value, in thousandths of a satoshi, that has been received.
@@ -110,13 +122,16 @@ impl_writeable_tlv_based_enum!(Event,
110122 ( 0 , PaymentSuccessful ) => {
111123 ( 0 , payment_hash, required) ,
112124 ( 1 , fee_paid_msat, option) ,
125+ ( 3 , payment_id, option) ,
113126 } ,
114127 ( 1 , PaymentFailed ) => {
115128 ( 0 , payment_hash, required) ,
116129 ( 1 , reason, option) ,
130+ ( 3 , payment_id, option) ,
117131 } ,
118132 ( 2 , PaymentReceived ) => {
119133 ( 0 , payment_hash, required) ,
134+ ( 1 , payment_id, option) ,
120135 ( 2 , amount_msat, required) ,
121136 } ,
122137 ( 3 , ChannelReady ) => {
@@ -594,7 +609,11 @@ where
594609 } ;
595610
596611 self . event_queue
597- . add_event ( Event :: PaymentReceived { payment_hash, amount_msat } )
612+ . add_event ( Event :: PaymentReceived {
613+ payment_id : Some ( payment_id) ,
614+ payment_hash,
615+ amount_msat,
616+ } )
598617 . unwrap_or_else ( |e| {
599618 log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
600619 panic ! ( "Failed to push to event queue" ) ;
@@ -642,7 +661,11 @@ where
642661 } ) ;
643662
644663 self . event_queue
645- . add_event ( Event :: PaymentSuccessful { payment_hash, fee_paid_msat } )
664+ . add_event ( Event :: PaymentSuccessful {
665+ payment_id : Some ( payment_id) ,
666+ payment_hash,
667+ fee_paid_msat,
668+ } )
646669 . unwrap_or_else ( |e| {
647670 log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
648671 panic ! ( "Failed to push to event queue" ) ;
@@ -665,7 +688,11 @@ where
665688 panic ! ( "Failed to access payment store" ) ;
666689 } ) ;
667690 self . event_queue
668- . add_event ( Event :: PaymentFailed { payment_hash, reason } )
691+ . add_event ( Event :: PaymentFailed {
692+ payment_id : Some ( payment_id) ,
693+ payment_hash,
694+ reason,
695+ } )
669696 . unwrap_or_else ( |e| {
670697 log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
671698 panic ! ( "Failed to push to event queue" ) ;
0 commit comments