tx: Strengthen transaction construction checks

We roll the `elements_add_fee_output` function and the cropping of
overallocated arrays into the `bitcoin_tx_finalize` function. This is supposed
to be the final cleanup and compaction step before a tx can be sent to bitcoin
or passed off to other daemons.

This is the cleanup promised in #3491
This commit is contained in:
Christian Decker
2020-02-08 21:26:55 +01:00
committed by Rusty Russell
parent 24aaf73982
commit 42a63e4416
8 changed files with 56 additions and 17 deletions

View File

@@ -305,8 +305,8 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
u32 sequence = (0x80000000 | ((obscured_commitment_number>>24) & 0xFFFFFF));
bitcoin_tx_add_input(tx, funding_txid, funding_txout, sequence, funding, NULL);
elements_tx_add_fee_output(tx);
tal_resize(&(tx->output_witscripts), tx->wtx->num_outputs);
bitcoin_tx_finalize(tx);
assert(bitcoin_tx_check(tx));
return tx;
}