Skip to content

Commit

Permalink
Remove distinction on PendingHTLCStatus
Browse files Browse the repository at this point in the history
This will be removed as part of #2845.
  • Loading branch information
wvanlint committed Feb 1, 2024
1 parent 58e8e16 commit 8884077
Showing 1 changed file with 13 additions and 38 deletions.
51 changes: 13 additions & 38 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,28 +175,11 @@ enum InboundHTLCState {
pub enum InboundHTLCStateDetails {
/// The remote node announced the HTLC with update_add_htlc but the HTLC is not added to any
/// commitment transactions yet.
///
/// We intend to forward the HTLC as it is correctly formed and is forwardable to the next hop.
RemoteAnnouncedForward,
/// The remote node announced the HTLC with update_add_htlc but the HTLC is not added to any
/// commitment transactions yet.
///
/// We intend to fail the HTLC as it is malformed or we are unable to forward to the next hop,
/// for example if the peer is disconnected or not enough capacity is available.
RemoteAnnouncedFail,
/// 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.
///
/// We intend to forward the HTLC as it is correctly formed and is forwardable to the next hop.
AwaitingRemoteRevokeToAddForward,
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.
///
/// We intend to fail the HTLC as it is malformed or we are unable to forward to the next hop,
/// for example if the peer is disconnected or not enough capacity is available.
AwaitingRemoteRevokeToAddFail,
AwaitingRemoteRevokeToAdd,
/// This HTLC has been included in the commitment_signed and revoke_and_ack messages on both sides
/// and is included in both commitment transactions.
///
Expand All @@ -220,18 +203,12 @@ pub enum InboundHTLCStateDetails {
impl From<&InboundHTLCState> for InboundHTLCStateDetails {
fn from(state: &InboundHTLCState) -> InboundHTLCStateDetails {
match state {
InboundHTLCState::RemoteAnnounced(PendingHTLCStatus::Forward(_)) =>
InboundHTLCStateDetails::RemoteAnnouncedForward,
InboundHTLCState::RemoteAnnounced(PendingHTLCStatus::Fail(_)) =>
InboundHTLCStateDetails::RemoteAnnouncedFail,
InboundHTLCState::AwaitingRemoteRevokeToAnnounce(PendingHTLCStatus::Forward(_)) =>
InboundHTLCStateDetails::AwaitingRemoteRevokeToAddForward,
InboundHTLCState::AwaitingRemoteRevokeToAnnounce(PendingHTLCStatus::Fail(_)) =>
InboundHTLCStateDetails::AwaitingRemoteRevokeToAddFail,
InboundHTLCState::AwaitingAnnouncedRemoteRevoke(PendingHTLCStatus::Forward(_)) =>
InboundHTLCStateDetails::AwaitingRemoteRevokeToAddForward,
InboundHTLCState::AwaitingAnnouncedRemoteRevoke(PendingHTLCStatus::Fail(_)) =>
InboundHTLCStateDetails::AwaitingRemoteRevokeToAddFail,
InboundHTLCState::RemoteAnnounced(_) =>
InboundHTLCStateDetails::RemoteAnnounced,
InboundHTLCState::AwaitingRemoteRevokeToAnnounce(_) =>
InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
InboundHTLCState::AwaitingAnnouncedRemoteRevoke(_) =>
InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd,
InboundHTLCState::Committed =>
InboundHTLCStateDetails::Committed,
InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::FailRelay(_)) =>
Expand All @@ -245,13 +222,11 @@ impl From<&InboundHTLCState> for InboundHTLCStateDetails {
}

impl_writeable_tlv_based_enum!(InboundHTLCStateDetails,
(0, RemoteAnnouncedForward) => {},
(2, RemoteAnnouncedFail) => {},
(4, AwaitingRemoteRevokeToAddForward) => {},
(6, AwaitingRemoteRevokeToAddFail) => {},
(8, Committed) => {},
(10, AwaitingRemoteRevokeToRemoveFulfill) => {},
(12, AwaitingRemoteRevokeToRemoveFail) => {};
(0, RemoteAnnounced) => {},
(2, AwaitingRemoteRevokeToAdd) => {},
(4, Committed) => {},
(6, AwaitingRemoteRevokeToRemoveFulfill) => {},
(8, AwaitingRemoteRevokeToRemoveFail) => {};
);

struct InboundHTLCOutput {
Expand Down

0 comments on commit 8884077

Please sign in to comment.