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

@@ -247,6 +247,7 @@ int main(int argc, char *argv[])
const struct htlc **htlcmap;
struct privkey local_htlc_privkey, remote_htlc_privkey;
struct pubkey local_htlc_pubkey, remote_htlc_pubkey;
const struct chainparams *chainparams = chainparams_for_network("bitcoin");
setup_locale();
@@ -367,7 +368,7 @@ int main(int argc, char *argv[])
if (!per_commit_point(&localseed, &local_per_commit_point, commitnum))
errx(1, "Bad deriving local per-commitment-point");
local_txs = channel_txs(NULL, &htlcmap, &wscripts, channel,
local_txs = channel_txs(chainparams, NULL, &htlcmap, &wscripts, channel,
&local_per_commit_point, commitnum, LOCAL);
printf("## local_commitment\n"
@@ -468,7 +469,7 @@ int main(int argc, char *argv[])
/* Create the remote commitment tx */
if (!per_commit_point(&remoteseed, &remote_per_commit_point, commitnum))
errx(1, "Bad deriving remote per-commitment-point");
remote_txs = channel_txs(NULL, &htlcmap, &wscripts, channel,
remote_txs = channel_txs(chainparams, NULL, &htlcmap, &wscripts, channel,
&remote_per_commit_point, commitnum, REMOTE);
remote_txs[0]->input_amounts[0]
= tal_dup(remote_txs[0], struct amount_sat, &funding_amount);