Skip to content

Commit b45d110

Browse files
committed
Amended the GetExtPubKey interface, removed derivation_path.
1 parent 36cff25 commit b45d110

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

contrib/remote_hsmd/hsmd.c

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static struct {
7171
* so set it static.*/
7272
static struct bip32_key_version bip32_key_version;
7373

74+
/* These are no longer used, but handle_memleak seems to need them. */
7475
#if DEVELOPER
7576
/* If they specify --dev-force-privkey it ends up in here. */
7677
static struct privkey *dev_force_privkey;
@@ -353,11 +354,12 @@ static struct io_plan *init_hsm(struct io_conn *conn,
353354
const u8 *msg_in)
354355
{
355356
struct node_id node_id;
356-
struct privkey *privkey;
357-
struct secret *seed;
358-
struct secrets *secrets;
359-
struct sha256 *shaseed;
357+
struct privkey *force_privkey;
358+
struct secret *force_bip32_seed;
359+
struct secrets *force_channel_secrets;
360+
struct sha256 *force_channel_secrets_shaseed;
360361
struct secret *hsm_encryption_key;
362+
struct secret hsm_secret;
361363

362364
/* This must be lightningd. */
363365
assert(is_lightningd(c));
@@ -367,36 +369,42 @@ static struct io_plan *init_hsm(struct io_conn *conn,
367369
* an extension of the simple comma-separated format output by the
368370
* BOLT tools/extract-formats.py tool. */
369371
if (!fromwire_hsm_init(NULL, msg_in, &bip32_key_version, &chainparams,
370-
&hsm_encryption_key, &privkey, &seed, &secrets, &shaseed))
372+
&hsm_encryption_key, &force_privkey,
373+
&force_bip32_seed, &force_channel_secrets,
374+
&force_channel_secrets_shaseed))
371375
return bad_req(conn, c, msg_in);
372376

373377
#if DEVELOPER
374-
dev_force_privkey = privkey;
375-
dev_force_bip32_seed = seed;
376-
dev_force_channel_secrets = secrets;
377-
dev_force_channel_secrets_shaseed = shaseed;
378+
dev_force_privkey = force_privkey;
379+
dev_force_bip32_seed = force_bip32_seed;
380+
dev_force_channel_secrets = force_channel_secrets;
381+
dev_force_channel_secrets_shaseed = force_channel_secrets_shaseed;
378382
#endif
379383

384+
// We can't force any of these secrets individually, we only
385+
// can set the seed (for testnet integration tests). If we
386+
// see anything being set fail fast.
387+
assert(force_privkey == NULL);
388+
assert(force_bip32_seed == NULL);
389+
assert(force_channel_secrets == NULL);
390+
assert(force_channel_secrets_shaseed == NULL);
391+
392+
/* The hsm_encryption_key doesn't make any sense with the
393+
* remote signer, fail-fast if it's set.
394+
*/
395+
assert(hsm_encryption_key == NULL);
396+
380397
/* Once we have read the init message we know which params the master
381398
* will use */
382399
c->chainparams = chainparams;
383400

384-
/* Fail fast if these are set. */
385-
assert(hsm_encryption_key == NULL);
386-
assert(privkey == NULL);
387-
assert(seed == NULL);
388-
assert(secrets == NULL);
389-
assert(shaseed == NULL);
390-
391-
/* The c-lightning testing framework imbues the hsm_secret
392-
* with a file created before hsmd starts. To allow running
393-
* the c-lightning test suite we use the secret from the
394-
* testing framework rather than generating in the remote
395-
* signer for now. The seed is NOT otherwise retained.
401+
/* To support integration tests we honor any seed provided
402+
* in the hsm_secret file (testnet only). Otherwise we
403+
* generate a random seed.
396404
*/
397-
struct secret hsm_secret;
398-
if (!read_test_seed(&hsm_secret))
405+
if (!read_test_seed(&hsm_secret)) {
399406
randombytes_buf(&hsm_secret, sizeof(hsm_secret));
407+
}
400408

401409
proxy_stat rv = proxy_init_hsm(&bip32_key_version, chainparams,
402410
&hsm_secret, &node_id,

contrib/remote_hsmd/proxy.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ proxy_stat proxy_init_hsm(struct bip32_key_version *bip32_key_version,
348348
GetExtPubKeyRequest req;
349349

350350
marshal_node_id(&self_id, req.mutable_node_id());
351-
req.set_derivation_path("m");
352351

353352
ClientContext context;
354353
GetExtPubKeyReply rsp;

tests/test_misc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,7 @@ def mock_fail(*args):
17191719

17201720
@unittest.skipIf(not DEVELOPER, "needs --dev-force-bip32-seed")
17211721
@unittest.skipIf(TEST_NETWORK != 'regtest', "Addresses are network specific")
1722+
@unittest.skipIf(os.getenv('SUBDAEMON', 'xxx') == 'hsmd:remote_hsmd', "remote_hsmd doesn't support forced secrets")
17221723
def test_dev_force_bip32_seed(node_factory):
17231724
l1 = node_factory.get_node(options={'dev-force-bip32-seed': '0000000000000000000000000000000000000000000000000000000000000001'})
17241725
# First is m/0/0/1 ..

0 commit comments

Comments
 (0)