MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_client

Function handle_client

hsmd/hsmd.c:729–858  ·  view source on GitHub ↗

~ This is the core of the HSM daemon: handling requests. */

Source from the content-addressed store, hash-verified

727
728/*~ This is the core of the HSM daemon: handling requests. */
729static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
730{
731 enum hsmd_wire t = fromwire_peektype(c->msg_in);
732
733 if (!is_lightningd(c))
734 status_peer_debug(&c->id, "Got %s", hsmd_wire_name(t));
735
736 /* Before we do anything else, is this client allowed to do
737 * what he asks for? */
738 if (!hsmd_check_client_capabilities(c->hsmd_client, t))
739 return bad_req_fmt(conn, c, c->msg_in,
740 "client does not have capability to run %d",
741 t);
742
743 /* Now actually go and do what the client asked for */
744 switch (t) {
745 case WIRE_HSMD_DEV_PREINIT:
746 return preinit_hsm(conn, c, c->msg_in);
747
748 case WIRE_HSMD_INIT:
749 return init_hsm(conn, c, c->msg_in);
750
751 case WIRE_HSMD_CLIENT_HSMFD:
752 return pass_client_hsmfd(conn, c, c->msg_in);
753
754 case WIRE_HSMD_CHECK_BIP86_PUBKEY:
755 return handle_check_bip86_pubkey(conn, c, c->msg_in);
756
757 case WIRE_HSMD_DEV_MEMLEAK:
758 if (!developer)
759 break;
760 return handle_memleak(conn, c, c->msg_in);
761
762 case WIRE_HSMD_NEW_CHANNEL:
763 case WIRE_HSMD_SETUP_CHANNEL:
764 case WIRE_HSMD_CHECK_OUTPOINT:
765 case WIRE_HSMD_LOCK_OUTPOINT:
766 case WIRE_HSMD_FORGET_CHANNEL:
767 case WIRE_HSMD_SIGN_COMMITMENT_TX:
768 case WIRE_HSMD_VALIDATE_COMMITMENT_TX:
769 case WIRE_HSMD_REVOKE_COMMITMENT_TX:
770 case WIRE_HSMD_VALIDATE_REVOCATION:
771 case WIRE_HSMD_SIGN_PENALTY_TO_US:
772 case WIRE_HSMD_SIGN_REMOTE_COMMITMENT_TX:
773 case WIRE_HSMD_SIGN_REMOTE_HTLC_TX:
774 case WIRE_HSMD_SIGN_MUTUAL_CLOSE_TX:
775 case WIRE_HSMD_SIGN_SPLICE_TX:
776 case WIRE_HSMD_GET_PER_COMMITMENT_POINT:
777 case WIRE_HSMD_SIGN_WITHDRAWAL:
778 case WIRE_HSMD_GET_CHANNEL_BASEPOINTS:
779 case WIRE_HSMD_SIGN_INVOICE:
780 case WIRE_HSMD_SIGN_MESSAGE:
781 case WIRE_HSMD_BIP137_SIGN_MESSAGE:
782 case WIRE_HSMD_SIGN_OPTION_WILL_FUND_OFFER:
783 case WIRE_HSMD_SIGN_BOLT12:
784 case WIRE_HSMD_SIGN_BOLT12_2:
785 case WIRE_HSMD_PREAPPROVE_INVOICE:
786 case WIRE_HSMD_PREAPPROVE_KEYSEND:

Callers

nothing calls this directly

Calls 12

fromwire_peektypeFunction · 0.85
is_lightningdFunction · 0.85
hsmd_wire_nameFunction · 0.85
bad_req_fmtFunction · 0.85
preinit_hsmFunction · 0.85
init_hsmFunction · 0.85
pass_client_hsmfdFunction · 0.85
handle_memleakFunction · 0.85
req_replyFunction · 0.85

Tested by

no test coverage detected