@@ -848,6 +848,34 @@ static struct io_plan *handle_validate_commitment_tx(struct io_conn *conn,
848848 NULL , old_secret , & next_per_commitment_point )));
849849}
850850
851+ /* Validate the peer's signatures for our commitment and htlc txs. */
852+ static struct io_plan * handle_validate_revocation (struct io_conn * conn ,
853+ struct client * c ,
854+ const u8 * msg_in )
855+ {
856+ u64 revoke_num ;
857+ struct secret old_secret ;
858+
859+ if (!fromwire_hsmd_validate_revocation (msg_in ,
860+ & revoke_num , & old_secret ))
861+ bad_req (conn , c , msg_in );
862+
863+ proxy_stat rv = proxy_handle_validate_revocation (
864+ & c -> id , c -> dbid ,
865+ revoke_num , & old_secret );
866+ if (PROXY_PERMANENT (rv ))
867+ status_failed (STATUS_FAIL_INTERNAL_ERROR ,
868+ "proxy_%s failed: %s" , __FUNCTION__ ,
869+ proxy_last_message ());
870+ else if (!PROXY_SUCCESS (rv ))
871+ return bad_req_fmt (conn , c , msg_in ,
872+ "proxy_%s error: %s" , __FUNCTION__ ,
873+ proxy_last_message ());
874+
875+ return req_reply (conn , c ,
876+ take (towire_hsmd_validate_revocation_reply (NULL )));
877+ }
878+
851879/*~ This is used by channeld to create signatures for the remote peer's
852880 * commitment transaction. It's functionally identical to signing our own,
853881 * but we expect to do this repeatedly as commitment transactions are
@@ -1636,6 +1664,7 @@ static bool check_client_capabilities(struct client *client,
16361664 case WIRE_HSMD_SIGN_REMOTE_COMMITMENT_TX :
16371665 case WIRE_HSMD_SIGN_REMOTE_HTLC_TX :
16381666 case WIRE_HSMD_VALIDATE_COMMITMENT_TX :
1667+ case WIRE_HSMD_VALIDATE_REVOCATION :
16391668 return (client -> capabilities & HSM_CAP_SIGN_REMOTE_TX ) != 0 ;
16401669
16411670 case WIRE_HSMD_SIGN_MUTUAL_CLOSE_TX :
@@ -1670,6 +1699,7 @@ static bool check_client_capabilities(struct client *client,
16701699 case WIRE_HSMSTATUS_CLIENT_BAD_REQUEST :
16711700 case WIRE_HSMD_SIGN_COMMITMENT_TX_REPLY :
16721701 case WIRE_HSMD_VALIDATE_COMMITMENT_TX_REPLY :
1702+ case WIRE_HSMD_VALIDATE_REVOCATION_REPLY :
16731703 case WIRE_HSMD_SIGN_TX_REPLY :
16741704 case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY :
16751705 case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY :
@@ -1749,6 +1779,9 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
17491779 case WIRE_HSMD_VALIDATE_COMMITMENT_TX :
17501780 return handle_validate_commitment_tx (conn , c , c -> msg_in );
17511781
1782+ case WIRE_HSMD_VALIDATE_REVOCATION :
1783+ return handle_validate_revocation (conn , c , c -> msg_in );
1784+
17521785 case WIRE_HSMD_SIGN_DELAYED_PAYMENT_TO_US :
17531786 return handle_sign_delayed_payment_to_us (conn , c , c -> msg_in );
17541787
@@ -1800,6 +1833,7 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
18001833 case WIRE_HSMSTATUS_CLIENT_BAD_REQUEST :
18011834 case WIRE_HSMD_SIGN_COMMITMENT_TX_REPLY :
18021835 case WIRE_HSMD_VALIDATE_COMMITMENT_TX_REPLY :
1836+ case WIRE_HSMD_VALIDATE_REVOCATION_REPLY :
18031837 case WIRE_HSMD_SIGN_TX_REPLY :
18041838 case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY :
18051839 case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY :
0 commit comments