Skip to content

Commit 5918d1c

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 7479712 commit 5918d1c

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
@@ -3626,6 +3626,12 @@ impl<Signer: Sign> Channel<Signer> {
36263626
},
36273627
};
36283628

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

0 commit comments

Comments
 (0)