@@ -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 ) => {
@@ -594,7 +609,11 @@ where
594
609
} ;
595
610
596
611
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
+ } )
598
617
. unwrap_or_else ( |e| {
599
618
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
600
619
panic ! ( "Failed to push to event queue" ) ;
@@ -642,7 +661,11 @@ where
642
661
} ) ;
643
662
644
663
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
+ } )
646
669
. unwrap_or_else ( |e| {
647
670
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
648
671
panic ! ( "Failed to push to event queue" ) ;
@@ -665,7 +688,11 @@ where
665
688
panic ! ( "Failed to access payment store" ) ;
666
689
} ) ;
667
690
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
+ } )
669
696
. unwrap_or_else ( |e| {
670
697
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
671
698
panic ! ( "Failed to push to event queue" ) ;
0 commit comments