diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 794b9754f42..d067566caf0 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -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; @@ -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; @@ -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 }, -} - -impl Writeable for HTLCDestination { - fn write(&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 { diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index bff293d4fd6..65954ccd8ea 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -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; @@ -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}; diff --git a/lightning/src/util/events.rs b/lightning/src/util/events.rs index 0de5cf73247..e0f1503d613 100644 --- a/lightning/src/util/events.rs +++ b/lightning/src/util/events.rs @@ -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.