tx: Add chainparams to struct bitcoin_tx as context

The way we build transactions, serialize them, and compute fees depends on the
chain we are working on, so let's add some context to the transactions.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2019-07-30 16:14:43 +02:00
committed by Rusty Russell
parent 2537bd5afa
commit 9288a7906b
32 changed files with 244 additions and 138 deletions

View File

@@ -2,6 +2,7 @@
#ifndef LIGHTNING_COMMON_INITIAL_COMMIT_TX_H
#define LIGHTNING_COMMON_INITIAL_COMMIT_TX_H
#include "config.h"
#include <bitcoin/chainparams.h>
#include <bitcoin/pubkey.h>
#include <common/amount.h>
#include <common/htlc.h>
@@ -52,6 +53,7 @@ static inline struct amount_sat commit_tx_base_fee(u32 feerate_per_kw,
/**
* initial_commit_tx: create (unsigned) commitment tx to spend the funding tx output
* @ctx: context to allocate transaction and @htlc_map from.
* @chainparams: Params for the resulting transactions
* @funding_txid, @funding_out, @funding: funding outpoint.
* @funder: is the LOCAL or REMOTE paying the fee?
* @keyset: keys derived for this commit tx.
@@ -69,6 +71,7 @@ static inline struct amount_sat commit_tx_base_fee(u32 feerate_per_kw,
* transaction, so we carefully use the terms "self" and "other" here.
*/
struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
const struct chainparams *chainparams,
const struct bitcoin_txid *funding_txid,
unsigned int funding_txout,
struct amount_sat funding,