Browse Source

hsmtool: only write 32 bytes to hsm_secret on generatehsm

Fixes #4302
Changelog-fixed: hsmtool: the `generatehsm` command now generates an appropriately-sized hsm_secret
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
ppa
Antoine Poinsot 4 years ago
committed by Christian Decker
parent
commit
19afe15968
  1. 1
      tests/test_wallet.py
  2. 4
      tools/hsmtool.c

1
tests/test_wallet.py

@ -1097,7 +1097,6 @@ def test_hsmtool_dump_descriptors(node_factory, bitcoind):
assert len(bitcoind.rpc.listunspent(1, 1, [addr])) == 1
@pytest.mark.xfail(strict=True)
@unittest.skipIf(VALGRIND, "It does not play well with prompt and key derivation.")
def test_hsmtool_generatehsm(node_factory):
l1 = node_factory.get_node()

4
tools/hsmtool.c

@ -532,7 +532,9 @@ static int generate_hsm(const char *hsm_secret_path)
if (fd < 0) {
errx(ERROR_USAGE, "Unable to create hsm_secret file");
}
if (!write_all(fd, bip32_seed, bip32_seed_len))
/* Write only the first 32 bytes, length of the (plaintext) seed in the
* hsm_secret. */
if (!write_all(fd, bip32_seed, 32))
errx(ERROR_USAGE, "Error writing secret to hsm_secret file");
if (fsync(fd) != 0)

Loading…
Cancel
Save