From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Fri, 7 Sep 2018 14:19:28 +0000 (-0400) Subject: Merge pull request #160 from ariard/channel_manager_refactor_all X-Git-Tag: v0.0.12~322 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=6016ca18709bec800ce0b290ebc946ecbe9e73e4;hp=4b5b48cb57703ce9a094eb32e0d85b2a45072f45;p=rust-lightning Merge pull request #160 from ariard/channel_manager_refactor_all Channel manager refactor all --- diff --git a/fuzz/fuzz_targets/router_target.rs b/fuzz/fuzz_targets/router_target.rs index fdc59efc..d8755956 100644 --- a/fuzz/fuzz_targets/router_target.rs +++ b/fuzz/fuzz_targets/router_target.rs @@ -4,7 +4,6 @@ extern crate secp256k1; use bitcoin::util::hash::Sha256dHash; use bitcoin::blockdata::script::{Script, Builder}; -use bitcoin::blockdata::opcodes; use lightning::chain::chaininterface::{ChainError,ChainWatchInterface, ChainListener}; use lightning::ln::channelmanager::ChannelDetails; diff --git a/src/ln/channel.rs b/src/ln/channel.rs index b2d6a70e..ab8b3bcd 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -1268,10 +1268,13 @@ impl Channel { pub fn funding_created(&mut self, msg: &msgs::FundingCreated) -> Result<(msgs::FundingSigned, ChannelMonitor), HandleError> { if self.channel_outbound { - return Err(HandleError{err: "Received funding_created for an outbound channel?", action: None}); + return Err(HandleError{err: "Received funding_created for an outbound channel?", action: Some(msgs::ErrorAction::SendErrorMessage {msg: msgs::ErrorMessage {channel_id: self.channel_id, data: "Received funding_created for an outbound channel?".to_string()}})}); } if self.channel_state != (ChannelState::OurInitSent as u32 | ChannelState::TheirInitSent as u32) { - return Err(HandleError{err: "Received funding_created after we got the channel!", action: None}); + // BOLT 2 says that if we disconnect before we send funding_signed we SHOULD NOT + // remember the channel, so its safe to just send an error_message here and drop the + // channel. + return Err(HandleError{err: "Received funding_created after we got the channel!", action: Some(msgs::ErrorAction::SendErrorMessage {msg: msgs::ErrorMessage {channel_id: self.channel_id, data: "Received funding_created after we got the channel!".to_string()}})}); } if self.channel_monitor.get_min_seen_secret() != (1 << 48) || self.cur_remote_commitment_transaction_number != (1 << 48) - 1 || self.cur_local_commitment_transaction_number != (1 << 48) - 1 { panic!("Should not have advanced channel commitment tx numbers prior to funding_created");