lightningd: move testnet flag out of config.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-10-07 14:00:18 +10:30
parent 1e6f7059d3
commit c0d0606d66
5 changed files with 10 additions and 9 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);
}