@@ -119,6 +119,7 @@ bool hsmd_check_client_capabilities(struct hsmd_client *client,
119119 case WIRE_HSMD_SIGN_INVOICE :
120120 case WIRE_HSMD_SIGN_COMMITMENT_TX :
121121 case WIRE_HSMD_GET_CHANNEL_BASEPOINTS :
122+ case WIRE_HSMD_NEXT_FUNDING_PUBKEY :
122123 case WIRE_HSMD_DEV_MEMLEAK :
123124 case WIRE_HSMD_SIGN_MESSAGE :
124125 case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY :
@@ -158,6 +159,7 @@ bool hsmd_check_client_capabilities(struct hsmd_client *client,
158159 case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY :
159160 case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY :
160161 case WIRE_HSMD_GET_CHANNEL_BASEPOINTS_REPLY :
162+ case WIRE_HSMD_NEXT_FUNDING_PUBKEY_REPLY :
161163 case WIRE_HSMD_DEV_MEMLEAK_REPLY :
162164 case WIRE_HSMD_SIGN_MESSAGE_REPLY :
163165 case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY :
@@ -379,6 +381,27 @@ static u8 *handle_setup_channel(struct hsmd_client *c, const u8 *msg_in)
379381 return towire_hsmd_setup_channel_reply (NULL );
380382}
381383
384+ /* ~Return the funding pubkey for the next splice */
385+ static u8 * handle_next_funding_pubkey (struct hsmd_client * c , const u8 * msg_in )
386+ {
387+ struct node_id peer_id ;
388+ u64 dbid ;
389+ struct bitcoin_txid funding_txid ;
390+ u32 funding_txout ;
391+ struct secret seed ;
392+ struct pubkey funding_pubkey ;
393+
394+ if (!fromwire_hsmd_next_funding_pubkey (msg_in , & peer_id , & dbid ,
395+ & funding_txid , & funding_txout ))
396+ return hsmd_status_malformed_request (c , msg_in );
397+
398+ // TODO actually rotate the funding pubkey
399+ get_channel_seed (& peer_id , dbid , & seed );
400+ derive_basepoints (& seed , & funding_pubkey , NULL , NULL , NULL );
401+
402+ return towire_hsmd_setup_channel_reply (NULL );
403+ }
404+
382405/*~ For almost every wallet tx we use the BIP32 seed, but not for onchain
383406 * unilateral closes from a peer: they (may) have an output to us using a
384407 * public key based on the channel basepoints. It's a bit spammy to spend
@@ -1906,6 +1929,8 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
19061929 return handle_new_channel (client , msg );
19071930 case WIRE_HSMD_SETUP_CHANNEL :
19081931 return handle_setup_channel (client , msg );
1932+ case WIRE_HSMD_NEXT_FUNDING_PUBKEY :
1933+ return handle_next_funding_pubkey (client , msg );
19091934 case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY :
19101935 return handle_get_output_scriptpubkey (client , msg );
19111936 case WIRE_HSMD_CHECK_FUTURE_SECRET :
@@ -1983,6 +2008,7 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
19832008 case WIRE_HSMD_CLIENT_HSMFD_REPLY :
19842009 case WIRE_HSMD_NEW_CHANNEL_REPLY :
19852010 case WIRE_HSMD_SETUP_CHANNEL_REPLY :
2011+ case WIRE_HSMD_NEXT_FUNDING_PUBKEY_REPLY :
19862012 case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY :
19872013 case WIRE_HSMD_SIGN_WITHDRAWAL_REPLY :
19882014 case WIRE_HSMD_SIGN_INVOICE_REPLY :
0 commit comments