Closed
Description
Hey, was taking a look at channel close fees today and noticed something funky in Channel::build_closing_transaction
.
When value_to_holder: i64
or value_to_counterparty: i64
are negative (funder doesn't have enough channel balance to pay the total_fee_satoshis
) they'll underflow at the _ as u64
conversion.
Adding some logs, you can see:
// context
[lightning/src/ln/channel.rs:4004:3] holder_balance = 2500
[lightning/src/ln/channel.rs:4004:3] counterparty_balance = 17500
// first block
[lightning/src/ln/channel.rs:4004:3] total_fee_satoshis = 3053
[lightning/src/ln/channel.rs:4004:3] value_to_holder = -553
[lightning/src/ln/channel.rs:4004:3] value_to_counterparty = 17500
// after if blocks
[lightning/src/ln/channel.rs:4022:3] total_fee_satoshis = 3606
[lightning/src/ln/channel.rs:4022:3] value_to_holder as u64 = 18446744073709551063
[lightning/src/ln/channel.rs:4022:3] value_to_counterparty as u64 = 17500
Fortunately the remote just force closes, so it doesn't seem too problematic.