Fix feerate calculation on closing transactions
authorMatt Corallo <git@bluematt.me>
Fri, 18 Sep 2020 22:26:12 +0000 (18:26 -0400)
committerMatt Corallo <git@bluematt.me>
Mon, 5 Oct 2020 15:32:30 +0000 (11:32 -0400)
commitb43a7e3ef3e88012cf9d6dfd0fa8362a32474fb4
tree3bc9c22e454f416a05d8c6f1df3fbaffd432d909
parent6366fc7154e1a5be9723dabe2dd323f23e07407f
Fix feerate calculation on closing transactions

This resolves a number of bugs around how we calculate feerates on
closing transactions:

 * We previously calculated the weight wrong both by always
   counting two outputs instead of counting the number of outputs
   that actually exist in the closing transaction and by not
   counting the witness redeemscript.
 * We use assertions to check the calculated weight matches what we
   actually build (with debug_assertions for variable-length sigs).
 * As an additional sanity check, we really should check that the
   transaction had at least min-relay-fee when we were the channel
   initator.
lightning/src/ln/channel.rs