@@ -71,6 +71,7 @@ static struct {
7171 * so set it static.*/
7272static 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. */
7677static 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 ,
0 commit comments