Skip to content

Commit 3dde575

Browse files
committed
Force-close channels if closing transactions may be non-standard
If a counterparty (or an old channel of ours) uses a non-segwit script for their cooperative close payout, they may include an output which is unbroadcastable due to not meeting the network dust limit. Here we check for this condition, force-closing the channel instead if we find an output in the closing transaction which does not meet the limit.
1 parent b7533b2 commit 3dde575

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3642,6 +3642,12 @@ impl<Signer: Sign> Channel<Signer> {
36423642
},
36433643
};
36443644

3645+
for outp in closing_tx.output.iter() {
3646+
if !outp.script_pubkey.is_witness_program() && outp.value < MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS {
3647+
return Err(ChannelError::Close("Remote sent us a closing_signed with a dust output. Always use segwit closing scripts!".to_owned()));
3648+
}
3649+
}
3650+
36453651
assert!(self.shutdown_scriptpubkey.is_some());
36463652
if let Some((last_fee, sig)) = self.last_sent_closing_fee {
36473653
if last_fee == msg.fee_satoshis {

0 commit comments

Comments
 (0)