Skip to content

Commit 9d39c93

Browse files
authored
Merge pull request #156 from TheBlueMatt/2018-09-funding_created_action
Ensure funding_created always returns Some(_) HandleError::action
2 parents 6132a8e + 5adf125 commit 9d39c93

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

fuzz/fuzz_targets/router_target.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ extern crate secp256k1;
44

55
use bitcoin::util::hash::Sha256dHash;
66
use bitcoin::blockdata::script::{Script, Builder};
7-
use bitcoin::blockdata::opcodes;
87

98
use lightning::chain::chaininterface::{ChainError,ChainWatchInterface, ChainListener};
109
use lightning::ln::channelmanager::ChannelDetails;

src/ln/channel.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,10 +1268,13 @@ impl Channel {
12681268

12691269
pub fn funding_created(&mut self, msg: &msgs::FundingCreated) -> Result<(msgs::FundingSigned, ChannelMonitor), HandleError> {
12701270
if self.channel_outbound {
1271-
return Err(HandleError{err: "Received funding_created for an outbound channel?", action: None});
1271+
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()}})});
12721272
}
12731273
if self.channel_state != (ChannelState::OurInitSent as u32 | ChannelState::TheirInitSent as u32) {
1274-
return Err(HandleError{err: "Received funding_created after we got the channel!", action: None});
1274+
// BOLT 2 says that if we disconnect before we send funding_signed we SHOULD NOT
1275+
// remember the channel, so its safe to just send an error_message here and drop the
1276+
// channel.
1277+
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()}})});
12751278
}
12761279
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 {
12771280
panic!("Should not have advanced channel commitment tx numbers prior to funding_created");

0 commit comments

Comments
 (0)