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 mut channel_state = self.channel_state.lock().unwrap();
- match channel_state.by_id.insert(channel.channel_id(), channel) {
- Some(_) => panic!("RNG is bad???"),
- None => {}
+ match channel_state.by_id.entry(channel.channel_id()) {
+ hash_map::Entry::Occupied(_) => {
+ if cfg!(feature = "fuzztarget") {
+ return Err(APIError::APIMisuseError { err: "Fuzzy bad RNG" });
+ } else {
+ panic!("RNG is bad???");
+ }
+ },
+ hash_map::Entry::Vacant(entry) => { entry.insert(channel); }
}
let mut events = self.pending_events.lock().unwrap();
}
impl Drop for Node {
fn drop(&mut self) {
- // Check that we processed all pending events
- assert_eq!(self.node.get_and_clear_pending_events().len(), 0);
- assert_eq!(self.chan_monitor.added_monitors.lock().unwrap().len(), 0);
+ if !::std::thread::panicking() {
+ // Check that we processed all pending events
+ assert_eq!(self.node.get_and_clear_pending_events().len(), 0);
+ assert_eq!(self.chan_monitor.added_monitors.lock().unwrap().len(), 0);
+ }
}
}
/// Attempst to claim a remote HTLC-Success/HTLC-Timeout s outputs using the revocation key
fn check_spend_remote_htlc(&self, tx: &Transaction, commitment_number: u64) -> Option<Transaction> {
- let htlc_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
+ if tx.input.len() != 1 || tx.output.len() != 1 {
+ return None;
+ }
macro_rules! ignore_error {
( $thing : expr ) => {
};
let redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.their_to_self_delay.unwrap(), &delayed_key);
let revokeable_p2wsh = redeemscript.to_v0_p2wsh();
+ let htlc_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
let mut inputs = Vec::new();
let mut amount = 0;