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

Function peer_start_openingd

lightningd/opening_control.c:969–1038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967}
968
969bool peer_start_openingd(struct peer *peer, struct peer_fd *peer_fd)
970{
971 int hsmfd;
972 u32 max_to_self_delay;
973 struct amount_msat min_effective_htlc_capacity;
974 struct uncommitted_channel *uc;
975 const u8 *msg;
976 u32 minrate, maxrate;
977
978 assert(peer->uncommitted_channel);
979 uc = peer->uncommitted_channel;
980 assert(!uc->open_daemon);
981
982 hsmfd = hsm_get_client_fd(peer->ld, &uc->peer->id, uc->dbid,
983 HSM_PERM_COMMITMENT_POINT
984 | HSM_PERM_SIGN_REMOTE_TX);
985
986 if (hsmfd < 0) {
987 uncommitted_channel_disconnect(uc, LOG_BROKEN,
988 tal_fmt(tmpctx,
989 "Getting hsmfd for lightning_openingd: %s",
990 strerror(errno)));
991 tal_free(uc);
992 return false;
993 }
994
995 uc->open_daemon = new_channel_subd(peer, peer->ld,
996 "lightning_openingd",
997 uc, &peer->id, uc->log,
998 true, openingd_wire_name,
999 openingd_msg,
1000 opend_channel_errmsg,
1001 opend_channel_set_billboard,
1002 take(&peer_fd->fd),
1003 take(&hsmfd), NULL);
1004 if (!uc->open_daemon) {
1005 uncommitted_channel_disconnect(uc, LOG_BROKEN,
1006 tal_fmt(tmpctx,
1007 "Running lightning_openingd: %s",
1008 strerror(errno)));
1009 tal_free(uc);
1010 return false;
1011 }
1012
1013 channel_config(peer->ld, &uc->our_config,
1014 &max_to_self_delay,
1015 &min_effective_htlc_capacity);
1016
1017 /* openingd applies ignore_fee_limits itself, so these stay honest. */
1018 minrate = feerate_min(peer->ld, NULL);
1019 maxrate = feerate_max(peer->ld, NULL);
1020
1021 msg = towire_openingd_init(NULL,
1022 chainparams,
1023 peer->ld->our_features,
1024 peer->their_features,
1025 &uc->our_config,
1026 max_to_self_delay,

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