Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,15 @@ 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 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();
Expand Down Expand Up @@ -2456,9 +2462,11 @@ mod tests {
}
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);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/ln/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,9 @@ impl ChannelMonitor {

/// 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 ) => {
Expand Down Expand Up @@ -1039,6 +1041,7 @@ impl ChannelMonitor {
};
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;
Expand Down