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

Function peer_start_channeld

lightningd/channel_control.c:1746–2014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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
our_feerate_maxFunction · 0.85
get_blockheightFunction · 0.85
topology_syncedFunction · 0.85

Tested by

no test coverage detected