@@ -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 ) => {
@@ -635,7 +650,11 @@ where
635
650
} ;
636
651
637
652
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
+ } )
639
658
. unwrap_or_else ( |e| {
640
659
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
641
660
panic ! ( "Failed to push to event queue" ) ;
@@ -683,7 +702,11 @@ where
683
702
} ) ;
684
703
685
704
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
+ } )
687
710
. unwrap_or_else ( |e| {
688
711
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
689
712
panic ! ( "Failed to push to event queue" ) ;
@@ -706,7 +729,11 @@ where
706
729
panic ! ( "Failed to access payment store" ) ;
707
730
} ) ;
708
731
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
+ } )
710
737
. unwrap_or_else ( |e| {
711
738
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
712
739
panic ! ( "Failed to push to event queue" ) ;
0 commit comments