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

Function peer_start_openingd

lightningd/opening_control.c:956–1028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

954}
955
956bool peer_start_openingd(struct peer *peer, struct peer_fd *peer_fd)
957{
958 int hsmfd;
959 u32 max_to_self_delay;
960 struct amount_msat min_effective_htlc_capacity;
961 struct uncommitted_channel *uc;
962 const u8 *msg;
963 u32 minrate, maxrate;
964
965 assert(peer->uncommitted_channel);
966 uc = peer->uncommitted_channel;
967 assert(!uc->open_daemon);
968
969 hsmfd = hsm_get_client_fd(peer->ld, &uc->peer->id, uc->dbid,
970 HSM_PERM_COMMITMENT_POINT
971 | HSM_PERM_SIGN_REMOTE_TX);
972
973 if (hsmfd < 0) {
974 uncommitted_channel_disconnect(uc, LOG_BROKEN,
975 tal_fmt(tmpctx,
976 "Getting hsmfd for lightning_openingd: %s",
977 strerror(errno)));
978 tal_free(uc);
979 return false;
980 }
981
982 uc->open_daemon = new_channel_subd(peer, peer->ld,
983 "lightning_openingd",
984 uc, &peer->id, uc->log,
985 true, openingd_wire_name,
986 openingd_msg,
987 opend_channel_errmsg,
988 opend_channel_set_billboard,
989 take(&peer_fd->fd),
990 take(&hsmfd), NULL);
991 if (!uc->open_daemon) {
992 uncommitted_channel_disconnect(uc, LOG_BROKEN,
993 tal_fmt(tmpctx,
994 "Running lightning_openingd: %s",
995 strerror(errno)));
996 tal_free(uc);
997 return false;
998 }
999
1000 channel_config(peer->ld, &uc->our_config,
1001 &max_to_self_delay,
1002 &min_effective_htlc_capacity);
1003
1004 if (peer->ld->config.ignore_fee_limits) {
1005 minrate = 1;
1006 maxrate = 0xFFFFFFFF;
1007 } else {
1008 minrate = feerate_min(peer->ld, NULL);
1009 maxrate = feerate_max(peer->ld, NULL);
1010 }
1011
1012 msg = towire_openingd_init(NULL,
1013 chainparams,

Callers 2

handle_peer_spokeFunction · 0.70
fundchannel_startFunction · 0.70

Calls 7

hsm_get_client_fdFunction · 0.85
tal_freeFunction · 0.85
feerate_minFunction · 0.85
feerate_maxFunction · 0.85
channel_configClass · 0.70
subd_send_msgFunction · 0.70

Tested by

no test coverage detected