closingd, lightningd: use bitcoin_tx_2of2_input_witness_weight

This fixes lightningd's chronic weight underestimate.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: closingd: more accurate weight estimation helps mutual closing near min/max feerates.
This commit is contained in:
Rusty Russell
2022-01-26 12:42:34 +10:30
committed by Christian Decker
parent 8a8d7c4243
commit de28bbd792
3 changed files with 5 additions and 17 deletions

View File

@@ -202,7 +202,9 @@ static bool closing_fee_is_acceptable(struct lightningd *ld,
last_fee = calc_tx_fee(channel->funding_sats, channel->last_tx);
/* Weight once we add in sigs. */
weight = bitcoin_tx_weight(tx) + bitcoin_tx_input_sig_weight() * 2;
assert(!tx->wtx->inputs[0].witness
|| tx->wtx->inputs[0].witness->num_items == 0);
weight = bitcoin_tx_weight(tx) + bitcoin_tx_2of2_input_witness_weight();
log_debug(channel->log, "Their actual closing tx fee is %s"
" vs previous %s: weight is %"PRIu64,