Skip to content

Commit 3b6131d

Browse files
committed
Move HTLCDestination to events.rs
1 parent d272759 commit 3b6131d

File tree

3 files changed

+4
-34
lines changed

3 files changed

+4
-34
lines changed

lightning/src/ln/channel.rs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
3535
use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, LATENCY_GRACE_PERIOD_BLOCKS};
3636
use chain::transaction::{OutPoint, TransactionData};
3737
use chain::keysinterface::{Sign, KeysInterface};
38-
use util::events::ClosureReason;
38+
use util::events::{ClosureReason, HTLCDestination};
3939
use util::ser::{Readable, ReadableArgs, Writeable, Writer, VecWriter};
4040
use util::logger::Logger;
4141
use util::errors::APIError;
@@ -46,7 +46,6 @@ use io;
4646
use prelude::*;
4747
use core::{cmp,mem,fmt};
4848
use core::ops::Deref;
49-
use io::Error;
5049
#[cfg(any(test, fuzzing, debug_assertions))]
5150
use sync::Mutex;
5251
use bitcoin::hashes::hex::ToHex;
@@ -805,36 +804,6 @@ impl fmt::Debug for ChannelError {
805804
}
806805
}
807806

808-
/// Used to return destination of where we are forwarding our HTLC to.
809-
#[derive(Clone, Debug)]
810-
pub enum HTLCDestination {
811-
OpenChannel { node_id: PublicKey, channel_id: [u8; 32] },
812-
Unknown { previous_hop_scid: u64 },
813-
Payment { payment_hash: PaymentHash, payment_preimage: Option<PaymentPreimage> },
814-
}
815-
816-
impl Writeable for HTLCDestination {
817-
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
818-
match self {
819-
HTLCDestination::OpenChannel { ref node_id, ref channel_id } => {
820-
0u8.write(writer)?;
821-
node_id.write(writer)?;
822-
channel_id.write(writer)?;
823-
},
824-
HTLCDestination::Unknown { ref previous_hop_scid } => {
825-
1u8.write(writer)?;
826-
previous_hop_scid.write(writer)?;
827-
},
828-
HTLCDestination::Payment { ref payment_hash, ref payment_preimage } => {
829-
2u8.write(writer)?;
830-
payment_hash.write(writer)?;
831-
payment_preimage.write(writer)?;
832-
}
833-
}
834-
Ok(())
835-
}
836-
}
837-
838807
macro_rules! secp_check {
839808
($res: expr, $err: expr) => {
840809
match $res {

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use chain::transaction::{OutPoint, TransactionData};
4141
// Since this struct is returned in `list_channels` methods, expose it here in case users want to
4242
// construct one themselves.
4343
use ln::{inbound_payment, PaymentHash, PaymentPreimage, PaymentSecret};
44-
use ln::channel::{Channel, ChannelError, ChannelUpdateStatus, HTLCDestination, UpdateFulfillCommitFetch};
44+
use ln::channel::{Channel, ChannelError, ChannelUpdateStatus, UpdateFulfillCommitFetch};
4545
use ln::features::{ChannelTypeFeatures, InitFeatures, NodeFeatures};
4646
use routing::router::{PaymentParameters, Route, RouteHop, RoutePath, RouteParameters};
4747
use ln::msgs;
@@ -51,7 +51,7 @@ use ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSA
5151
use ln::wire::Encode;
5252
use chain::keysinterface::{Sign, KeysInterface, KeysManager, InMemorySigner, Recipient};
5353
use util::config::UserConfig;
54-
use util::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason};
54+
use util::events::{EventHandler, EventsProvider, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination};
5555
use util::{byte_utils, events};
5656
use util::scid_utils::fake_scid;
5757
use util::ser::{BigSize, FixedLengthReader, Readable, ReadableArgs, MaybeReadable, Writeable, Writer, VecWriter};

lightning/src/util/events.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use prelude::*;
3535
use core::time::Duration;
3636
use core::ops::Deref;
3737
use sync::Arc;
38+
use io::Error;
3839

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

0 commit comments

Comments
 (0)