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

@@ -113,3 +113,8 @@ struct bitcoin_tx *tx_spending_utxos(const tal_t *ctx,
return tx;
}
size_t utxo_spend_weight(const struct utxo *utxo)
{
return bitcoin_tx_simple_input_weight(utxo->is_p2sh);
}

View File

@@ -59,4 +59,6 @@ struct bitcoin_tx *tx_spending_utxos(const tal_t *ctx,
u32 nlocktime,
u32 nsequence);
/* Estimate of (signed) UTXO weight in transaction */
size_t utxo_spend_weight(const struct utxo *utxo);
#endif /* LIGHTNING_COMMON_UTXO_H */