+ }
+ }
+
+ for ref htlc in self.pending_inbound_htlcs.iter() {
+ let include = match htlc.state {
+ InboundHTLCState::RemoteAnnounced => !generated_by_local,
+ InboundHTLCState::AwaitingRemoteRevokeToAnnounce => !generated_by_local,
+ InboundHTLCState::AwaitingAnnouncedRemoteRevoke => true,
+ InboundHTLCState::Committed => true,
+ InboundHTLCState::LocalRemoved => !generated_by_local,
+ };
+
+ if include {
+ add_htlc_output!(htlc, false);
+ remote_htlc_total_msat += htlc.amount_msat;
+ } else {
+ match htlc.state {
+ InboundHTLCState::LocalRemoved => {
+ if generated_by_local && htlc.local_removed_fulfilled {
+ value_to_self_msat_offset += htlc.amount_msat as i64;
+ }
+ },
+ _ => {},
+ }
+ }
+ }
+
+ for ref htlc in self.pending_outbound_htlcs.iter() {
+ let include = match htlc.state {
+ OutboundHTLCState::LocalAnnounced => generated_by_local,
+ OutboundHTLCState::Committed => true,
+ OutboundHTLCState::RemoteRemoved => generated_by_local,
+ OutboundHTLCState::AwaitingRemoteRevokeToRemove => generated_by_local,
+ OutboundHTLCState::AwaitingRemovedRemoteRevoke => false,
+ };
+
+ if include {
+ add_htlc_output!(htlc, true);
+ local_htlc_total_msat += htlc.amount_msat;