@@ -120,6 +120,7 @@ bool hsmd_check_client_capabilities(struct hsmd_client *client,
120120 case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY :
121121 case WIRE_HSMD_SIGN_BOLT12 :
122122 case WIRE_HSMD_PREAPPROVE_INVOICE :
123+ case WIRE_HSMD_PREAPPROVE_KEYSEND :
123124 case WIRE_HSMD_DERIVE_SECRET :
124125 return (client -> capabilities & HSM_CAP_MASTER ) != 0 ;
125126
@@ -151,6 +152,7 @@ bool hsmd_check_client_capabilities(struct hsmd_client *client,
151152 case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY :
152153 case WIRE_HSMD_SIGN_BOLT12_REPLY :
153154 case WIRE_HSMD_PREAPPROVE_INVOICE_REPLY :
155+ case WIRE_HSMD_PREAPPROVE_KEYSEND_REPLY :
154156 case WIRE_HSMD_DERIVE_SECRET_REPLY :
155157 break ;
156158 }
@@ -677,6 +679,24 @@ static u8 *handle_preapprove_invoice(struct hsmd_client *c, const u8 *msg_in)
677679 return towire_hsmd_preapprove_invoice_reply (NULL , approved );
678680}
679681
682+ /*~ lightningd asks us to approve a keysend payment. This stub implementation
683+ * is overriden by fully validating signers that need to track keysend
684+ * payments. */
685+ static u8 * handle_preapprove_keysend (struct hsmd_client * c , const u8 * msg_in )
686+ {
687+ struct node_id destination ;
688+ struct sha256 payment_hash ;
689+ struct amount_msat amount_msat ;
690+ bool approved ;
691+ if (!fromwire_hsmd_preapprove_keysend (msg_in , & destination , & payment_hash , & amount_msat ))
692+ return hsmd_status_malformed_request (c , msg_in );
693+
694+ /* This stub always approves */
695+ approved = true;
696+
697+ return towire_hsmd_preapprove_keysend_reply (NULL , approved );
698+ }
699+
680700/*~ Lightning invoices, defined by BOLT 11, are signed. This has been
681701 * surprisingly controversial; it means a node needs to be online to create
682702 * invoices. However, it seems clear to me that in a world without
@@ -1592,6 +1612,8 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
15921612 return handle_sign_bolt12 (client , msg );
15931613 case WIRE_HSMD_PREAPPROVE_INVOICE :
15941614 return handle_preapprove_invoice (client , msg );
1615+ case WIRE_HSMD_PREAPPROVE_KEYSEND :
1616+ return handle_preapprove_keysend (client , msg );
15951617 case WIRE_HSMD_SIGN_MESSAGE :
15961618 return handle_sign_message (client , msg );
15971619 case WIRE_HSMD_GET_CHANNEL_BASEPOINTS :
@@ -1656,6 +1678,7 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
16561678 case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY :
16571679 case WIRE_HSMD_SIGN_BOLT12_REPLY :
16581680 case WIRE_HSMD_PREAPPROVE_INVOICE_REPLY :
1681+ case WIRE_HSMD_PREAPPROVE_KEYSEND_REPLY :
16591682 break ;
16601683 }
16611684 return hsmd_status_bad_request (client , msg , "Unknown request" );
0 commit comments