Skip to content

Commit

Permalink
Move HTLCDestination to events.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
jurvis committed May 31, 2022
1 parent d272759 commit 3b6131d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 34 deletions.
33 changes: 1 addition & 32 deletions lightning/src/ln/channel.rs
Expand Up @@ -35,7 +35,7 @@ use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, LATENCY_GRACE_PERIOD_BLOCKS};
use chain::transaction::{OutPoint, TransactionData};
use chain::keysinterface::{Sign, KeysInterface};
use util::events::ClosureReason;
use util::events::{ClosureReason, HTLCDestination};
use util::ser::{Readable, ReadableArgs, Writeable, Writer, VecWriter};
use util::logger::Logger;
use util::errors::APIError;
Expand All @@ -46,7 +46,6 @@ use io;
use prelude::*;
use core::{cmp,mem,fmt};
use core::ops::Deref;
use io::Error;
#[cfg(any(test, fuzzing, debug_assertions))]
use sync::Mutex;
use bitcoin::hashes::hex::ToHex;
Expand Down Expand Up @@ -805,36 +804,6 @@ impl fmt::Debug for ChannelError {
}
}

/// Used to return destination of where we are forwarding our HTLC to.
#[derive(Clone, Debug)]
pub enum HTLCDestination {
OpenChannel { node_id: PublicKey, channel_id: [u8; 32] },
Unknown { previous_hop_scid: u64 },
Payment { payment_hash: PaymentHash, payment_preimage: Option<PaymentPreimage> },
}

impl Writeable for HTLCDestination {
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
match self {
HTLCDestination::OpenChannel { ref node_id, ref channel_id } => {
0u8.write(writer)?;
node_id.write(writer)?;
channel_id.write(writer)?;
},
HTLCDestination::Unknown { ref previous_hop_scid } => {
1u8.write(writer)?;
previous_hop_scid.write(writer)?;
},
HTLCDestination::Payment { ref payment_hash, ref payment_preimage } => {
2u8.write(writer)?;
payment_hash.write(writer)?;
payment_preimage.write(writer)?;
}
}
Ok(())
}
}

macro_rules! secp_check {
($res: expr, $err: expr) => {
match $res {
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/channelmanager.rs
Expand Up @@ -41,7 +41,7 @@ use chain::transaction::{OutPoint, TransactionData};
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
// construct one themselves.
use ln::{inbound_payment, PaymentHash, PaymentPreimage, PaymentSecret};
use ln::channel::{Channel, ChannelError, ChannelUpdateStatus, HTLCDestination, UpdateFulfillCommitFetch};
use ln::channel::{Channel, ChannelError, ChannelUpdateStatus, UpdateFulfillCommitFetch};
use ln::features::{ChannelTypeFeatures, InitFeatures, NodeFeatures};
use routing::router::{PaymentParameters, Route, RouteHop, RoutePath, RouteParameters};
use ln::msgs;
Expand All @@ -51,7 +51,7 @@ use ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSA
use ln::wire::Encode;
use chain::keysinterface::{Sign, KeysInterface, KeysManager, InMemorySigner, Recipient};
use util::config::UserConfig;
use util::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason};
use util::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
use util::{byte_utils, events};
use util::scid_utils::fake_scid;
use util::ser::{BigSize, FixedLengthReader, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};
Expand Down
1 change: 1 addition & 0 deletions lightning/src/util/events.rs
Expand Up @@ -35,6 +35,7 @@ use prelude::*;
use core::time::Duration;
use core::ops::Deref;
use sync::Arc;
use io::Error;

/// Some information provided on receipt of payment depends on whether the payment received is a
/// spontaneous payment or a "conventional" lightning payment that's paying an invoice.
Expand Down

0 comments on commit 3b6131d

Please sign in to comment.