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

Function connectd_init

lightningd/connect_control.c:562–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560}
561
562int connectd_init(struct lightningd *ld)
563{
564 int fds[2];
565 u8 *msg;
566 int hsmfd;
567 struct wireaddr_internal *wireaddrs = ld->proposed_wireaddr;
568 enum addr_listen_announce *listen_announce = ld->proposed_listen_announce;
569 const char *websocket_helper_path;
570 void *ret;
571
572 websocket_helper_path = subdaemon_path(tmpctx, ld,
573 "lightning_websocketd");
574
575 if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0)
576 fatal("Could not socketpair for connectd<->gossipd");
577
578 hsmfd = hsm_get_global_fd(ld, HSM_CAP_ECDH);
579
580 ld->connectd = new_global_subd(ld, "lightning_connectd",
581 connectd_wire_name, connectd_msg,
582 take(&hsmfd), take(&fds[1]),
583#if DEVELOPER
584 /* Not take(): we share it */
585 ld->dev_disconnect_fd >= 0 ?
586 &ld->dev_disconnect_fd : NULL,
587#endif
588 NULL);
589 if (!ld->connectd)
590 err(1, "Could not subdaemon connectd");
591
592 /* If no addr specified, hand wildcard to connectd */
593 if (tal_count(wireaddrs) == 0 && ld->autolisten) {
594 wireaddrs = tal_arrz(tmpctx, struct wireaddr_internal, 1);
595 listen_announce = tal_arr(tmpctx, enum addr_listen_announce, 1);
596 wireaddrs->itype = ADDR_INTERNAL_ALLPROTO;
597 wireaddrs->u.port = ld->portnum;
598 *listen_announce = ADDR_LISTEN_AND_ANNOUNCE;
599 }
600
601 msg = towire_connectd_init(
602 tmpctx, chainparams,
603 ld->our_features,
604 &ld->id,
605 wireaddrs,
606 listen_announce,
607 ld->proxyaddr, ld->always_use_proxy || ld->pure_tor_setup,
608 IFDEV(ld->dev_allow_localhost, false), ld->config.use_dns,
609 ld->tor_service_password ? ld->tor_service_password : "",
610 ld->config.connection_timeout_secs,
611 websocket_helper_path,
612 ld->websocket_port,
613 !deprecated_apis,
614 IFDEV(ld->dev_fast_gossip, false),
615 IFDEV(ld->dev_disconnect_fd >= 0, false),
616 IFDEV(ld->dev_no_ping_timer, false));
617
618 subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
619 connect_init_done, NULL);

Callers 1

mainFunction · 0.70

Calls 7

hsm_get_global_fdFunction · 0.85
new_global_subdFunction · 0.85
errFunction · 0.85
io_loopFunction · 0.85
subdaemon_pathFunction · 0.70
fatalFunction · 0.70
subd_reqClass · 0.70

Tested by

no test coverage detected