mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 09:34:24 +01:00
onchain fees are weird at channel close because: - you may be missing an trimmed htlc (which went to fees) - the balance from close may have been rounded (msats cant land on chain) - the close might have been a past state and you've actually ended up with more money onchain than you had in the channel. wut This commit accounts for all of this appropriately, with some tests. channel_close.debit should equal onchain_fee.credit (for that txid) plus sum(chain_event.credit [wallet/channel_acct]). In the penalty case, channel_close.debit becomes channel_close.debit + penalty_adj.debit, i.e. channel-close.debit + (penalty_adj.debit) = onchain_fee.credit + sum(chain_event.credit [wallet/channel_acct])