From c0d0606d6617e72d4d32702cd013c4e92ce70c53 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 7 Oct 2016 14:00:18 +1030 Subject: [PATCH] lightningd: move testnet flag out of config. Signed-off-by: Rusty Russell --- daemon/bitcoind.c | 2 +- daemon/jsonrpc.c | 2 +- daemon/lightningd.c | 3 +-- daemon/lightningd.h | 9 ++++++--- daemon/wallet.c | 3 +-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/daemon/bitcoind.c b/daemon/bitcoind.c index 68f08ff5a..f081d9d4b 100644 --- a/daemon/bitcoind.c +++ b/daemon/bitcoind.c @@ -34,7 +34,7 @@ static char **gather_args(struct lightningd_state *dstate, if (dstate->config.regtest) args[n++] = "-regtest=1"; else - args[n++] = tal_fmt(args, "-testnet=%u", dstate->config.testnet); + args[n++] = tal_fmt(args, "-testnet=%u", dstate->testnet); if (bitcoin_datadir) { args[n++] = tal_fmt(args, "-datadir=%s", bitcoin_datadir); tal_resize(&args, n + 1); diff --git a/daemon/jsonrpc.c b/daemon/jsonrpc.c index 6a1369b22..b376170e9 100644 --- a/daemon/jsonrpc.c +++ b/daemon/jsonrpc.c @@ -266,7 +266,7 @@ static void json_getinfo(struct command *cmd, /* FIXME: Keep netaddrs and list them all. */ if (cmd->dstate->portnum) json_add_num(response, "port", cmd->dstate->portnum); - json_add_bool(response, "testnet", cmd->dstate->config.testnet); + json_add_bool(response, "testnet", cmd->dstate->testnet); json_add_string(response, "version", version()); json_object_end(response); command_success(cmd, response); diff --git a/daemon/lightningd.c b/daemon/lightningd.c index 2832acf8f..46038a39b 100644 --- a/daemon/lightningd.c +++ b/daemon/lightningd.c @@ -163,8 +163,6 @@ static void dev_register_opts(struct lightningd_state *dstate) static void default_config(struct config *config) { - /* aka. "Dude, where's my coins?" */ - config->testnet = true; config->regtest = false; /* ~one day to catch cheating attempts. */ @@ -263,6 +261,7 @@ static struct lightningd_state *lightningd_state(void) list_head_init(&dstate->peers); list_head_init(&dstate->pay_commands); dstate->portnum = 0; + dstate->testnet = true; timers_init(&dstate->timers, controlled_time()); txwatch_hash_init(&dstate->txwatches); txowatch_hash_init(&dstate->txowatches); diff --git a/daemon/lightningd.h b/daemon/lightningd.h index 489c1b424..20f27b39c 100644 --- a/daemon/lightningd.h +++ b/daemon/lightningd.h @@ -11,8 +11,8 @@ /* Various adjustable things. */ struct config { - /* Are we on testnet? regtest?*/ - bool testnet, regtest; + /* Are we on regtest? */ + bool regtest; /* How long do we want them to lock up their funds? (blocks) */ u32 locktime_blocks; @@ -74,7 +74,10 @@ struct lightningd_state { /* Port we're listening on */ u16 portnum; - + + /* We're on testnet. */ + bool testnet; + /* Configuration settings. */ struct config config; diff --git a/daemon/wallet.c b/daemon/wallet.c index 62d424cd9..0f7269748 100644 --- a/daemon/wallet.c +++ b/daemon/wallet.c @@ -113,8 +113,7 @@ static void json_newaddr(struct command *cmd, json_object_start(response, NULL); json_add_string(response, "address", - p2sh_to_base58(cmd, cmd->dstate->config.testnet, - &w->p2sh)); + p2sh_to_base58(cmd, cmd->dstate->testnet, &w->p2sh)); json_object_end(response); command_success(cmd, response); }