Skip to content

Commit da2fb19

Browse files
committed
setconfig: make source for setconfig "setconfig transient".
Previously it would be the value of the previous config setting. Signed-off-by: Rusty Russell <[email protected]>
1 parent 5a80223 commit da2fb19

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

common/configvar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* 3. An implied config (~/.lightning/config) (and includes)
1212
* 4. A network config ((~/.lightning/<network>/config) (and includes)
1313
* 5. A plugin start parameter.
14+
* 6. Setconfig called with transient=true
1415
*
1516
* Turns out we care: you can't set network in a network config for
1617
* example.
@@ -22,6 +23,7 @@ enum configvar_src {
2223
CONFIGVAR_BASE_CONF,
2324
CONFIGVAR_NETWORK_CONF,
2425
CONFIGVAR_PLUGIN_START,
26+
CONFIGVAR_SETCONFIG_TRANSIENT,
2527
};
2628

2729
/* This represents the configuration variables specified; they are

lightningd/configs.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ static void json_add_source(struct json_stream *result,
4242
case CONFIGVAR_PLUGIN_START:
4343
source = "pluginstart";
4444
break;
45+
case CONFIGVAR_SETCONFIG_TRANSIENT:
46+
source = "setconfig transient";
47+
break;
4548
}
4649
}
4750
json_add_string(result, fieldname, source);
@@ -376,7 +379,7 @@ static void configvar_updated(struct lightningd *ld,
376379

377380
log_info(ld->log, "setconfig: %s %s (updated %s:%u)",
378381
cv->optvar, cv->optarg ? cv->optarg : "SET",
379-
cv->file, cv->linenum);
382+
cv->file ? cv->file : "NULL", cv->linenum);
380383

381384
tal_arr_expand(&ld->configvars, cv);
382385
configvar_finalize_overrides(ld->configvars);
@@ -446,6 +449,7 @@ static bool configfile_replace_var(struct lightningd *ld,
446449
case CONFIGVAR_CMDLINE:
447450
case CONFIGVAR_CMDLINE_SHORT:
448451
case CONFIGVAR_PLUGIN_START:
452+
case CONFIGVAR_SETCONFIG_TRANSIENT:
449453
/* These can't be commented out */
450454
return false;
451455
case CONFIGVAR_EXPLICIT_CONF:
@@ -568,6 +572,9 @@ static struct command_result *setconfig_success(struct command *cmd,
568572

569573
if (!transient)
570574
configvar_save(cmd->ld, names, confline);
575+
else
576+
configvar_updated(cmd->ld, CONFIGVAR_SETCONFIG_TRANSIENT, NULL, 0, confline);
577+
571578

572579
response = json_stream_success(cmd);
573580
json_object_start(response, "config");

tests/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4169,7 +4169,7 @@ def test_setconfig(node_factory, bitcoind):
41694169
ret = l2.rpc.setconfig(config='min-capacity-sat', val=400001, transient=True)
41704170
assert ret == {'config':
41714171
{'config': 'min-capacity-sat',
4172-
'source': '{}:3'.format(configfile),
4172+
'source': 'setconfig transient',
41734173
'value_int': 400001,
41744174
'dynamic': True}}
41754175

0 commit comments

Comments
 (0)