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

Function handle_client

hsmd/hsmd.c:614–705  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

612
613/*~ This is the core of the HSM daemon: handling requests. */
614static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
615{
616 enum hsmd_wire t = fromwire_peektype(c->msg_in);
617
618 if (!is_lightningd(c))
619 status_peer_debug(&c->id, "Got %s", hsmd_wire_name(t));
620
621 /* Before we do anything else, is this client allowed to do
622 * what he asks for? */
623 if (!hsmd_check_client_capabilities(c->hsmd_client, t))
624 return bad_req_fmt(conn, c, c->msg_in,
625 "client does not have capability to run %d",
626 t);
627
628 /* Now actually go and do what the client asked for */
629 switch (t) {
630 case WIRE_HSMD_INIT:
631 return init_hsm(conn, c, c->msg_in);
632
633 case WIRE_HSMD_CLIENT_HSMFD:
634 return pass_client_hsmfd(conn, c, c->msg_in);
635
636#if DEVELOPER
637 case WIRE_HSMD_DEV_MEMLEAK:
638 return handle_memleak(conn, c, c->msg_in);
639#else
640 case WIRE_HSMD_DEV_MEMLEAK:
641#endif /* DEVELOPER */
642
643 case WIRE_HSMD_NEW_CHANNEL:
644 case WIRE_HSMD_READY_CHANNEL:
645 case WIRE_HSMD_SIGN_COMMITMENT_TX:
646 case WIRE_HSMD_VALIDATE_COMMITMENT_TX:
647 case WIRE_HSMD_VALIDATE_REVOCATION:
648 case WIRE_HSMD_SIGN_PENALTY_TO_US:
649 case WIRE_HSMD_SIGN_REMOTE_COMMITMENT_TX:
650 case WIRE_HSMD_SIGN_REMOTE_HTLC_TX:
651 case WIRE_HSMD_SIGN_MUTUAL_CLOSE_TX:
652 case WIRE_HSMD_GET_PER_COMMITMENT_POINT:
653 case WIRE_HSMD_SIGN_WITHDRAWAL:
654 case WIRE_HSMD_GET_CHANNEL_BASEPOINTS:
655 case WIRE_HSMD_SIGN_INVOICE:
656 case WIRE_HSMD_SIGN_MESSAGE:
657 case WIRE_HSMD_SIGN_OPTION_WILL_FUND_OFFER:
658 case WIRE_HSMD_SIGN_BOLT12:
659 case WIRE_HSMD_ECDH_REQ:
660 case WIRE_HSMD_CHECK_FUTURE_SECRET:
661 case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY:
662 case WIRE_HSMD_DERIVE_SECRET:
663 case WIRE_HSMD_CANNOUNCEMENT_SIG_REQ:
664 case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REQ:
665 case WIRE_HSMD_CUPDATE_SIG_REQ:
666 case WIRE_HSMD_SIGN_LOCAL_HTLC_TX:
667 case WIRE_HSMD_SIGN_REMOTE_HTLC_TO_US:
668 case WIRE_HSMD_SIGN_DELAYED_PAYMENT_TO_US:
669 /* Hand off to libhsmd for processing */
670 return req_reply(conn, c,
671 take(hsmd_handle_client_message(

Callers

nothing calls this directly

Calls 9

is_lightningdFunction · 0.85
bad_req_fmtFunction · 0.85
init_hsmFunction · 0.85
pass_client_hsmfdFunction · 0.85
handle_memleakFunction · 0.85
req_replyFunction · 0.85
fromwire_peektypeFunction · 0.50

Tested by

no test coverage detected