mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
devtools: revert changes and make sure chainparams always set.
[Also fixes crash with -h, since chainparams was not set! --RR]
This commit is contained in:
committed by
Rusty Russell
parent
2c9d7484a2
commit
2754e30269
@@ -21,13 +21,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wire/peer_wire.h>
|
#include <wire/peer_wire.h>
|
||||||
|
|
||||||
#define chainparams_get_ln_port simple_get_ln_port
|
|
||||||
#define io_write_ simple_write
|
#define io_write_ simple_write
|
||||||
#define io_read_ simple_read
|
#define io_read_ simple_read
|
||||||
#define io_close simple_close
|
#define io_close simple_close
|
||||||
static bool stream_stdin = false;
|
static bool stream_stdin = false;
|
||||||
static bool no_init = false;
|
static bool no_init = false;
|
||||||
static bool hex = false;
|
static bool hex = false;
|
||||||
|
static bool explicit_network = false;
|
||||||
static int timeout_after = -1;
|
static int timeout_after = -1;
|
||||||
static u8 *features;
|
static u8 *features;
|
||||||
|
|
||||||
@@ -46,11 +46,6 @@ static struct io_plan *simple_close(struct io_conn *conn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int simple_get_ln_port(const struct chainparams *params UNNEEDED)
|
|
||||||
{
|
|
||||||
return 9735;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "../connectd/handshake.c"
|
#include "../connectd/handshake.c"
|
||||||
|
|
||||||
/* This makes the handshake prototypes work. */
|
/* This makes the handshake prototypes work. */
|
||||||
@@ -83,6 +78,7 @@ static char *opt_set_network(const char *arg, void *unused)
|
|||||||
chainparams = chainparams_for_network(arg);
|
chainparams = chainparams_for_network(arg);
|
||||||
if (!chainparams)
|
if (!chainparams)
|
||||||
return tal_fmt(NULL, "Unknown network name '%s'", arg);
|
return tal_fmt(NULL, "Unknown network name '%s'", arg);
|
||||||
|
explicit_network = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,12 +180,12 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
|||||||
|
|
||||||
if (!no_init) {
|
if (!no_init) {
|
||||||
struct tlv_init_tlvs *tlvs = NULL;
|
struct tlv_init_tlvs *tlvs = NULL;
|
||||||
if (chainparams) {
|
if (explicit_network) {
|
||||||
tlvs = tlv_init_tlvs_new(NULL);
|
tlvs = tlv_init_tlvs_new(NULL);
|
||||||
tlvs->networks = tal_arr(tlvs, struct bitcoin_blkid, 1);
|
tlvs->networks = tal_arr(tlvs, struct bitcoin_blkid, 1);
|
||||||
tlvs->networks[0] = chainparams->genesis_blockhash;
|
tlvs->networks[0] = chainparams->genesis_blockhash;
|
||||||
}
|
}
|
||||||
msg = towire_init(NULL, NULL, features, tlvs);
|
msg = towire_init(NULL, NULL, features, tlvs);
|
||||||
|
|
||||||
sync_crypto_write(peer_fd, cs, take(msg));
|
sync_crypto_write(peer_fd, cs, take(msg));
|
||||||
/* Ignore their init message. */
|
/* Ignore their init message. */
|
||||||
@@ -287,6 +283,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
memset(¬sosecret, 0x42, sizeof(notsosecret));
|
memset(¬sosecret, 0x42, sizeof(notsosecret));
|
||||||
features = tal_arr(conn, u8, 0);
|
features = tal_arr(conn, u8, 0);
|
||||||
|
chainparams = chainparams_for_network("bitcoin");
|
||||||
|
|
||||||
opt_register_noarg("--initial-sync", opt_set_bool, &initial_sync,
|
opt_register_noarg("--initial-sync", opt_set_bool, &initial_sync,
|
||||||
"Stream complete gossip history at start");
|
"Stream complete gossip history at start");
|
||||||
@@ -328,7 +325,7 @@ int main(int argc, char *argv[])
|
|||||||
opt_usage_exit_fail("Invalid id %.*s",
|
opt_usage_exit_fail("Invalid id %.*s",
|
||||||
(int)(at - argv[1]), argv[1]);
|
(int)(at - argv[1]), argv[1]);
|
||||||
|
|
||||||
if (!parse_wireaddr_internal(at+1, &addr, simple_get_ln_port(NULL), NULL,
|
if (!parse_wireaddr_internal(at+1, &addr, chainparams_get_ln_port(chainparams), NULL,
|
||||||
true, false, true, &err_msg))
|
true, false, true, &err_msg))
|
||||||
opt_usage_exit_fail("%s '%s'", err_msg, argv[1]);
|
opt_usage_exit_fail("%s '%s'", err_msg, argv[1]);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import time
|
|||||||
EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1"
|
EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1"
|
||||||
COMPAT = env("COMPAT", "1") == "1"
|
COMPAT = env("COMPAT", "1") == "1"
|
||||||
|
|
||||||
|
|
||||||
def default_ln_port(network: str) -> int:
|
def default_ln_port(network: str) -> int:
|
||||||
network_map = {
|
network_map = {
|
||||||
"bitcoin": 9735,
|
"bitcoin": 9735,
|
||||||
@@ -15,10 +16,11 @@ def default_ln_port(network: str) -> int:
|
|||||||
"regtest": 19846,
|
"regtest": 19846,
|
||||||
"signet": 39735,
|
"signet": 39735,
|
||||||
"liquid-regtest": 20735,
|
"liquid-regtest": 20735,
|
||||||
"liquid": 9735,
|
"liquid": 9735,
|
||||||
}
|
}
|
||||||
return network_map[network]
|
return network_map[network]
|
||||||
|
|
||||||
|
|
||||||
def anchor_expected():
|
def anchor_expected():
|
||||||
return EXPERIMENTAL_FEATURES or EXPERIMENTAL_DUAL_FUND
|
return EXPERIMENTAL_FEATURES or EXPERIMENTAL_DUAL_FUND
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user