diff --git a/bitcoin/block.c b/bitcoin/block.c index c57e90ecf..d12a97a77 100644 --- a/bitcoin/block.c +++ b/bitcoin/block.c @@ -3,13 +3,6 @@ #include "bitcoin/tx.h" #include -const struct sha256_double genesis_blockhash -= { { .u.u8 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0xd6, 0x68, - 0x9c, 0x08, 0x5a, 0xe1, 0x65, 0x83, 0x1e, 0x93, - 0x4f, 0xf7, 0x63, 0xae, 0x46, 0xa2, 0xa6, 0xc1, - 0x72, 0xb3, 0xf1, 0xb6, 0x0a, 0x8c, 0xe2, 0x6f - } } }; - /* Encoding is ... */ struct bitcoin_block *bitcoin_block_from_hex(const tal_t *ctx, const char *hex, size_t hexlen) diff --git a/bitcoin/block.h b/bitcoin/block.h index 0e88b3508..44b712b61 100644 --- a/bitcoin/block.h +++ b/bitcoin/block.h @@ -22,8 +22,6 @@ struct bitcoin_block { struct bitcoin_tx **tx; }; -const struct sha256_double genesis_blockhash; - struct bitcoin_block *bitcoin_block_from_hex(const tal_t *ctx, const char *hex, size_t hexlen); diff --git a/lightningd/opening/opening.c b/lightningd/opening/opening.c index 9bb8157aa..a7a75c376 100644 --- a/lightningd/opening/opening.c +++ b/lightningd/opening/opening.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -55,6 +56,8 @@ struct state { u64 min_effective_htlc_capacity_msat; struct channel *channel; + + const struct chainparams *chainparams; }; static void check_config_bounds(struct state *state, @@ -246,7 +249,9 @@ static u8 *funder_channel(struct state *state, "push-msat must be < %"PRIu64, 1000 * state->funding_satoshis); - msg = towire_open_channel(tmpctx, &genesis_blockhash.sha, &channel_id, + msg = towire_open_channel(tmpctx, + &state->chainparams->genesis_blockhash.sha, + &channel_id, state->funding_satoshis, state->push_msat, state->localconf.dust_limit_satoshis, state->localconf.max_htlc_value_in_flight_msat, @@ -507,7 +512,7 @@ static u8 *fundee_channel(struct state *state, * within the `open_channel` message is set to a hash of a chain * unknown to the receiver. */ - if (!structeq(&chain_hash, &genesis_blockhash)) { + if (!structeq(&chain_hash, &state->chainparams->genesis_blockhash)) { peer_failed(PEER_FD, &state->cs, NULL, WIRE_OPENING_PEER_BAD_INITIAL_MESSAGE, "Unknown chain-hash %s", @@ -720,6 +725,8 @@ int main(int argc, char *argv[]) status_failed(WIRE_OPENING_BAD_COMMAND, "%s", strerror(errno)); tal_free(msg); + state->chainparams = chainparams_by_index(network_index); + /* We derive everything from the one secret seed. */ if (!derive_basepoints(&seed, &our_funding_pubkey, &our_points, &state->our_secrets,