elements: Remove global is_elements variable in favor of chainparams

No need to keep duplicate globals.
This commit is contained in:
Christian Decker
2019-09-26 00:42:26 +02:00
committed by Rusty Russell
parent ef7a63d8f8
commit d5f0c08a88
23 changed files with 48 additions and 37 deletions

View File

@@ -31,7 +31,7 @@ bitcoin_block_from_hex(const tal_t *ctx, const struct chainparams *chainparams,
pull(&p, &len, &b->hdr.merkle_hash, sizeof(b->hdr.merkle_hash)); pull(&p, &len, &b->hdr.merkle_hash, sizeof(b->hdr.merkle_hash));
b->hdr.timestamp = pull_le32(&p, &len); b->hdr.timestamp = pull_le32(&p, &len);
if (is_elements) { if (is_elements(chainparams)) {
b->elements_hdr = tal(b, struct elements_block_hdr); b->elements_hdr = tal(b, struct elements_block_hdr);
b->elements_hdr->block_height = pull_le32(&p, &len); b->elements_hdr->block_height = pull_le32(&p, &len);
@@ -76,7 +76,7 @@ void bitcoin_block_blkid(const struct bitcoin_block *b,
sha256_update(&shactx, &b->hdr.merkle_hash, sizeof(b->hdr.merkle_hash)); sha256_update(&shactx, &b->hdr.merkle_hash, sizeof(b->hdr.merkle_hash));
sha256_le32(&shactx, b->hdr.timestamp); sha256_le32(&shactx, b->hdr.timestamp);
if (is_elements) { if (is_elements(chainparams)) {
size_t clen = tal_bytelen(b->elements_hdr->proof.challenge); size_t clen = tal_bytelen(b->elements_hdr->proof.challenge);
sha256_le32(&shactx, b->elements_hdr->block_height); sha256_le32(&shactx, b->elements_hdr->block_height);

View File

@@ -98,7 +98,7 @@ static void bitcoin_tx_hash_for_sig(const struct bitcoin_tx *tx, unsigned int in
u64 satoshis = tx->input_amounts[in]->satoshis /* Raw: sig-helper */; u64 satoshis = tx->input_amounts[in]->satoshis /* Raw: sig-helper */;
int flags = WALLY_TX_FLAG_USE_WITNESS; int flags = WALLY_TX_FLAG_USE_WITNESS;
if (is_elements) { if (is_elements(chainparams)) {
ret = wally_tx_confidential_value_from_satoshi(satoshis, value, sizeof(value)); ret = wally_tx_confidential_value_from_satoshi(satoshis, value, sizeof(value));
assert(ret == WALLY_OK); assert(ret == WALLY_OK);
ret = wally_tx_get_elements_signature_hash( ret = wally_tx_get_elements_signature_hash(

View File

@@ -69,7 +69,8 @@ int main(void)
struct bitcoin_block *b; struct bitcoin_block *b;
setup_locale(); setup_locale();
b = bitcoin_block_from_hex(NULL, chainparams_for_network("bitcoin"), chainparams = chainparams_for_network("bitcoin");
b = bitcoin_block_from_hex(NULL, chainparams,
block, strlen(block)); block, strlen(block));
assert(b); assert(b);

View File

@@ -34,6 +34,7 @@ static void hexeq(const void *p, size_t len, const char *hex)
int main(void) int main(void)
{ {
setup_locale(); setup_locale();
chainparams = chainparams_for_network("bitcoin");
struct bitcoin_tx *tx; struct bitcoin_tx *tx;

View File

@@ -27,7 +27,7 @@ int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
assert(tx->wtx != NULL); assert(tx->wtx != NULL);
assert(chainparams); assert(chainparams);
if (is_elements) { if (chainparams->is_elements) {
u8 value[9]; u8 value[9];
ret = wally_tx_confidential_value_from_satoshi(satoshis, value, ret = wally_tx_confidential_value_from_satoshi(satoshis, value,
sizeof(value)); sizeof(value));
@@ -65,7 +65,8 @@ int bitcoin_tx_add_multi_outputs(struct bitcoin_tx *tx,
static bool elements_tx_output_is_fee(const struct bitcoin_tx *tx, int outnum) static bool elements_tx_output_is_fee(const struct bitcoin_tx *tx, int outnum)
{ {
assert(outnum < tx->wtx->num_outputs); assert(outnum < tx->wtx->num_outputs);
return is_elements && tx->wtx->outputs[outnum].script_len == 0; return chainparams->is_elements &&
tx->wtx->outputs[outnum].script_len == 0;
} }
/** /**
@@ -82,7 +83,7 @@ static u64 bitcoin_tx_compute_fee(const struct bitcoin_tx *tx)
if (elements_tx_output_is_fee(tx, i)) if (elements_tx_output_is_fee(tx, i))
continue; continue;
if (!is_elements) { if (!chainparams->is_elements) {
fee -= tx->wtx->outputs[i].satoshi; /* Raw: low-level helper */ fee -= tx->wtx->outputs[i].satoshi; /* Raw: low-level helper */
} else { } else {
beint64_t tmp; beint64_t tmp;
@@ -103,7 +104,7 @@ int elements_tx_add_fee_output(struct bitcoin_tx *tx)
fee.satoshis = rawsats; /* Raw: need amounts later */ fee.satoshis = rawsats; /* Raw: need amounts later */
/* If we aren't using elements, we don't add explicit fee outputs */ /* If we aren't using elements, we don't add explicit fee outputs */
if (!is_elements || rawsats == 0) if (!chainparams->is_elements || rawsats == 0)
return -1; return -1;
/* Try to find any existing fee output */ /* Try to find any existing fee output */
@@ -135,7 +136,7 @@ int bitcoin_tx_add_input(struct bitcoin_tx *tx, const struct bitcoin_txid *txid,
sizeof(struct bitcoin_txid), outnum, sequence, sizeof(struct bitcoin_txid), outnum, sequence,
script, tal_bytelen(script), script, tal_bytelen(script),
NULL /* Empty witness stack */, &input); NULL /* Empty witness stack */, &input);
input->features = is_elements ? WALLY_TX_IS_ELEMENTS : 0; input->features = chainparams->is_elements ? WALLY_TX_IS_ELEMENTS : 0;
wally_tx_add_input(tx->wtx, input); wally_tx_add_input(tx->wtx, input);
wally_tx_input_free(input); wally_tx_input_free(input);
@@ -155,7 +156,7 @@ bool bitcoin_tx_check(const struct bitcoin_tx *tx)
if (wally_tx_get_length(tx->wtx, flags, &written) != WALLY_OK) if (wally_tx_get_length(tx->wtx, flags, &written) != WALLY_OK)
return false; return false;
if (is_elements) { if (chainparams->is_elements) {
flags |= WALLY_TX_FLAG_USE_ELEMENTS; flags |= WALLY_TX_FLAG_USE_ELEMENTS;
} }
@@ -176,9 +177,9 @@ void bitcoin_tx_output_set_amount(struct bitcoin_tx *tx, int outnum,
u64 satoshis = amount.satoshis; /* Raw: low-level helper */ u64 satoshis = amount.satoshis; /* Raw: low-level helper */
struct wally_tx_output *output = &tx->wtx->outputs[outnum]; struct wally_tx_output *output = &tx->wtx->outputs[outnum];
assert(outnum < tx->wtx->num_outputs); assert(outnum < tx->wtx->num_outputs);
if (is_elements) { if (chainparams->is_elements) {
int ret = wally_tx_confidential_value_from_satoshi(satoshis, output->value, int ret = wally_tx_confidential_value_from_satoshi(
output->value_len); satoshis, output->value, output->value_len);
assert(ret == WALLY_OK); assert(ret == WALLY_OK);
} else { } else {
output->satoshi = satoshis; output->satoshi = satoshis;
@@ -318,7 +319,7 @@ static void push_tx(const struct bitcoin_tx *tx,
if (bip144 && uses_witness(tx)) if (bip144 && uses_witness(tx))
flag |= WALLY_TX_FLAG_USE_WITNESS; flag |= WALLY_TX_FLAG_USE_WITNESS;
if (is_elements) if (chainparams->is_elements)
flag |= WALLY_TX_FLAG_USE_ELEMENTS; flag |= WALLY_TX_FLAG_USE_ELEMENTS;
res = wally_tx_get_length(tx->wtx, flag & WALLY_TX_FLAG_USE_WITNESS, &len); res = wally_tx_get_length(tx->wtx, flag & WALLY_TX_FLAG_USE_WITNESS, &len);
@@ -408,7 +409,7 @@ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, const u8 **cursor,
int flags = WALLY_TX_FLAG_USE_WITNESS; int flags = WALLY_TX_FLAG_USE_WITNESS;
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx); struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
if (is_elements) if (chainparams->is_elements)
flags |= WALLY_TX_FLAG_USE_ELEMENTS; flags |= WALLY_TX_FLAG_USE_ELEMENTS;
if (wally_tx_from_bytes(*cursor, *max, flags, &tx->wtx) != WALLY_OK) { if (wally_tx_from_bytes(*cursor, *max, flags, &tx->wtx) != WALLY_OK) {

View File

@@ -3001,8 +3001,6 @@ static void init_channel(struct peer *peer)
} }
/* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = HSM */ /* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = HSM */
per_peer_state_set_fds(peer->pps, 3, 4, 5); per_peer_state_set_fds(peer->pps, 3, 4, 5);
is_elements = chainparams->is_elements;
peer->chain_hash = chainparams->genesis_blockhash; peer->chain_hash = chainparams->genesis_blockhash;
status_debug("init %s: remote_per_commit = %s, old_remote_per_commit = %s" status_debug("init %s: remote_per_commit = %s, old_remote_per_commit = %s"

View File

@@ -465,11 +465,11 @@ int main(void)
u64 commitment_number, cn_obscurer; u64 commitment_number, cn_obscurer;
struct amount_msat to_local, to_remote; struct amount_msat to_local, to_remote;
const struct htlc **htlcs, **htlc_map, **htlc_map2, **inv_htlcs; const struct htlc **htlcs, **htlc_map, **htlc_map2, **inv_htlcs;
const struct chainparams *chainparams = chainparams_for_network("bitcoin");
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN); | SECP256K1_CONTEXT_SIGN);
setup_tmpctx(); setup_tmpctx();
chainparams = chainparams_for_network("bitcoin");
htlcs = setup_htlcs(tmpctx); htlcs = setup_htlcs(tmpctx);
inv_htlcs = invert_htlcs(htlcs); inv_htlcs = invert_htlcs(htlcs);

View File

@@ -354,11 +354,11 @@ int main(void)
const struct htlc **htlc_map, **htlcs; const struct htlc **htlc_map, **htlcs;
const u8 *funding_wscript, **wscripts; const u8 *funding_wscript, **wscripts;
size_t i; size_t i;
const struct chainparams *chainparams = chainparams_for_network("bitcoin");
wally_init(0); wally_init(0);
secp256k1_ctx = wally_get_secp_context(); secp256k1_ctx = wally_get_secp_context();
setup_tmpctx(); setup_tmpctx();
chainparams = chainparams_for_network("bitcoin");
feerate_per_kw = tal_arr(tmpctx, u32, NUM_SIDES); feerate_per_kw = tal_arr(tmpctx, u32, NUM_SIDES);
unknown = tal(tmpctx, struct pubkey); unknown = tal(tmpctx, struct pubkey);

View File

@@ -22,7 +22,7 @@ struct ripemd160;
static inline size_t elements_add_overhead(size_t weight, size_t incount, static inline size_t elements_add_overhead(size_t weight, size_t incount,
size_t outcount) size_t outcount)
{ {
if (is_elements) { if (chainparams->is_elements) {
/* Each transaction has surjection and rangeproof (both empty /* Each transaction has surjection and rangeproof (both empty
* for us as long as we use unblinded L-BTC transactions). */ * for us as long as we use unblinded L-BTC transactions). */
weight += 2 * 4; weight += 2 * 4;

View File

@@ -43,7 +43,7 @@ static inline struct amount_sat commit_tx_base_fee(u32 feerate_per_kw,
*/ */
weight += 172 * num_untrimmed_htlcs; weight += 172 * num_untrimmed_htlcs;
if (is_elements) { if (chainparams->is_elements) {
/* Each transaction has surjection and rangeproof (both empty /* Each transaction has surjection and rangeproof (both empty
* for us as long as we use unblinded L-BTC transactions). */ * for us as long as we use unblinded L-BTC transactions). */
weight += 2 * 4; weight += 2 * 4;

View File

@@ -110,11 +110,11 @@ int main(void)
struct bitcoin_signature sig; struct bitcoin_signature sig;
struct bitcoin_address addr; struct bitcoin_address addr;
struct amount_sat tmpamt; struct amount_sat tmpamt;
const struct chainparams *chainparams = chainparams_for_network("bitcoin");
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN); | SECP256K1_CONTEXT_SIGN);
setup_tmpctx(); setup_tmpctx();
chainparams = chainparams_for_network("bitcoin");
/* BOLT #3: /* BOLT #3:
* *

View File

@@ -1,4 +1,5 @@
#include "utils.h" #include "utils.h"
#include <bitcoin/chainparams.h>
#include <ccan/list/list.h> #include <ccan/list/list.h>
#include <ccan/str/hex/hex.h> #include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h> #include <ccan/tal/str/str.h>
@@ -6,10 +7,14 @@
secp256k1_context *secp256k1_ctx; secp256k1_context *secp256k1_ctx;
const tal_t *tmpctx; const tal_t *tmpctx;
bool is_elements = false;
const struct chainparams *chainparams; const struct chainparams *chainparams;
bool is_elements(const struct chainparams *chainparams)
{
return chainparams->is_elements;
}
char *tal_hexstr(const tal_t *ctx, const void *data, size_t len) char *tal_hexstr(const tal_t *ctx, const void *data, size_t len)
{ {
char *str = tal_arr(ctx, char, hex_str_size(len)); char *str = tal_arr(ctx, char, hex_str_size(len));

View File

@@ -10,11 +10,12 @@
extern secp256k1_context *secp256k1_ctx; extern secp256k1_context *secp256k1_ctx;
/* FIXME: Instead of using this as a global, we might want to pass it as
* context whenever we need it. The global var is just lazy... */
extern bool is_elements;
extern const struct chainparams *chainparams; extern const struct chainparams *chainparams;
/* Simple accessor function for our own dependencies to use, in order to avoid
* circular dependencies (should only be used in `bitcoin/y`). */
bool is_elements(const struct chainparams *chainparams);
/* Allocate and fill in a hex-encoded string of this data. */ /* Allocate and fill in a hex-encoded string of this data. */
char *tal_hexstr(const tal_t *ctx, const void *data, size_t len); char *tal_hexstr(const tal_t *ctx, const void *data, size_t len);

View File

@@ -31,7 +31,7 @@ static struct amount_sat calc_tx_fee(struct amount_sat sat_in,
scriptlen = tal_bytelen(oscript); scriptlen = tal_bytelen(oscript);
tal_free(oscript); tal_free(oscript);
if (is_elements && scriptlen == 0) if (chainparams->is_elements && scriptlen == 0)
continue; continue;
if (!amount_sat_sub(&fee, fee, amt)) if (!amount_sat_sub(&fee, fee, amt))

View File

@@ -247,7 +247,6 @@ static char *opt_set_network(const char *arg, struct lightningd *ld)
ld->topology->bitcoind->chainparams = chainparams; ld->topology->bitcoind->chainparams = chainparams;
if (!ld->topology->bitcoind->chainparams) if (!ld->topology->bitcoind->chainparams)
return tal_fmt(NULL, "Unknown network name '%s'", arg); return tal_fmt(NULL, "Unknown network name '%s'", arg);
is_elements = ld->topology->bitcoind->chainparams->is_elements;
return NULL; return NULL;
} }

View File

@@ -727,7 +727,8 @@ static bool is_mutual_close(const struct bitcoin_tx *tx,
for (i = 0; i < tx->wtx->num_outputs; i++) { for (i = 0; i < tx->wtx->num_outputs; i++) {
const u8 *script = bitcoin_tx_output_get_script(tmpctx, tx, i); const u8 *script = bitcoin_tx_output_get_script(tmpctx, tx, i);
/* To be paranoid, we only let each one match once. */ /* To be paranoid, we only let each one match once. */
if (is_elements && (script == NULL || tal_bytelen(script) == 0)) { if (chainparams->is_elements &&
(script == NULL || tal_bytelen(script) == 0)) {
/* This is a fee output, ignore please */ /* This is a fee output, ignore please */
continue; continue;
} else if (scripteq(script, local_scriptpubkey) } else if (scripteq(script, local_scriptpubkey)
@@ -1797,7 +1798,8 @@ static void handle_our_unilateral(const struct bitcoin_tx *tx,
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i); const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i); struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
if (is_elements && (oscript == NULL || tal_bytelen(oscript) == 0)) { if (chainparams->is_elements &&
(oscript == NULL || tal_bytelen(oscript) == 0)) {
status_debug("OUTPUT %zu is a fee output", i); status_debug("OUTPUT %zu is a fee output", i);
/* An empty script simply means that that this is a /* An empty script simply means that that this is a
* fee output. */ * fee output. */
@@ -2157,7 +2159,8 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i); const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i); struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
if (is_elements && (oscript == NULL || tal_bytelen(oscript) == 0)) { if (chainparams->is_elements &&
(oscript == NULL || tal_bytelen(oscript) == 0)) {
/* An empty script simply means that that this is a /* An empty script simply means that that this is a
* fee output. */ * fee output. */
out = new_tracked_output(tx->chainparams, out = new_tracked_output(tx->chainparams,
@@ -2390,7 +2393,8 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i); const u8 *oscript = bitcoin_tx_output_get_script(tmpctx, tx, i);
struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i); struct amount_sat amt = bitcoin_tx_output_get_amount(tx, i);
if (is_elements && (oscript == NULL || tal_bytelen(oscript) == 0)) { if (chainparams->is_elements &&
(oscript == NULL || tal_bytelen(oscript) == 0)) {
/* An empty script simply means that that this is a /* An empty script simply means that that this is a
* fee output. */ * fee output. */
out = new_tracked_output(tx->chainparams, out = new_tracked_output(tx->chainparams,

View File

@@ -244,6 +244,8 @@ int main(void)
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN); | SECP256K1_CONTEXT_SIGN);
setup_tmpctx(); setup_tmpctx();
chainparams = chainparams_for_network("bitcoin");
htlcs[0].cltv_expiry = 585998; htlcs[0].cltv_expiry = 585998;
htlcs[1].cltv_expiry = 585998; htlcs[1].cltv_expiry = 585998;
htlcs[2].cltv_expiry = 586034; htlcs[2].cltv_expiry = 586034;

View File

@@ -201,6 +201,7 @@ int main(int argc, char *argv[])
secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY secp256k1_ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY
| SECP256K1_CONTEXT_SIGN); | SECP256K1_CONTEXT_SIGN);
setup_tmpctx(); setup_tmpctx();
chainparams = chainparams_for_network("bitcoin");
tx = bitcoin_tx_from_hex(tmpctx, "0200000001e1ebca08cf1c301ac563580a1126d5c8fcb0e5e2043230b852c726553caf1e1d0000000000000000000160ae0a000000000022002082e03c5a9cb79c82cd5a0572dc175290bc044609aabe9cc852d61927436041796d000000", tx = bitcoin_tx_from_hex(tmpctx, "0200000001e1ebca08cf1c301ac563580a1126d5c8fcb0e5e2043230b852c726553caf1e1d0000000000000000000160ae0a000000000022002082e03c5a9cb79c82cd5a0572dc175290bc044609aabe9cc852d61927436041796d000000",
strlen("0200000001e1ebca08cf1c301ac563580a1126d5c8fcb0e5e2043230b852c726553caf1e1d0000000000000000000160ae0a000000000022002082e03c5a9cb79c82cd5a0572dc175290bc044609aabe9cc852d61927436041796d000000")); strlen("0200000001e1ebca08cf1c301ac563580a1126d5c8fcb0e5e2043230b852c726553caf1e1d0000000000000000000160ae0a000000000022002082e03c5a9cb79c82cd5a0572dc175290bc044609aabe9cc852d61927436041796d000000"));
tx->chainparams = chainparams_for_network("regtest"); tx->chainparams = chainparams_for_network("regtest");

View File

@@ -1451,7 +1451,6 @@ int main(int argc, char *argv[])
* regtest modes, so we have a general "parameters for this chain" * regtest modes, so we have a general "parameters for this chain"
* function. */ * function. */
state->chainparams = chainparams; state->chainparams = chainparams;
is_elements = state->chainparams->is_elements;
/*~ Initially we're not associated with a channel, but /*~ Initially we're not associated with a channel, but
* handle_peer_gossip_or_error compares this. */ * handle_peer_gossip_or_error compares this. */

View File

@@ -543,7 +543,6 @@ static struct command_result *handle_init(struct command *init_cmd,
nettok = json_delve(buf, configtok, ".network"); nettok = json_delve(buf, configtok, ".network");
network = json_strdup(tmpctx, buf, nettok); network = json_strdup(tmpctx, buf, nettok);
chainparams = chainparams_for_network(network); chainparams = chainparams_for_network(network);
is_elements = chainparams->is_elements;
rpctok = json_delve(buf, configtok, ".rpc-file"); rpctok = json_delve(buf, configtok, ".rpc-file");
rpc_conn.fd = socket(AF_UNIX, SOCK_STREAM, 0); rpc_conn.fd = socket(AF_UNIX, SOCK_STREAM, 0);

View File

@@ -1298,6 +1298,7 @@ static bool test_wallet_payment_status_enum(void)
int main(void) int main(void)
{ {
setup_locale(); setup_locale();
chainparams = chainparams_for_network("bitcoin");
bool ok = true; bool ok = true;
struct lightningd *ld; struct lightningd *ld;

View File

@@ -372,7 +372,7 @@ static const struct utxo **wallet_select(const tal_t *ctx, struct wallet *w,
weight += (8 + 1 + BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN) * 4; weight += (8 + 1 + BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN) * 4;
/* A couple of things need to change for elements: */ /* A couple of things need to change for elements: */
if (is_elements) { if (chainparams->is_elements) {
/* Each transaction has surjection and rangeproof (both empty /* Each transaction has surjection and rangeproof (both empty
* for us as long as we use unblinded L-BTC transactions). */ * for us as long as we use unblinded L-BTC transactions). */
weight += 2 * 4; weight += 2 * 4;
@@ -425,7 +425,7 @@ static const struct utxo **wallet_select(const tal_t *ctx, struct wallet *w,
input_weight += 1 + (1 + 73 + 1 + 33); input_weight += 1 + (1 + 73 + 1 + 33);
/* Elements inputs have 6 bytes of blank proofs attached. */ /* Elements inputs have 6 bytes of blank proofs attached. */
if (is_elements) if (chainparams->is_elements)
input_weight += 6; input_weight += 6;
weight += input_weight; weight += input_weight;

View File

@@ -398,5 +398,4 @@ void fromwire_chainparams(const u8 **cursor, size_t *max,
struct bitcoin_blkid genesis; struct bitcoin_blkid genesis;
fromwire_bitcoin_blkid(cursor, max, &genesis); fromwire_bitcoin_blkid(cursor, max, &genesis);
*chainparams = chainparams_by_chainhash(&genesis); *chainparams = chainparams_by_chainhash(&genesis);
is_elements = (*chainparams)->is_elements;
} }