Skip to content

Commit 93e8971

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 4c24653 commit 93e8971

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
@@ -3629,6 +3629,12 @@ impl<Signer: Sign> Channel<Signer> {
36293629
},
36303630
};
36313631

3632+
for outp in closing_tx.trust().built_transaction().output.iter() {
3633+
if !outp.script_pubkey.is_witness_program() && outp.value < MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS {
3634+
return Err(ChannelError::Close("Remote sent us a closing_signed with a dust output. Always use segwit closing scripts!".to_owned()));
3635+
}
3636+
}
3637+
36323638
assert!(self.shutdown_scriptpubkey.is_some());
36333639
if let Some((last_fee, sig)) = self.last_sent_closing_fee {
36343640
if last_fee == msg.fee_satoshis {

0 commit comments

Comments
 (0)