]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Dont return an Err from Channel::get_accept_channel that can't fail
authorMatt Corallo <git@bluematt.me>
Tue, 4 Sep 2018 23:28:06 +0000 (19:28 -0400)
committerMatt Corallo <git@bluematt.me>
Wed, 5 Sep 2018 00:27:55 +0000 (20:27 -0400)
fuzz/fuzz_targets/channel_target.rs
src/ln/channel.rs
src/ln/channelmanager.rs

index 37a67183696b13f3b2dd229af6cd2978fcdbd504..7b3b7df1ce2ec3ddcc039212e92352bddef8b246 100644 (file)
@@ -230,7 +230,7 @@ pub fn do_test(data: &[u8]) {
                        Ok(chan) => chan,
                        Err(_) => return,
                };
-               chan.get_accept_channel().unwrap();
+               chan.get_accept_channel();
 
                tx.output.push(TxOut{ value: open_chan.funding_satoshis, script_pubkey: chan.get_funding_redeemscript().to_v0_p2wsh() });
                let funding_output = OutPoint::new(Sha256dHash::from_data(&serialize(&tx).unwrap()[..]), 0);
index 0659f8261af0e52083fd7b9d5a3efceadc602c70..8dcd23b785ec811e6ccda83078bd1165506bc35d 100644 (file)
@@ -2200,7 +2200,7 @@ impl Channel {
                })
        }
 
-       pub fn get_accept_channel(&self) -> Result<msgs::AcceptChannel, HandleError> {
+       pub fn get_accept_channel(&self) -> msgs::AcceptChannel {
                if self.channel_outbound {
                        panic!("Tried to send accept_channel for an outbound channel?");
                }
@@ -2213,7 +2213,7 @@ impl Channel {
 
                let local_commitment_secret = self.build_local_commitment_secret(self.cur_local_commitment_transaction_number);
 
-               Ok(msgs::AcceptChannel {
+               msgs::AcceptChannel {
                        temporary_channel_id: self.channel_id,
                        dust_limit_satoshis: self.our_dust_limit_satoshis,
                        max_htlc_value_in_flight_msat: Channel::get_our_max_htlc_value_in_flight_msat(self.channel_value_satoshis),
@@ -2229,7 +2229,7 @@ impl Channel {
                        htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, &self.local_keys.htlc_base_key),
                        first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
                        shutdown_scriptpubkey: None,
-               })
+               }
        }
 
        fn get_outbound_funding_created_signature(&mut self) -> Result<(Signature, Transaction), HandleError> {
index 845bced75905ac2dd14c7ce6fcff4650f7484556..ff1f6e53dae90fe27999d20d9298346252cbd4fe 100644 (file)
@@ -1414,7 +1414,7 @@ impl ChannelManager {
                };
 
                let channel = Channel::new_from_req(&*self.fee_estimator, chan_keys, their_node_id.clone(), msg, 0, false, self.announce_channels_publicly, Arc::clone(&self.logger)).map_err(|e| MsgHandleErrInternal::from_no_close(e))?;
-               let accept_msg = channel.get_accept_channel().map_err(|e| MsgHandleErrInternal::from_no_close(e))?;
+               let accept_msg = channel.get_accept_channel();
                channel_state.by_id.insert(channel.channel_id(), channel);
                Ok(accept_msg)
        }