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

Function peer_start_dualopend

lightningd/dual_open_control.c:4150–4225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4148}
4149
4150bool peer_start_dualopend(struct peer *peer,
4151 struct peer_fd *peer_fd,
4152 struct channel *channel)
4153{
4154 int hsmfd;
4155 u32 max_to_self_delay;
4156 struct amount_msat min_effective_htlc_capacity;
4157 const u8 *msg;
4158 const char *dev_old_seed;
4159
4160 hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->unsaved_dbid,
4161 HSM_PERM_COMMITMENT_POINT
4162 | HSM_PERM_SIGN_REMOTE_TX
4163 | HSM_PERM_SIGN_WILL_FUND_OFFER
4164 | HSM_PERM_LOCK_OUTPOINT);
4165 if (hsmfd < 0) {
4166 channel_internal_error(channel,
4167 "Getting hsm fd for dualopend: %s",
4168 strerror(errno));
4169 return false;
4170 }
4171
4172 dev_old_seed = dev_setup_dualopend_seed(tmpctx, peer->ld);
4173 channel->owner = new_channel_subd(channel,
4174 peer->ld,
4175 "lightning_dualopend",
4176 channel,
4177 &peer->id,
4178 channel->log, true,
4179 dualopend_wire_name,
4180 dual_opend_msg,
4181 dualopen_errmsg,
4182 channel_set_billboard,
4183 take(&peer_fd->fd),
4184 take(&hsmfd), NULL);
4185 dev_restore_seed(dev_old_seed);
4186
4187 if (!channel->owner) {
4188 channel_internal_error(channel,
4189 "Running lightningd_dualopend: %s",
4190 strerror(errno));
4191 return false;
4192 }
4193
4194 channel_config(peer->ld, &channel->our_config,
4195 &max_to_self_delay,
4196 &min_effective_htlc_capacity);
4197
4198 /* BOLT #2:
4199 *
4200 * The sender:
4201 * - if `channel_type` includes `option_zeroconf`:
4202 * - MUST set `minimum_depth` to zero.
4203 * - otherwise:
4204 * - SHOULD set `minimum_depth` to a number of blocks it
4205 * considers reasonable to avoid double-spending of the
4206 * funding transaction.
4207 */

Callers 4

openchannel_initFunction · 0.70
json_queryratesFunction · 0.70
peer_restart_dualopendFunction · 0.70
handle_peer_spokeFunction · 0.70

Calls 6

hsm_get_client_fdFunction · 0.85
dev_setup_dualopend_seedFunction · 0.85
dev_restore_seedFunction · 0.85
channel_internal_errorFunction · 0.70
channel_configClass · 0.70
subd_send_msgFunction · 0.70

Tested by

no test coverage detected