@@ -485,6 +485,14 @@ impl PendingOutboundPayment {
485
485
_ => false ,
486
486
}
487
487
}
488
+
489
+ fn is_legacy ( & self ) -> bool {
490
+ match self {
491
+ PendingOutboundPayment :: Legacy { .. } => true ,
492
+ _ => false ,
493
+ }
494
+ }
495
+
488
496
fn abandoned ( & self ) -> bool {
489
497
match self {
490
498
PendingOutboundPayment :: Abandoned { .. } => true ,
@@ -1203,6 +1211,17 @@ impl ChannelDetails {
1203
1211
}
1204
1212
}
1205
1213
1214
+ pub enum PendingPaymentStatus {
1215
+ Retryable ,
1216
+ Fulfilled ,
1217
+ Abandoned ,
1218
+ }
1219
+
1220
+ pub struct PendingPaymentDetails {
1221
+ status : PendingPaymentStatus ,
1222
+ total_msat : Option < u64 > ,
1223
+ }
1224
+
1206
1225
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
1207
1226
/// Err() type describing which state the payment is in, see the description of individual enum
1208
1227
/// states for more.
@@ -1770,6 +1789,27 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
1770
1789
self . list_channels_with_filter ( |& ( _, ref channel) | channel. is_live ( ) )
1771
1790
}
1772
1791
1792
+ pub fn list_pending_payments ( & self ) -> Vec < PendingPaymentDetails > {
1793
+ self . pending_outbound_payments . lock ( ) . unwrap ( ) . iter ( )
1794
+ . filter ( |& ( _, value) | { !value. is_legacy ( ) } )
1795
+ . map ( |( _, pending_outbound_payment) | {
1796
+ match pending_outbound_payment {
1797
+ PendingOutboundPayment :: Retryable { total_msat, .. } => {
1798
+ PendingPaymentDetails { status : PendingPaymentStatus :: Retryable , total_msat : Some ( * total_msat) }
1799
+ } ,
1800
+ PendingOutboundPayment :: Abandoned { .. } => {
1801
+ PendingPaymentDetails { status : PendingPaymentStatus :: Abandoned , total_msat : None }
1802
+ } ,
1803
+ PendingOutboundPayment :: Fulfilled { .. } => {
1804
+ PendingPaymentDetails { status : PendingPaymentStatus :: Fulfilled , total_msat : None }
1805
+ } ,
1806
+ _ => { unreachable ! ( ) }
1807
+ }
1808
+
1809
+ } )
1810
+ . collect ( )
1811
+ }
1812
+
1773
1813
/// Helper function that issues the channel close events
1774
1814
fn issue_channel_close_events ( & self , channel : & Channel < <K :: Target as KeysInterface >:: Signer > , closure_reason : ClosureReason ) {
1775
1815
let mut pending_events_lock = self . pending_events . lock ( ) . unwrap ( ) ;
0 commit comments