@@ -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 ) => {
@@ -635,7 +650,11 @@ where
635650 } ;
636651
637652 self . event_queue
638- . add_event ( Event :: PaymentReceived { payment_hash, amount_msat } )
653+ . add_event ( Event :: PaymentReceived {
654+ payment_id : Some ( payment_id) ,
655+ payment_hash,
656+ amount_msat,
657+ } )
639658 . unwrap_or_else ( |e| {
640659 log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
641660 panic ! ( "Failed to push to event queue" ) ;
@@ -683,7 +702,11 @@ where
683702 } ) ;
684703
685704 self . event_queue
686- . add_event ( Event :: PaymentSuccessful { payment_hash, fee_paid_msat } )
705+ . add_event ( Event :: PaymentSuccessful {
706+ payment_id : Some ( payment_id) ,
707+ payment_hash,
708+ fee_paid_msat,
709+ } )
687710 . unwrap_or_else ( |e| {
688711 log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
689712 panic ! ( "Failed to push to event queue" ) ;
@@ -706,7 +729,11 @@ where
706729 panic ! ( "Failed to access payment store" ) ;
707730 } ) ;
708731 self . event_queue
709- . add_event ( Event :: PaymentFailed { payment_hash, reason } )
732+ . add_event ( Event :: PaymentFailed {
733+ payment_id : Some ( payment_id) ,
734+ payment_hash,
735+ reason,
736+ } )
710737 . unwrap_or_else ( |e| {
711738 log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
712739 panic ! ( "Failed to push to event queue" ) ;
0 commit comments