@@ -46,13 +46,21 @@ use std::time::Duration;
46
46
pub enum Event {
47
47
/// A sent payment was successful.
48
48
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 > ,
49
53
/// The hash of the payment.
50
54
payment_hash : PaymentHash ,
51
55
/// The total fee which was spent at intermediate hops in this payment.
52
56
fee_paid_msat : Option < u64 > ,
53
57
} ,
54
58
/// A sent payment has failed.
55
59
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 > ,
56
64
/// The hash of the payment.
57
65
payment_hash : PaymentHash ,
58
66
/// The reason why the payment failed.
@@ -62,6 +70,10 @@ pub enum Event {
62
70
} ,
63
71
/// A payment has been received.
64
72
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 > ,
65
77
/// The hash of the payment.
66
78
payment_hash : PaymentHash ,
67
79
/// The value, in thousandths of a satoshi, that has been received.
@@ -110,13 +122,16 @@ impl_writeable_tlv_based_enum!(Event,
110
122
( 0 , PaymentSuccessful ) => {
111
123
( 0 , payment_hash, required) ,
112
124
( 1 , fee_paid_msat, option) ,
125
+ ( 3 , payment_id, option) ,
113
126
} ,
114
127
( 1 , PaymentFailed ) => {
115
128
( 0 , payment_hash, required) ,
116
129
( 1 , reason, option) ,
130
+ ( 3 , payment_id, option) ,
117
131
} ,
118
132
( 2 , PaymentReceived ) => {
119
133
( 0 , payment_hash, required) ,
134
+ ( 1 , payment_id, option) ,
120
135
( 2 , amount_msat, required) ,
121
136
} ,
122
137
( 3 , ChannelReady ) => {
@@ -636,7 +651,11 @@ where
636
651
} ;
637
652
638
653
self . event_queue
639
- . add_event ( Event :: PaymentReceived { payment_hash, amount_msat } )
654
+ . add_event ( Event :: PaymentReceived {
655
+ payment_id : Some ( payment_id) ,
656
+ payment_hash,
657
+ amount_msat,
658
+ } )
640
659
. unwrap_or_else ( |e| {
641
660
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
642
661
panic ! ( "Failed to push to event queue" ) ;
@@ -684,7 +703,11 @@ where
684
703
} ) ;
685
704
686
705
self . event_queue
687
- . add_event ( Event :: PaymentSuccessful { payment_hash, fee_paid_msat } )
706
+ . add_event ( Event :: PaymentSuccessful {
707
+ payment_id : Some ( payment_id) ,
708
+ payment_hash,
709
+ fee_paid_msat,
710
+ } )
688
711
. unwrap_or_else ( |e| {
689
712
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
690
713
panic ! ( "Failed to push to event queue" ) ;
@@ -707,7 +730,11 @@ where
707
730
panic ! ( "Failed to access payment store" ) ;
708
731
} ) ;
709
732
self . event_queue
710
- . add_event ( Event :: PaymentFailed { payment_hash, reason } )
733
+ . add_event ( Event :: PaymentFailed {
734
+ payment_id : Some ( payment_id) ,
735
+ payment_hash,
736
+ reason,
737
+ } )
711
738
. unwrap_or_else ( |e| {
712
739
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
713
740
panic ! ( "Failed to push to event queue" ) ;
0 commit comments