@@ -32,7 +32,7 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
3232use lightning:: impl_writeable_tlv_based_enum;
3333use lightning:: ln:: channelmanager:: PaymentId ;
3434use lightning:: ln:: types:: ChannelId ;
35- use lightning:: ln:: PaymentHash ;
35+ use lightning:: ln:: { PaymentHash , PaymentPreimage } ;
3636use lightning:: routing:: gossip:: NodeId ;
3737use lightning:: util:: errors:: APIError ;
3838use lightning:: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
@@ -65,6 +65,12 @@ pub enum Event {
6565 payment_id : Option < PaymentId > ,
6666 /// The hash of the payment.
6767 payment_hash : PaymentHash ,
68+ /// The preimage to the `payment_hash`.
69+ ///
70+ /// Note that this serves as a payment receipt.
71+ ///
72+ /// Will only be `None` for events serialized with LDK Node v0.4.2 or prior.
73+ payment_preimage : Option < PaymentPreimage > ,
6874 /// The total fee which was spent at intermediate hops in this payment.
6975 fee_paid_msat : Option < u64 > ,
7076 } ,
@@ -163,6 +169,7 @@ impl_writeable_tlv_based_enum!(Event,
163169 ( 0 , payment_hash, required) ,
164170 ( 1 , fee_paid_msat, option) ,
165171 ( 3 , payment_id, option) ,
172+ ( 5 , payment_preimage, option) ,
166173 } ,
167174 ( 1 , PaymentFailed ) => {
168175 ( 0 , payment_hash, option) ,
@@ -870,6 +877,7 @@ where
870877 let event = Event :: PaymentSuccessful {
871878 payment_id : Some ( payment_id) ,
872879 payment_hash,
880+ payment_preimage : Some ( payment_preimage) ,
873881 fee_paid_msat,
874882 } ;
875883
0 commit comments