diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 686f36bbf..4861d9149 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -50,7 +50,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx) #if DEVELOPER ld->dev_debug_subdaemon = NULL; ld->dev_disconnect_fd = -1; - ld->dev_hsm_seed = NULL; ld->dev_subdaemon_fail = false; ld->no_reconnect = false; diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 0287a612a..b17c50df7 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -171,9 +171,6 @@ struct lightningd { /* If we want to debug a subdaemon. */ const char *dev_debug_subdaemon; - /* If we want to set a specific non-random HSM seed. */ - const u8 *dev_hsm_seed; - /* If we have a --dev-disconnect file */ int dev_disconnect_fd; diff --git a/lightningd/options.c b/lightningd/options.c index fd2db18e8..2b6cc09b5 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -344,17 +344,6 @@ static void config_register_opts(struct lightningd *ld) } #if DEVELOPER -static char *opt_set_hsm_seed(const char *arg, struct lightningd *ld) -{ - assert(arg != NULL); - - ld->dev_hsm_seed = tal_hexdata(ld, arg, strlen(arg)); - if (ld->dev_hsm_seed) - return NULL; - - return tal_fmt(NULL, "bad hex string '%s'", arg); -} - static void dev_register_opts(struct lightningd *ld) { opt_register_noarg("--dev-no-reconnect", opt_set_bool, @@ -369,8 +358,6 @@ static void dev_register_opts(struct lightningd *ld) "Time between gossip broadcasts in milliseconds"); opt_register_arg("--dev-disconnect=", opt_subd_dev_disconnect, NULL, ld, "File containing disconnection points"); - opt_register_arg("--dev-hsm-seed=", opt_set_hsm_seed, - NULL, ld, "Hex-encoded seed for HSM"); } #endif @@ -771,20 +758,6 @@ void handle_opts(struct lightningd *ld, int argc, char *argv[]) else log_debug(ld->log, "Not guessing addresses: %s", ld->portnum ? "manually set" : "port set to zero"); - -#if DEVELOPER - if (ld->dev_hsm_seed) { - int fd; - unlink("hsm_secret"); - fd = open("hsm_secret", O_CREAT|O_WRONLY, 0400); - if (fd < 0 || - !write_all(fd, ld->dev_hsm_seed, tal_len(ld->dev_hsm_seed)) - || fsync(fd) != 0) - fatal("dev-hsm-seed: Could not write file: %s", - strerror(errno)); - close(fd); - } -#endif } /* FIXME: This is a hack! Expose somehow in ccan/opt.*/ diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index aecca39d6..423563106 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -454,6 +454,17 @@ class LightningDTests(BaseLightningDTests): l2.rpc.invoice, 123456, 'inv2', '?', None, None, invoice_preimage) + def test_names(self): + for key, alias, color in [('0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'JUNIORBEAM', '0266e4'), + ('022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'SILENTARTIST', '022d22'), + ('035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d', 'HOPPINGFIRE', '035d2b'), + ('0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199', 'JUNIORFELONY', '0382ce'), + ('032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e', 'SOMBERFIRE', '032cf1'), + ('0265b6ab5ec860cd257865d61ef0bbf5b3339c36cbda8b26b74e7f1dca490b6518', 'LOUDPHOTO', '0265b6')]: + n = self.node_factory.get_node() + assert n.daemon.is_in_log('public key {}, alias {}.* \(color #{}\)' + .format(key, alias, color)) + def test_invoice(self): l1 = self.node_factory.get_node() l2 = self.node_factory.get_node() diff --git a/tests/utils.py b/tests/utils.py index 88ffb5eeb..4a4bf96d8 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,4 +1,3 @@ -import binascii import logging import os import re @@ -233,12 +232,6 @@ class BitcoinD(TailableProc): # As of 0.16, generate() is removed; use generatetoaddress. self.rpc.generatetoaddress(numblocks, self.rpc.getnewaddress()) -# lightning-1 => 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518 aka JUNIORBEAM #0266e4 -# lightning-2 => 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59 aka SILENTARTIST #022d22 -# lightning-3 => 035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d aka HOPPINGFIRE #035d2b -# lightning-4 => 0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199 aka JUNIORFELONY #0382ce -# lightning-5 => 032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e aka SOMBERFIRE #032cf1 - class LightningD(TailableProc): def __init__(self, lightning_dir, bitcoin_dir, port=9735, random_hsm=False): @@ -261,17 +254,18 @@ class LightningD(TailableProc): for k, v in opts.items(): self.opts[k] = v + if not os.path.exists(lightning_dir): + os.makedirs(lightning_dir) + # Last 32-bytes of final part of dir -> seed. seed = (bytes(re.search('([^/]+)/*$', lightning_dir).group(1), encoding='utf-8') + bytes(32))[:32] + if not random_hsm: + with open(os.path.join(lightning_dir, 'hsm_secret'), 'wb') as f: + f.write(seed) if DEVELOPER: self.opts['dev-broadcast-interval'] = 1000 - if not random_hsm: - self.opts['dev-hsm-seed'] = binascii.hexlify(seed).decode('ascii') self.prefix = 'lightningd(%d)' % (port) - if not os.path.exists(lightning_dir): - os.makedirs(lightning_dir) - @property def cmd_line(self):