mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 15:20:24 +01:00
Check for misuse of funding_transaction_generated and panic
This commit is contained in:
parent
c531cb4faa
commit
a9434db103
1 changed files with 10 additions and 1 deletions
|
@ -2114,6 +2114,15 @@ impl Channel {
|
||||||
let txo_idx = self.channel_monitor.get_funding_txo().unwrap().index as usize;
|
let txo_idx = self.channel_monitor.get_funding_txo().unwrap().index as usize;
|
||||||
if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != self.get_funding_redeemscript().to_v0_p2wsh() ||
|
if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != self.get_funding_redeemscript().to_v0_p2wsh() ||
|
||||||
tx.output[txo_idx].value != self.channel_value_satoshis {
|
tx.output[txo_idx].value != self.channel_value_satoshis {
|
||||||
|
if self.channel_outbound {
|
||||||
|
// If we generated the funding transaction and it doesn't match what it
|
||||||
|
// should, the client is really broken and we should just panic and
|
||||||
|
// tell them off. That said, because hash collisions happen with high
|
||||||
|
// probability in fuzztarget mode, if we're fuzzing we just close the
|
||||||
|
// channel and move on.
|
||||||
|
#[cfg(not(feature = "fuzztarget"))]
|
||||||
|
panic!("Client called ChannelManager::funding_transaction_generated with bogus transaction!");
|
||||||
|
}
|
||||||
self.channel_state = ChannelState::ShutdownComplete as u32;
|
self.channel_state = ChannelState::ShutdownComplete as u32;
|
||||||
self.channel_update_count += 1;
|
self.channel_update_count += 1;
|
||||||
return Err(HandleError{err: "funding tx had wrong script/value", action: Some(ErrorAction::DisconnectPeer{msg: None})});
|
return Err(HandleError{err: "funding tx had wrong script/value", action: Some(ErrorAction::DisconnectPeer{msg: None})});
|
||||||
|
|
Loading…
Add table
Reference in a new issue