Skip to content

Commit 9ebc2f5

Browse files
committed
splice: Add hsmd_sync_outpoint
1 parent 098819f commit 9ebc2f5

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

hsmd/hsmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
654654

655655
case WIRE_HSMD_NEW_CHANNEL:
656656
case WIRE_HSMD_SETUP_CHANNEL:
657+
case WIRE_HSMD_SYNC_OUTPOINT:
657658
case WIRE_HSMD_SIGN_COMMITMENT_TX:
658659
case WIRE_HSMD_VALIDATE_COMMITMENT_TX:
659660
case WIRE_HSMD_VALIDATE_REVOCATION:
@@ -699,6 +700,7 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
699700
case WIRE_HSMD_CLIENT_HSMFD_REPLY:
700701
case WIRE_HSMD_NEW_CHANNEL_REPLY:
701702
case WIRE_HSMD_SETUP_CHANNEL_REPLY:
703+
case WIRE_HSMD_SYNC_OUTPOINT_REPLY:
702704
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY:
703705
case WIRE_HSMD_SIGN_WITHDRAWAL_REPLY:
704706
case WIRE_HSMD_SIGN_INVOICE_REPLY:

hsmd/hsmd_wire.csv

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ msgdata,hsmd_setup_channel,channel_type,channel_type,
8989
# No value returned.
9090
msgtype,hsmd_setup_channel_reply,131
9191

92+
# Sent when channel_ready or splice_locked are mutual.
93+
# Ensures that hsmd sees outpoint buried.
94+
msgtype,hsmd_sync_outpoint,32
95+
msgdata,hsmd_sync_outpoint,funding_outpoint,bitcoin_outpoint,
96+
97+
# No value returned
98+
msgtype,hsmd_sync_outpoint_reply,132
99+
92100
# Return signature for a funding tx.
93101
#include <common/utxo.h>
94102

hsmd/libhsmd.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ bool hsmd_check_client_capabilities(struct hsmd_client *client,
112112
case WIRE_HSMD_SIGN_OPTION_WILL_FUND_OFFER:
113113
return (client->capabilities & HSM_PERM_SIGN_WILL_FUND_OFFER) != 0;
114114

115+
case WIRE_HSMD_SYNC_OUTPOINT:
116+
return (client->capabilities & HSM_PERM_SYNC_OUTPOINT) != 0;
117+
115118
case WIRE_HSMD_INIT:
116119
case WIRE_HSMD_NEW_CHANNEL:
117120
case WIRE_HSMD_CLIENT_HSMFD:
@@ -144,6 +147,7 @@ bool hsmd_check_client_capabilities(struct hsmd_client *client,
144147
case WIRE_HSMD_CLIENT_HSMFD_REPLY:
145148
case WIRE_HSMD_NEW_CHANNEL_REPLY:
146149
case WIRE_HSMD_SETUP_CHANNEL_REPLY:
150+
case WIRE_HSMD_SYNC_OUTPOINT_REPLY:
147151
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY:
148152
case WIRE_HSMD_SIGN_WITHDRAWAL_REPLY:
149153
case WIRE_HSMD_SIGN_INVOICE_REPLY:
@@ -379,6 +383,20 @@ static u8 *handle_setup_channel(struct hsmd_client *c, const u8 *msg_in)
379383
return towire_hsmd_setup_channel_reply(NULL);
380384
}
381385

386+
/* ~This stub implementation is overriden by fully validating signers
387+
* to ensure they are caught up when outpoints are freshly buried */
388+
static u8 *handle_sync_outpoint(struct hsmd_client *c, const u8 *msg_in)
389+
{
390+
struct bitcoin_outpoint outpoint;
391+
392+
if (!fromwire_hsmd_sync_outpoint(msg_in, &outpoint))
393+
return hsmd_status_malformed_request(c, msg_in);
394+
395+
/* Stub implementation */
396+
397+
return towire_hsmd_setup_channel_reply(NULL);
398+
}
399+
382400
/*~ For almost every wallet tx we use the BIP32 seed, but not for onchain
383401
* unilateral closes from a peer: they (may) have an output to us using a
384402
* public key based on the channel basepoints. It's a bit spammy to spend
@@ -1906,6 +1924,8 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
19061924
return handle_new_channel(client, msg);
19071925
case WIRE_HSMD_SETUP_CHANNEL:
19081926
return handle_setup_channel(client, msg);
1927+
case WIRE_HSMD_SYNC_OUTPOINT:
1928+
return handle_sync_outpoint(client, msg);
19091929
case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY:
19101930
return handle_get_output_scriptpubkey(client, msg);
19111931
case WIRE_HSMD_CHECK_FUTURE_SECRET:
@@ -1983,6 +2003,7 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
19832003
case WIRE_HSMD_CLIENT_HSMFD_REPLY:
19842004
case WIRE_HSMD_NEW_CHANNEL_REPLY:
19852005
case WIRE_HSMD_SETUP_CHANNEL_REPLY:
2006+
case WIRE_HSMD_SYNC_OUTPOINT_REPLY:
19862007
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY:
19872008
case WIRE_HSMD_SIGN_WITHDRAWAL_REPLY:
19882009
case WIRE_HSMD_SIGN_INVOICE_REPLY:

hsmd/permissions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define HSM_PERM_SIGN_CLOSING_TX 32
1111
#define HSM_PERM_SIGN_WILL_FUND_OFFER 64
1212
#define HSM_PERM_SIGN_SPLICE_TX 128
13+
#define HSM_PERM_SYNC_OUTPOINT 256
1314

1415
#define HSM_PERM_MASTER 1024
1516
#endif /* LIGHTNING_HSMD_PERMISSIONS_H */

0 commit comments

Comments
 (0)