From 4e4fa56e2b52971271ccddf56e8195d96b1c69ba Mon Sep 17 00:00:00 2001 From: Yuntai Kyong Date: Sat, 15 Sep 2018 07:26:03 +0900 Subject: [PATCH] unwrap channel.get_open_channel --- fuzz/fuzz_targets/channel_target.rs | 2 +- src/ln/channel.rs | 6 +++--- src/ln/channelmanager.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fuzz/fuzz_targets/channel_target.rs b/fuzz/fuzz_targets/channel_target.rs index d33ac9419..5cf0783c5 100644 --- a/fuzz/fuzz_targets/channel_target.rs +++ b/fuzz/fuzz_targets/channel_target.rs @@ -197,7 +197,7 @@ pub fn do_test(data: &[u8]) { Ok(chan) => chan, Err(_) => return, }; - chan.get_open_channel(Sha256dHash::from(get_slice!(32)), &fee_est).unwrap(); + chan.get_open_channel(Sha256dHash::from(get_slice!(32)), &fee_est); let accept_chan = if get_slice!(1)[0] == 0 { decode_msg_with_len16!(msgs::AcceptChannel, 270, 1) } else { diff --git a/src/ln/channel.rs b/src/ln/channel.rs index e71ba9b2c..c4b6acb7d 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -2168,7 +2168,7 @@ impl Channel { // Methods to get unprompted messages to send to the remote end (or where we already returned // something in the handler for the message that prompted this message): - pub fn get_open_channel(&self, chain_hash: Sha256dHash, fee_estimator: &FeeEstimator) -> Result { + pub fn get_open_channel(&self, chain_hash: Sha256dHash, fee_estimator: &FeeEstimator) -> msgs::OpenChannel { if !self.channel_outbound { panic!("Tried to open a channel for an inbound channel?"); } @@ -2182,7 +2182,7 @@ impl Channel { let local_commitment_secret = self.build_local_commitment_secret(self.cur_local_commitment_transaction_number); - Ok(msgs::OpenChannel { + msgs::OpenChannel { chain_hash: chain_hash, temporary_channel_id: self.channel_id, funding_satoshis: self.channel_value_satoshis, @@ -2202,7 +2202,7 @@ impl Channel { first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret), channel_flags: if self.announce_publicly {1} else {0}, shutdown_scriptpubkey: None, - }) + } } pub fn get_accept_channel(&self) -> msgs::AcceptChannel { diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index 765c417f3..af27a3f32 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -369,7 +369,7 @@ impl ChannelManager { }; let channel = Channel::new_outbound(&*self.fee_estimator, chan_keys, their_network_key, channel_value_satoshis, push_msat, self.announce_channels_publicly, user_id, Arc::clone(&self.logger))?; - let res = channel.get_open_channel(self.genesis_hash.clone(), &*self.fee_estimator)?; + let res = channel.get_open_channel(self.genesis_hash.clone(), &*self.fee_estimator); let mut channel_state = self.channel_state.lock().unwrap(); match channel_state.by_id.insert(channel.channel_id(), channel) { Some(_) => panic!("RNG is bad???"), -- 2.39.5