Merge pull request #1830 from jurvis/jurvis/2022-10-calculate-inflight-with-chanmanager
[rust-lightning] / lightning / src / ln / channel.rs
index 2980b0f7cd56cf1d45452a6beba9199cb6c66899..95ae6987710d904a5508de4960df008340ae1779 100644 (file)
@@ -5950,6 +5950,17 @@ impl<Signer: Sign> Channel<Signer> {
                self.update_time_counter += 1;
                (monitor_update, dropped_outbound_htlcs)
        }
+
+       pub fn inflight_htlc_sources(&self) -> impl Iterator<Item=&HTLCSource> {
+               self.holding_cell_htlc_updates.iter()
+                       .flat_map(|htlc_update| {
+                               match htlc_update {
+                                       HTLCUpdateAwaitingACK::AddHTLC { source, .. } => { Some(source) }
+                                       _ => None
+                               }
+                       })
+                       .chain(self.pending_outbound_htlcs.iter().map(|htlc| &htlc.source))
+       }
 }
 
 const SERIALIZATION_VERSION: u8 = 2;