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

Function pass_client_hsmfd

hsmd/hsmd.c:601–629  ·  view source on GitHub ↗

~ This is used by the master to create a new client connection (which * becomes the HSM_FD for the subdaemon after forking). */

Source from the content-addressed store, hash-verified

599/*~ This is used by the master to create a new client connection (which
600 * becomes the HSM_FD for the subdaemon after forking). */
601static struct io_plan *pass_client_hsmfd(struct io_conn *conn,
602 struct client *c,
603 const u8 *msg_in)
604{
605 int fds[2];
606 u64 dbid, capabilities;
607 struct node_id id;
608
609 /* This must be lightningd itself. */
610 assert(is_lightningd(c));
611
612 if (!fromwire_hsmd_client_hsmfd(msg_in, &id, &dbid, &capabilities))
613 return bad_req(conn, c, msg_in);
614
615 /* socketpair is a bi-directional pipe, which is what we want. */
616 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) != 0)
617 status_failed(STATUS_FAIL_INTERNAL_ERROR, "creating fds: %s",
618 strerror(errno));
619
620 status_debug("new_client: %"PRIu64, dbid);
621 new_client(c, c->chainparams, &id, dbid, capabilities, fds[0]);
622
623 /*~ We stash this in a global, because we need to get both the fd and
624 * the client pointer to the callback. The other way would be to
625 * create a boutique structure and hand that, but we don't need to. */
626 pending_client_fd = fds[1];
627 return io_write_wire(conn, take(towire_hsmd_client_hsmfd_reply(NULL)),
628 send_pending_client_fd, c);
629}
630
631static struct io_plan *handle_memleak(struct io_conn *conn,
632 struct client *c,

Callers 1

handle_clientFunction · 0.85

Calls 4

is_lightningdFunction · 0.85
bad_reqFunction · 0.85
new_clientFunction · 0.85
status_failedFunction · 0.50

Tested by

no test coverage detected