diff --git a/doc/lightning-makesecret.7.md b/doc/lightning-makesecret.7.md index 2fdbf9755..7170061cb 100644 --- a/doc/lightning-makesecret.7.md +++ b/doc/lightning-makesecret.7.md @@ -4,14 +4,14 @@ lightning-makesecret -- Command for deriving pseudorandom key from HSM SYNOPSIS -------- -**makesecret** *info_hex* +**makesecret** *hex* DESCRIPTION ----------- 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 ------------ diff --git a/doc/schemas/makesecret.request.json b/doc/schemas/makesecret.request.json index a43ac493e..c26e3ce4b 100644 --- a/doc/schemas/makesecret.request.json +++ b/doc/schemas/makesecret.request.json @@ -3,10 +3,10 @@ "type": "object", "additionalProperties": false, "required": [ - "info_hex" + "hex" ], "properties": { - "info": { + "hex": { "type": "hex", "description": "This will be used for deriving the secret" } diff --git a/lightningd/hsm_control.c b/lightningd/hsm_control.c index d5f6413a9..c30895499 100644 --- a/lightningd/hsm_control.c +++ b/lightningd/hsm_control.c @@ -158,7 +158,7 @@ static struct command_result *json_makesecret(struct command *cmd, struct secret secret; if (!param(cmd, buffer, params, - p_req("info_hex", param_bin_from_hex, &info), + p_req("hex", param_bin_from_hex, &info), NULL)) return command_param_failed(); @@ -183,7 +183,7 @@ static const struct json_command makesecret_command = { "makesecret", "utility", &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); diff --git a/plugins/chanbackup.c b/plugins/chanbackup.c index cd8376be4..85637ba2f 100644 --- a/plugins/chanbackup.c +++ b/plugins/chanbackup.c @@ -376,7 +376,7 @@ static const char *init(struct plugin *p, "{scb:%}", JSON_SCAN(json_to_scb_chan, &scb_chan)); rpc_scan(p, "makesecret", - take(json_out_obj(NULL, "info_hex", + take(json_out_obj(NULL, "hex", tal_hexstr(tmpctx, info_hex, tal_bytelen(info_hex)))), diff --git a/tests/test_misc.py b/tests/test_misc.py index bafd13911..cac96dcf5 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2282,6 +2282,14 @@ def test_makesecret(node_factory): 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): """