Skip to content

Commit ef40b2f

Browse files
vincenzopalazzocdecker
authored andcommitted
hsmd: increase the min version
Increasing the min version of the hsmd due that we added new code that required the hsmd to sign an announcements. One of the solution is to increase the min version in this way a signer like VLS fails directly during the init phase. Link: #7074 Changelog-None: hsmd: increase the min version Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent b7b8e8d commit ef40b2f

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

common/hsm_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
* v5 with hsmd_revoke_commitment_tx: 5742538f87ef5d5bf55b66dc19e52c8683cfeb1b887d3e64ba530ba9a4d8e638
2424
* v5 with sign_any_cannouncement: 5fdb9068c43a21887dc03f7dce410d2e3eeff6277f0d49b4fc56595a798fd4a4
2525
*/
26-
#define HSM_MIN_VERSION 3
26+
#define HSM_MIN_VERSION 5
2727
#define HSM_MAX_VERSION 5
2828
#endif /* LIGHTNING_COMMON_HSM_VERSION_H */

hsmd/hsmd.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static struct io_plan *init_hsm(struct io_conn *conn,
436436
struct secret *hsm_encryption_key;
437437
struct bip32_key_version bip32_key_version;
438438
u32 minversion, maxversion;
439-
const u32 our_minversion = 2, our_maxversion = 3;
439+
const u32 our_minversion = 4, our_maxversion = 5;
440440

441441
/* This must be lightningd. */
442442
assert(is_lightningd(c));
@@ -489,7 +489,10 @@ static struct io_plan *init_hsm(struct io_conn *conn,
489489
if (hsm_encryption_key)
490490
discard_key(take(hsm_encryption_key));
491491

492-
return req_reply(conn, c, hsmd_init(hsm_secret, bip32_key_version));
492+
/* Define the minimum common max version for the hsmd one */
493+
u64 mutual_version = maxversion < our_maxversion ? maxversion : our_maxversion;
494+
return req_reply(conn, c, hsmd_init(hsm_secret, mutual_version,
495+
bip32_key_version));
493496
}
494497

495498
/*~ Since we process requests then service them in strict order, and because

hsmd/libhsmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,7 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
21512151
return hsmd_status_bad_request(client, msg, "Unknown request");
21522152
}
21532153

2154-
u8 *hsmd_init(struct secret hsm_secret,
2154+
u8 *hsmd_init(struct secret hsm_secret, const u64 hsmd_version,
21552155
struct bip32_key_version bip32_key_version)
21562156
{
21572157
u8 bip32_seed[BIP32_ENTROPY_LEN_256];
@@ -2297,7 +2297,7 @@ u8 *hsmd_init(struct secret hsm_secret,
22972297
* incompatibility detection) with alternate implementations.
22982298
*/
22992299
return take(towire_hsmd_init_reply_v4(
2300-
NULL, 4,
2300+
NULL, hsmd_version,
23012301
/* Capabilities arg needs to be a tal array */
23022302
tal_dup_arr(tmpctx, u32, capabilities,
23032303
ARRAY_SIZE(capabilities), 0),

hsmd/libhsmd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct hsmd_client {
4747
* Returns the `hsmd_init_reply` with the information required by
4848
* `lightningd`.
4949
*/
50-
u8 *hsmd_init(struct secret hsm_secret,
50+
u8 *hsmd_init(struct secret hsm_secret, const u64 hsmd_version,
5151
struct bip32_key_version bip32_key_version);
5252

5353
struct hsmd_client *hsmd_client_new_main(const tal_t *ctx, u64 capabilities,

0 commit comments

Comments
 (0)