From 5900742b3a26e4e6d1cfd413c24f2012b5c9213f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 1 Aug 2023 10:59:59 +0930 Subject: [PATCH] hsmtool: remove threshold arg. It really has to be 0, since it's the complete secret. And we didn't handle it well, (`a` would be treated as 0, for example!). Signed-off-by: Rusty Russell --- tests/test_misc.py | 10 +--------- tools/hsmtool.c | 11 +++++------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/test_misc.py b/tests/test_misc.py index 3182d3743..010a8681f 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1359,7 +1359,7 @@ def test_recover(node_factory, bitcoind): out = subprocess.check_output(cmd_line + ["leet", "0"]).decode('utf-8') assert out == "ms10leetsllhdmn9m42vcsamx24zrxgs3qrl7ahwvhw4fnzrhve25gvezzyqqtum9pgv99ycma\n" - # Check bad ids, threshold. + # Check bad ids. out = subprocess.run(cmd_line + ["lee", "0"], stderr=subprocess.PIPE, timeout=TIMEOUT) assert 'Invalid id: must be 4 characters' in out.stderr.decode('utf-8') assert out.returncode == 2 @@ -1377,14 +1377,6 @@ def test_recover(node_factory, bitcoind): assert 'Invalid id: must be valid bech32 string' in out.stderr.decode('utf-8') assert out.returncode == 2 - out = subprocess.run(cmd_line + ["leet", "1"], stderr=subprocess.PIPE, timeout=TIMEOUT) - assert 'Invalid threshold 1' in out.stderr.decode('utf-8') - assert out.returncode == 2 - - out = subprocess.run(cmd_line + ["leet", "99"], stderr=subprocess.PIPE, timeout=TIMEOUT) - assert 'Invalid threshold 99' in out.stderr.decode('utf-8') - assert out.returncode == 2 - basedir = l1.daemon.opts.get("lightning-dir") with open(os.path.join(basedir, TEST_NETWORK, 'hsm_secret'), 'rb') as f: buff = f.read() diff --git a/tools/hsmtool.c b/tools/hsmtool.c index aaaf44e20..21a4533ea 100644 --- a/tools/hsmtool.c +++ b/tools/hsmtool.c @@ -45,7 +45,7 @@ static void show_usage(const char *progname) printf(" - checkhsm \n"); printf(" - dumponchaindescriptors [network]\n"); printf(" - makerune \n"); - printf(" - getcodexsecret \n"); + printf(" - getcodexsecret \n"); exit(0); } @@ -247,15 +247,14 @@ static int decrypt_hsm(const char *hsm_secret_path) } static int make_codexsecret(const char *hsm_secret_path, - const char *id, - const u32 threshold) + const char *id) { struct secret hsm_secret; char *bip93; const char *err; get_hsm_secret(&hsm_secret, hsm_secret_path); - err = codex32_secret_encode(tmpctx, id, threshold, hsm_secret.data, 32, &bip93); + err = codex32_secret_encode(tmpctx, id, 0, hsm_secret.data, 32, &bip93); if (err) errx(ERROR_USAGE, "%s", err); @@ -765,9 +764,9 @@ int main(int argc, char *argv[]) } if(streq(method, "getcodexsecret")) { - if (argc < 3) + if (argc < 2) show_usage(argv[0]); - return make_codexsecret(argv[2], argv[3], atol(argv[4])); + return make_codexsecret(argv[2], argv[3]); } show_usage(argv[0]); }