diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 0425504a8a1..9a0bac8cef0 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -173,9 +173,6 @@ enum InboundHTLCState { /// This can be used to inspect what next message an HTLC is waiting for to advance its state. #[derive(Clone, Debug, PartialEq)] pub enum InboundHTLCStateDetails { - /// The remote node announced the HTLC with update_add_htlc but the HTLC is not added to any - /// commitment transactions yet. - RemoteAnnounced, /// We have added this HTLC in our commitment transaction by receiving commitment_signed and /// returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote /// before this HTLC is included on the remote commitment transaction. @@ -200,33 +197,31 @@ pub enum InboundHTLCStateDetails { AwaitingRemoteRevokeToRemoveFail, } -impl From<&InboundHTLCState> for InboundHTLCStateDetails { - fn from(state: &InboundHTLCState) -> InboundHTLCStateDetails { +impl From<&InboundHTLCState> for Option { + fn from(state: &InboundHTLCState) -> Option { match state { - InboundHTLCState::RemoteAnnounced(_) => - InboundHTLCStateDetails::RemoteAnnounced, + InboundHTLCState::RemoteAnnounced(_) => None, InboundHTLCState::AwaitingRemoteRevokeToAnnounce(_) => - InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd), InboundHTLCState::AwaitingAnnouncedRemoteRevoke(_) => - InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd), InboundHTLCState::Committed => - InboundHTLCStateDetails::Committed, + Some(InboundHTLCStateDetails::Committed), InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(_)) => - InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail, + Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail), InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailMalformed(_)) => - InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail, + Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail), InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(_)) => - InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill, + Some(InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill), } } } impl_writeable_tlv_based_enum!(InboundHTLCStateDetails, - (0, RemoteAnnounced) => {}, - (2, AwaitingRemoteRevokeToAdd) => {}, - (4, Committed) => {}, - (6, AwaitingRemoteRevokeToRemoveFulfill) => {}, - (8, AwaitingRemoteRevokeToRemoveFail) => {}; + (0, AwaitingRemoteRevokeToAdd) => {}, + (2, Committed) => {}, + (4, AwaitingRemoteRevokeToRemoveFulfill) => {}, + (6, AwaitingRemoteRevokeToRemoveFail) => {}; ); struct InboundHTLCOutput { @@ -2219,14 +2214,16 @@ impl ChannelContext where SP::Target: SignerProvider { }; let holder_dust_limit_success_sat = htlc_success_dust_limit + self.holder_dust_limit_satoshis; for htlc in self.pending_inbound_htlcs.iter() { - inbound_details.push(InboundHTLCDetails{ - htlc_id: htlc.htlc_id, - amount_msat: htlc.amount_msat, - cltv_expiry: htlc.cltv_expiry, - payment_hash: htlc.payment_hash, - state: holding_cell_states.remove(&htlc.htlc_id).unwrap_or((&htlc.state).into()), - is_dust: htlc.amount_msat / 1000 < holder_dust_limit_success_sat, - }); + if let Some(state_details) = (&htlc.state).into() { + inbound_details.push(InboundHTLCDetails{ + htlc_id: htlc.htlc_id, + amount_msat: htlc.amount_msat, + cltv_expiry: htlc.cltv_expiry, + payment_hash: htlc.payment_hash, + state: holding_cell_states.remove(&htlc.htlc_id).unwrap_or(state_details), + is_dust: htlc.amount_msat / 1000 < holder_dust_limit_success_sat, + }); + } } inbound_details }