| 1744 | } |
| 1745 | |
| 1746 | bool 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)); |
no test coverage detected