From b9f4c13ef135c2a94032322e9ff5b468ac16bde8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 16 Nov 2021 20:43:05 +0000 Subject: [PATCH] f adapt to new api --- lightning/src/ln/channel.rs | 7 ++----- lightning/src/ln/functional_tests.rs | 2 +- lightning/src/ln/mod.rs | 2 +- lightning/src/util/events.rs | 2 ++ 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 2ac035e8f1e..e0f7a1ae7c2 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -382,7 +382,7 @@ const FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE: u64 = 2; /// If we fail to see a funding transaction confirmed on-chain within this many blocks after the /// channel creation on an inbound channel, we simply force-close and move on. /// This constant is the one suggested in BOLT 2. -const FUNDING_CONF_DEADLINE_BLOCKS: u32 = 2016; +pub(crate) const FUNDING_CONF_DEADLINE_BLOCKS: u32 = 2016; // TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking // has been completed, and then turn into a Channel to get compiler-time enforcement of things like @@ -4259,10 +4259,7 @@ impl Channel { // If funding_tx_confirmed_in is unset, the channel must not be active assert!(non_shutdown_state <= ChannelState::ChannelFunded as u32); assert_eq!(non_shutdown_state & ChannelState::OurFundingLocked as u32, 0); - return Err((msgs::ErrorMessage { - channel_id: self.channel_id(), - data: format!("Funding transaction failed to confirm within {} blocks", FUNDING_CONF_DEADLINE_BLOCKS), - }, ClosureReason::FundingTimedOut)); + return Err(ClosureReason::FundingTimedOut); } Ok((None, timed_out_htlcs)) diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 54bf2e193ac..8e9893870da 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -7938,7 +7938,7 @@ fn test_channel_conf_timeout() { match close_ev[0] { MessageSendEvent::HandleError { action: ErrorAction::SendErrorMessage { ref msg }, ref node_id } => { assert_eq!(*node_id, nodes[0].node.get_our_node_id()); - assert_eq!(msg.data, "Funding transaction failed to confirm within 2016 blocks"); + assert_eq!(msg.data, "Channel closed because funding transaction failed to confirm within 2016 blocks"); }, _ => panic!("Unexpected event"), } diff --git a/lightning/src/ln/mod.rs b/lightning/src/ln/mod.rs index a2a0b4efee2..41d978e8d04 100644 --- a/lightning/src/ln/mod.rs +++ b/lightning/src/ln/mod.rs @@ -37,7 +37,7 @@ pub(crate) mod peer_channel_encryptor; #[cfg(feature = "fuzztarget")] pub mod channel; #[cfg(not(feature = "fuzztarget"))] -mod channel; +pub(crate) mod channel; mod onion_utils; pub mod wire; diff --git a/lightning/src/util/events.rs b/lightning/src/util/events.rs index 09776350bb7..6bbd6b9946c 100644 --- a/lightning/src/util/events.rs +++ b/lightning/src/util/events.rs @@ -16,6 +16,7 @@ use chain::keysinterface::SpendableOutputDescriptor; use ln::channelmanager::PaymentId; +use ln::channel::FUNDING_CONF_DEADLINE_BLOCKS; use ln::msgs; use ln::msgs::DecodeError; use ln::{PaymentPreimage, PaymentHash, PaymentSecret}; @@ -131,6 +132,7 @@ impl core::fmt::Display for ClosureReason { ClosureReason::HolderForceClosed => f.write_str("user manually force-closed the channel"), ClosureReason::CooperativeClosure => f.write_str("the channel was cooperatively closed"), ClosureReason::CommitmentTxConfirmed => f.write_str("commitment or closing transaction was confirmed on chain."), + ClosureReason::FundingTimedOut => write!(f, "funding transaction failed to confirm within {} blocks", FUNDING_CONF_DEADLINE_BLOCKS), ClosureReason::ProcessingError { err } => { f.write_str("of an exception: ")?; f.write_str(&err)