Skip to content

Commit a9434db

Browse files
committed
Check for misuse of funding_transaction_generated and panic
1 parent c531cb4 commit a9434db

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/ln/channel.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,16 @@ impl Channel {
21132113
if tx.txid() == self.channel_monitor.get_funding_txo().unwrap().txid {
21142114
let txo_idx = self.channel_monitor.get_funding_txo().unwrap().index as usize;
21152115
if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != self.get_funding_redeemscript().to_v0_p2wsh() ||
2116-
tx.output[txo_idx].value != self.channel_value_satoshis {
2116+
tx.output[txo_idx].value != self.channel_value_satoshis {
2117+
if self.channel_outbound {
2118+
// If we generated the funding transaction and it doesn't match what it
2119+
// should, the client is really broken and we should just panic and
2120+
// tell them off. That said, because hash collisions happen with high
2121+
// probability in fuzztarget mode, if we're fuzzing we just close the
2122+
// channel and move on.
2123+
#[cfg(not(feature = "fuzztarget"))]
2124+
panic!("Client called ChannelManager::funding_transaction_generated with bogus transaction!");
2125+
}
21172126
self.channel_state = ChannelState::ShutdownComplete as u32;
21182127
self.channel_update_count += 1;
21192128
return Err(HandleError{err: "funding tx had wrong script/value", action: Some(ErrorAction::DisconnectPeer{msg: None})});

0 commit comments

Comments
 (0)