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

Function peer_start_channeld

lightningd/channel_control.c:1729–1990  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1727}
1728
1729bool peer_start_channeld(struct channel *channel,
1730 struct peer_fd *peer_fd,
1731 const u8 *fwd_msg,
1732 bool reconnected)
1733{
1734 u8 *initmsg;
1735 int hsmfd;
1736 const struct existing_htlc **htlcs;
1737 struct short_channel_id scid;
1738 u64 num_revocations;
1739 struct lightningd *ld = channel->peer->ld;
1740 const struct config *cfg = &ld->config;
1741 struct secret last_remote_per_commit_secret;
1742 struct penalty_base *pbases;
1743 u32 feerate_splice, min_feerate, max_feerate, curr_blockheight;
1744 struct channel_inflight *inflight;
1745 struct inflight **inflights;
1746 struct bitcoin_txid txid;
1747
1748 hsmfd = hsm_get_client_fd(ld, &channel->peer->id,
1749 channel->dbid,
1750 HSM_PERM_SIGN_GOSSIP
1751 | HSM_PERM_ECDH
1752 | HSM_PERM_COMMITMENT_POINT
1753 | HSM_PERM_SIGN_REMOTE_TX
1754 | HSM_PERM_SIGN_ONCHAIN_TX
1755 | HSM_PERM_SIGN_CLOSING_TX
1756 | HSM_PERM_SIGN_SPLICE_TX
1757 | HSM_PERM_LOCK_OUTPOINT);
1758 if (hsmfd < 0) {
1759 log_broken(channel->log, "Could not get hsm fd: %s",
1760 strerror(errno));
1761 force_peer_disconnect(ld, channel->peer,
1762 "Failed to get hsm fd");
1763 return false;
1764 }
1765
1766 /* At this point, we can forward via alias scid, at least. */
1767 tell_connectd_scid(ld, *channel->alias[LOCAL], &channel->peer->id);
1768
1769 channel_set_owner(channel,
1770 new_channel_subd(channel, ld,
1771 "lightning_channeld",
1772 channel,
1773 &channel->peer->id,
1774 channel->log, true,
1775 channeld_wire_name,
1776 channel_msg,
1777 channel_control_errmsg,
1778 channel_set_billboard,
1779 take(&peer_fd->fd),
1780 take(&hsmfd), NULL));
1781
1782 if (!channel->owner) {
1783 log_broken(channel->log, "Could not subdaemon channel: %s",
1784 strerror(errno));
1785 force_peer_disconnect(ld, channel->peer,
1786 "Failed to create channeld");

Callers 6

handle_channel_lockedFunction · 0.70
connect_activate_subdFunction · 0.70
handle_peer_spokeFunction · 0.70
opening_funder_finishedFunction · 0.70
opening_fundee_finishedFunction · 0.70
handle_splice_abortFunction · 0.70

Calls 15

hsm_get_client_fdFunction · 0.85
tell_connectd_scidFunction · 0.85
channel_set_ownerFunction · 0.85
peer_htlcsFunction · 0.85
revocations_receivedFunction · 0.85
channel_type_has_anchorsFunction · 0.85
feerate_minFunction · 0.85
feerate_maxFunction · 0.85
get_blockheightFunction · 0.85
topology_syncedFunction · 0.85
tal_wally_startFunction · 0.85

Tested by

no test coverage detected