Skip to content

Commit 90b6cbc

Browse files
vincenzopalazzorustyrussell
authored andcommitted
devtools: revert changes and make sure chainparams always set.
[Also fixes crash with -h, since chainparams was not set! --RR]
1 parent c84b416 commit 90b6cbc

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

devtools/gossipwith.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#include <stdio.h>
2222
#include <wire/peer_wire.h>
2323

24-
#define chainparams_get_ln_port simple_get_ln_port
2524
#define io_write_ simple_write
2625
#define io_read_ simple_read
2726
#define io_close simple_close
2827
static bool stream_stdin = false;
2928
static bool no_init = false;
3029
static bool hex = false;
30+
static bool explicit_network = false;
3131
static int timeout_after = -1;
3232
static u8 *features;
3333

@@ -46,11 +46,6 @@ static struct io_plan *simple_close(struct io_conn *conn)
4646
return NULL;
4747
}
4848

49-
static int simple_get_ln_port(const struct chainparams *params UNNEEDED)
50-
{
51-
return 9735;
52-
}
53-
5449
#include "../connectd/handshake.c"
5550

5651
/* This makes the handshake prototypes work. */
@@ -83,6 +78,7 @@ static char *opt_set_network(const char *arg, void *unused)
8378
chainparams = chainparams_for_network(arg);
8479
if (!chainparams)
8580
return tal_fmt(NULL, "Unknown network name '%s'", arg);
81+
explicit_network = true;
8682
return NULL;
8783
}
8884

@@ -184,12 +180,12 @@ static struct io_plan *handshake_success(struct io_conn *conn,
184180

185181
if (!no_init) {
186182
struct tlv_init_tlvs *tlvs = NULL;
187-
if (chainparams) {
183+
if (explicit_network) {
188184
tlvs = tlv_init_tlvs_new(NULL);
189185
tlvs->networks = tal_arr(tlvs, struct bitcoin_blkid, 1);
190186
tlvs->networks[0] = chainparams->genesis_blockhash;
191187
}
192-
msg = towire_init(NULL, NULL, features, tlvs);
188+
msg = towire_init(NULL, NULL, features, tlvs);
193189

194190
sync_crypto_write(peer_fd, cs, take(msg));
195191
/* Ignore their init message. */
@@ -287,6 +283,7 @@ int main(int argc, char *argv[])
287283

288284
memset(&notsosecret, 0x42, sizeof(notsosecret));
289285
features = tal_arr(conn, u8, 0);
286+
chainparams = chainparams_for_network("bitcoin");
290287

291288
opt_register_noarg("--initial-sync", opt_set_bool, &initial_sync,
292289
"Stream complete gossip history at start");
@@ -328,7 +325,7 @@ int main(int argc, char *argv[])
328325
opt_usage_exit_fail("Invalid id %.*s",
329326
(int)(at - argv[1]), argv[1]);
330327

331-
if (!parse_wireaddr_internal(at+1, &addr, simple_get_ln_port(NULL), NULL,
328+
if (!parse_wireaddr_internal(at+1, &addr, chainparams_get_ln_port(chainparams), NULL,
332329
true, false, true, &err_msg))
333330
opt_usage_exit_fail("%s '%s'", err_msg, argv[1]);
334331

tests/utils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1"
99
COMPAT = env("COMPAT", "1") == "1"
1010

11+
1112
def default_ln_port(network: str) -> int:
1213
network_map = {
1314
"bitcoin": 9735,
1415
"testnet": 19735,
1516
"regtest": 19846,
1617
"signet": 39735,
1718
"liquid-regtest": 20735,
18-
"liquid": 9735,
19+
"liquid": 9735,
1920
}
2021
return network_map[network]
2122

23+
2224
def anchor_expected():
2325
return EXPERIMENTAL_FEATURES or EXPERIMENTAL_DUAL_FUND
2426

0 commit comments

Comments
 (0)