bitcoin: add weight calculation helpers.

These are pulled from wallet/wallet.c, with the fix now that we grind sigs.

This reduces the fees we pay slightly, as you can see in the coinmoves changes.

I now print out all the coin moves in suitable format before we match:
you only see this if the test fails, but it's really helpful.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-07-06 14:56:14 +09:30
committed by Christian Decker
parent 1ef0ca51b0
commit 7aa8ffa2a0
10 changed files with 125 additions and 66 deletions

View File

@@ -69,7 +69,7 @@ static bool closing_fee_is_acceptable(struct lightningd *ld,
type_to_string(tmpctx, struct amount_sat, &last_fee));
/* Weight once we add in sigs. */
weight = bitcoin_tx_weight(tx) + 74 * 2;
weight = bitcoin_tx_weight(tx) + bitcoin_tx_input_sig_weight() * 2;
/* If we don't have a feerate estimate, this gives feerate_floor */
min_feerate = feerate_min(ld, &feerate_unknown);