From fbc2b65a3d488fe7723231500cecf978c75b7eb5 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 10 Jul 2017 13:35:43 +0200 Subject: [PATCH] opening: Pass network_index through to openingd This is needed in order to open channels with the correct genesis_blockhash. Reported-By: @sstone --- lightningd/opening/opening.c | 2 ++ lightningd/opening/opening_wire.csv | 2 ++ lightningd/peer_control.c | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lightningd/opening/opening.c b/lightningd/opening/opening.c index 50bfb4255..9bb8157aa 100644 --- a/lightningd/opening/opening.c +++ b/lightningd/opening/opening.c @@ -691,6 +691,7 @@ int main(int argc, char *argv[]) u8 channel_flags; struct utxo *utxos; u8 *bip32_seed; + u32 network_index; if (argc == 2 && streq(argv[1], "--version")) { printf("%s\n", version()); @@ -710,6 +711,7 @@ int main(int argc, char *argv[]) status_failed(WIRE_OPENING_BAD_COMMAND, "%s", strerror(errno)); if (!fromwire_opening_init(msg, NULL, + &network_index, &state->localconf, &state->max_to_self_delay, &state->min_effective_htlc_capacity_msat, diff --git a/lightningd/opening/opening_wire.csv b/lightningd/opening/opening_wire.csv index bc0944335..1e80ea952 100644 --- a/lightningd/opening/opening_wire.csv +++ b/lightningd/opening/opening_wire.csv @@ -14,6 +14,8 @@ opening_peer_bad_initial_message,0x8014 #include #include opening_init,0 +# Which network are we configured for (as index into the chainparams)? +opening_init,,network_index,4 # Base configuration we'll offer (channel reserve will vary with amount) opening_init,,our_config,struct channel_config # Minimum/maximum configuration values we'll accept diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 7e4bc8556..809e3fa28 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1916,7 +1916,8 @@ void peer_fundee_open(struct peer *peer, const u8 *from_peer, peer->seed = tal(peer, struct privkey); derive_peer_seed(ld, peer->seed, &peer->id); - msg = towire_opening_init(peer, &peer->our_config, + msg = towire_opening_init(peer, ld->chainparams->index, + &peer->our_config, max_to_self_delay, min_effective_htlc_capacity_msat, cs, peer->seed); @@ -1986,7 +1987,8 @@ static bool gossip_peer_released(struct subd *gossip, fc->peer->seed = tal(fc->peer, struct privkey); derive_peer_seed(ld, fc->peer->seed, &fc->peer->id); - msg = towire_opening_init(fc, &fc->peer->our_config, + msg = towire_opening_init(fc, ld->chainparams->index, + &fc->peer->our_config, max_to_self_delay, min_effective_htlc_capacity_msat, &cs, fc->peer->seed);