Skip to content

Commit 17f32f9

Browse files
committed
Second dust check on change output (after subtracting fee)
1 parent 5aa14e0 commit 17f32f9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lightning/src/ln/channel.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,9 +2298,12 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22982298
};
22992299
let change_output_weight = get_output_weight(&change_output.script_pubkey).to_wu();
23002300
let change_output_fee = fee_for_weight(self.dual_funding_context.funding_feerate_sat_per_1000_weight, change_output_weight);
2301-
change_output.value = Amount::from_sat(change_value.saturating_sub(change_output_fee));
2302-
// Note: dust check not done here, should be handled before
2303-
funding_outputs.push(OutputOwned::Single(change_output));
2301+
let change_value_decreased_with_fee = change_value.saturating_sub(change_output_fee);
2302+
// Check dust limit again
2303+
if change_value_decreased_with_fee > self.context.holder_dust_limit_satoshis {
2304+
change_output.value = Amount::from_sat(change_value_decreased_with_fee);
2305+
funding_outputs.push(OutputOwned::Single(change_output));
2306+
}
23042307
}
23052308

23062309
let constructor_args = InteractiveTxConstructorArgs {

0 commit comments

Comments
 (0)