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

Function handle_client

hsmd/hsmd.c:758–891  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

fromwire_peektypeFunction · 0.85
is_lightningdFunction · 0.85
tal_freeFunction · 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

Tested by

no test coverage detected