@@ -14,8 +14,8 @@ use crate::io::{
14
14
use crate :: logger:: { log_error, log_info, Logger } ;
15
15
16
16
use lightning:: chain:: chaininterface:: ConfirmationTarget ;
17
- use lightning:: events:: Event as LdkEvent ;
18
17
use lightning:: events:: PaymentPurpose ;
18
+ use lightning:: events:: { Event as LdkEvent , PaymentFailureReason } ;
19
19
use lightning:: impl_writeable_tlv_based_enum;
20
20
use lightning:: ln:: { ChannelId , PaymentHash } ;
21
21
use lightning:: routing:: gossip:: NodeId ;
@@ -52,6 +52,10 @@ pub enum Event {
52
52
PaymentFailed {
53
53
/// The hash of the payment.
54
54
payment_hash : PaymentHash ,
55
+ /// The reason why the payment failed.
56
+ ///
57
+ /// This will be `None` for events serialized by LDK Node v0.2.1 and prior.
58
+ reason : Option < PaymentFailureReason > ,
55
59
} ,
56
60
/// A payment has been received.
57
61
PaymentReceived {
@@ -103,6 +107,7 @@ impl_writeable_tlv_based_enum!(Event,
103
107
} ,
104
108
( 1 , PaymentFailed ) => {
105
109
( 0 , payment_hash, required) ,
110
+ ( 1 , reason, option) ,
106
111
} ,
107
112
( 2 , PaymentReceived ) => {
108
113
( 0 , payment_hash, required) ,
@@ -609,11 +614,12 @@ where
609
614
panic ! ( "Failed to push to event queue" ) ;
610
615
} ) ;
611
616
}
612
- LdkEvent :: PaymentFailed { payment_hash, .. } => {
617
+ LdkEvent :: PaymentFailed { payment_hash, reason , .. } => {
613
618
log_info ! (
614
619
self . logger,
615
- "Failed to send payment to payment hash {:?}." ,
616
- hex_utils:: to_string( & payment_hash. 0 )
620
+ "Failed to send payment to payment hash {:?} due to {:?}." ,
621
+ hex_utils:: to_string( & payment_hash. 0 ) ,
622
+ reason
617
623
) ;
618
624
619
625
let update = PaymentDetailsUpdate {
@@ -624,12 +630,12 @@ where
624
630
log_error ! ( self . logger, "Failed to access payment store: {}" , e) ;
625
631
panic ! ( "Failed to access payment store" ) ;
626
632
} ) ;
627
- self . event_queue . add_event ( Event :: PaymentFailed { payment_hash } ) . unwrap_or_else (
628
- |e| {
633
+ self . event_queue
634
+ . add_event ( Event :: PaymentFailed { payment_hash, reason } )
635
+ . unwrap_or_else ( |e| {
629
636
log_error ! ( self . logger, "Failed to push to event queue: {}" , e) ;
630
637
panic ! ( "Failed to push to event queue" ) ;
631
- } ,
632
- ) ;
638
+ } ) ;
633
639
}
634
640
635
641
LdkEvent :: PaymentPathSuccessful { .. } => { }
0 commit comments