makesecret: change info_hex arg to simply "hex" to match datastore command.

And fix schema: it wasn't tested as there was no test-by-parameter-name.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-07-15 13:57:07 +09:30
parent 769efe8d54
commit c34a0a22ad
5 changed files with 15 additions and 7 deletions

View File

@ -4,14 +4,14 @@ lightning-makesecret -- Command for deriving pseudorandom key from HSM
SYNOPSIS SYNOPSIS
-------- --------
**makesecret** *info_hex* **makesecret** *hex*
DESCRIPTION DESCRIPTION
----------- -----------
The **makesecret** RPC command derives a secret key from the HSM_secret. The **makesecret** RPC command derives a secret key from the HSM_secret.
The *info_hex* can be any hex data. The *hex* can be any hex data.
RETURN VALUE RETURN VALUE
------------ ------------

View File

@ -3,10 +3,10 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
"info_hex" "hex"
], ],
"properties": { "properties": {
"info": { "hex": {
"type": "hex", "type": "hex",
"description": "This will be used for deriving the secret" "description": "This will be used for deriving the secret"
} }

View File

@ -158,7 +158,7 @@ static struct command_result *json_makesecret(struct command *cmd,
struct secret secret; struct secret secret;
if (!param(cmd, buffer, params, if (!param(cmd, buffer, params,
p_req("info_hex", param_bin_from_hex, &info), p_req("hex", param_bin_from_hex, &info),
NULL)) NULL))
return command_param_failed(); return command_param_failed();
@ -183,7 +183,7 @@ static const struct json_command makesecret_command = {
"makesecret", "makesecret",
"utility", "utility",
&json_makesecret, &json_makesecret,
"Get a pseudorandom secret key, using an info string." "Get a pseudorandom secret key, using some {hex} data."
}; };
AUTODATA(json_command, &makesecret_command); AUTODATA(json_command, &makesecret_command);

View File

@ -376,7 +376,7 @@ static const char *init(struct plugin *p,
"{scb:%}", JSON_SCAN(json_to_scb_chan, &scb_chan)); "{scb:%}", JSON_SCAN(json_to_scb_chan, &scb_chan));
rpc_scan(p, "makesecret", rpc_scan(p, "makesecret",
take(json_out_obj(NULL, "info_hex", take(json_out_obj(NULL, "hex",
tal_hexstr(tmpctx, tal_hexstr(tmpctx,
info_hex, info_hex,
tal_bytelen(info_hex)))), tal_bytelen(info_hex)))),

View File

@ -2282,6 +2282,14 @@ def test_makesecret(node_factory):
assert (secret == "04fe01631fcedc8d91f39ab43244e63afebaed68ee21d2f1c325fd1242726a18") assert (secret == "04fe01631fcedc8d91f39ab43244e63afebaed68ee21d2f1c325fd1242726a18")
# Same if we do it by parameter name
assert l1.rpc.makesecret(hex="73636220736563726574")["secret"] == secret
# Changing seed changes secret!
assert l1.rpc.makesecret(hex="73636220736563726575")["secret"] != secret
assert l1.rpc.makesecret(hex="736362207365637265")["secret"] != secret
assert l1.rpc.makesecret(hex="7363622073656372657401")["secret"] != secret
def test_staticbackup(node_factory): def test_staticbackup(node_factory):
""" """