Skip to content

Commit

Permalink
f adapt to new api
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Nov 16, 2021
1 parent e3103d4 commit b9f4c13
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
7 changes: 2 additions & 5 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -4259,10 +4259,7 @@ impl<Signer: Sign> Channel<Signer> {
// 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))
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lightning/src/util/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b9f4c13

Please sign in to comment.