hsmd: remove unused "sign_local_htlc_tx" function which onchaind used to use.
What changed, and why it matters
This commit removes an old, unused function called sign_local_htlc_tx from the wallet's Hardware Security Module (HSM) interface. The function was previously used by the on-chain transaction handler (onchaind) but is no longer called anywhere. The change is a cleanup that also updates a comment about another function used by watchtowers. There is no security fix here.
No security action required. This is a routine dead-code removal and comment correction.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes the WIRE_HSMD_SIGN_LOCAL_HTLC_TX message type and its handler handle_sign_local_htlc_tx from hsmd. The underlying signing logic remains available through handle_sign_any_local_htlc_tx, which is used by lightningd. The HSM capability check no longer lists the removed wire type. A test stub for the removed message is also deleted. A comment for sign_penalty_to_us is corrected to note it is used by channeld for watchtower code, not deprecated onchaind code.
Changed components
hsmd/hsmd.chsmd/libhsmd.chsmd/hsmd_wire.csvcommon/hsm_version.honchaind/test/run-grind_feerate-bug.cInspect captured patch +4 / −38
diff --git a/common/hsm_version.h b/common/hsm_version.h
index 8b6c54bd..e894974c 100644
--- a/common/hsm_version.h
+++ b/common/hsm_version.h
@@ -33,6 +33,7 @@
* v6 with hsm_secret struct cleanup: 06c56396fe42f4f47911d7f865dd0004d264fc1348f89547743755b6b33fec90
* v6 with hsm_secret_type TLV: 7bb5deb2367482feb084d304ee14b2373d42910ad56484fbf47614dbb3d4cb74
* v6 with bip86_base in TLV: 6bb6e6ee256f22a6fb41856c90feebde3065a9074e79a46731e453a932be83f0
+ * v6 with hsmd_sign_local_htlc_tx removed: 0e28ca3699196cf9d26d38f8f621d1bf68c76cf5e2cdc1f4157a6937b02dc2f6
*/
#define HSM_MIN_VERSION 5
#define HSM_MAX_VERSION 6
diff --git a/hsmd/hsmd.c b/hsmd/hsmd.c
index dfe61fc1..739a148b 100644
--- a/hsmd/hsmd.c
+++ b/hsmd/hsmd.c
@@ -794,7 +794,6 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
case WIRE_HSMD_SIGN_ANY_CANNOUNCEMENT_REQ:
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REQ:
case WIRE_HSMD_CUPDATE_SIG_REQ:
- case WIRE_HSMD_SIGN_LOCAL_HTLC_TX:
case WIRE_HSMD_SIGN_REMOTE_HTLC_TO_US:
case WIRE_HSMD_SIGN_DELAYED_PAYMENT_TO_US:
case WIRE_HSMD_CHECK_PUBKEY:
diff --git a/hsmd/hsmd_wire.csv b/hsmd/hsmd_wire.csv
index 7336feef..d3ee517b 100644
--- a/hsmd/hsmd_wire.csv
+++ b/hsmd/hsmd_wire.csv
@@ -299,20 +299,13 @@ msgdata,hsmd_sign_remote_htlc_to_us,wscript_len,u16,
msgdata,hsmd_sign_remote_htlc_to_us,wscript,u8,wscript_len
msgdata,hsmd_sign_remote_htlc_to_us,option_anchor_outputs,bool,
+# channeld asks HSM to sign penalty, for watchtower code.
msgtype,hsmd_sign_penalty_to_us,14
msgdata,hsmd_sign_penalty_to_us,revocation_secret,secret,
msgdata,hsmd_sign_penalty_to_us,tx,bitcoin_tx,
msgdata,hsmd_sign_penalty_to_us,wscript_len,u16,
msgdata,hsmd_sign_penalty_to_us,wscript,u8,wscript_len
-# Onchaind asks HSM to sign a local HTLC success or HTLC timeout tx.
-msgtype,hsmd_sign_local_htlc_tx,16
-msgdata,hsmd_sign_local_htlc_tx,commit_num,u64,
-msgdata,hsmd_sign_local_htlc_tx,tx,bitcoin_tx,
-msgdata,hsmd_sign_local_htlc_tx,wscript_len,u16,
-msgdata,hsmd_sign_local_htlc_tx,wscript,u8,wscript_len
-msgdata,hsmd_sign_local_htlc_tx,option_anchor_outputs,bool,
-
# Openingd/channeld asks HSM to sign the other sides' commitment tx.
msgtype,hsmd_sign_remote_commitment_tx,19
msgdata,hsmd_sign_remote_commitment_tx,tx,bitcoin_tx,
diff --git a/hsmd/libhsmd.c b/hsmd/libhsmd.c
index c98f13c5..f8d35a04 100644
--- a/hsmd/libhsmd.c
+++ b/hsmd/libhsmd.c
@@ -110,7 +110,6 @@ bool hsmd_check_client_capabilities(struct hsmd_client *client,
case WIRE_HSMD_SIGN_DELAYED_PAYMENT_TO_US:
case WIRE_HSMD_SIGN_REMOTE_HTLC_TO_US:
case WIRE_HSMD_SIGN_PENALTY_TO_US:
- case WIRE_HSMD_SIGN_LOCAL_HTLC_TX:
return (client->capabilities & HSM_PERM_SIGN_ONCHAIN_TX) != 0;
case WIRE_HSMD_GET_PER_COMMITMENT_POINT:
@@ -1559,25 +1558,7 @@ static u8 *do_sign_local_htlc_tx(struct hsmd_client *c,
return towire_hsmd_sign_tx_reply(NULL, &sig);
}
-/*~ Called from onchaind (deprecated) */
-static u8 *handle_sign_local_htlc_tx(struct hsmd_client *c, const u8 *msg_in)
-{
- u64 commit_num;
- struct bitcoin_tx *tx;
- u8 *wscript;
- bool option_anchor_outputs;
-
- if (!fromwire_hsmd_sign_local_htlc_tx(tmpctx, msg_in,
- &commit_num, &tx, &wscript,
- &option_anchor_outputs))
- return hsmd_status_malformed_request(c, msg_in);
-
- return do_sign_local_htlc_tx(c, msg_in, 0, &c->id, c->dbid,
- commit_num, tx, wscript,
- option_anchor_outputs);
-}
-
-/*~ This is the same function, but lightningd calling it */
+/*~ lightningd asks us to sign our HTLC transaction. */
static u8 *handle_sign_any_local_htlc_tx(struct hsmd_client *c, const u8 *msg_in)
{
u64 commit_num;
@@ -1752,7 +1733,7 @@ static u8 *do_sign_penalty_to_us(struct hsmd_client *c,
SIGHASH_ALL);
}
-/*~ Called from onchaind (deprecated) */
+/*~ Called from channeld: used by watchtower code. */
static u8 *handle_sign_penalty_to_us(struct hsmd_client *c, const u8 *msg_in)
{
struct secret revocation_secret;
@@ -2287,8 +2268,6 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
return handle_sign_mutual_close_tx(client, msg);
case WIRE_HSMD_SIGN_SPLICE_TX:
return handle_sign_splice_tx(client, msg);
- case WIRE_HSMD_SIGN_LOCAL_HTLC_TX:
- return handle_sign_local_htlc_tx(client, msg);
case WIRE_HSMD_SIGN_REMOTE_HTLC_TX:
return handle_sign_remote_htlc_tx(client, msg);
case WIRE_HSMD_SIGN_REMOTE_COMMITMENT_TX:
diff --git a/onchaind/test/run-grind_feerate-bug.c b/onchaind/test/run-grind_feerate-bug.c
index e57aca2a..a77627bc 100644
--- a/onchaind/test/run-grind_feerate-bug.c
+++ b/onchaind/test/run-grind_feerate-bug.c
@@ -222,12 +222,6 @@ void towire_wallet_tx_type(u8 **pptr UNNEEDED, const enum wallet_tx_type type UN
{ fprintf(stderr, "towire_wallet_tx_type called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
-/* Stubs which do get called. */
-u8 *towire_hsmd_sign_local_htlc_tx(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
-{
- return NULL;
-}
-
u8 *wire_sync_read(const tal_t *ctx, int fd UNNEEDED)
{
return towire_onchaind_spend_created(ctx, true, NULL);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.