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

Function handle_client

hsmd/hsmd.c:743–874  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

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
io_closeFunction · 0.85

Tested by

no test coverage detected