mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
df: move initialization over to unsaved channel
uncommitted_channel -> channel (but unsaved)
This commit is contained in:
parent
0951e2c941
commit
8b0e88dfb3
@ -2305,6 +2305,7 @@ void peer_restart_dualopend(struct peer *peer,
|
|||||||
u32 max_to_self_delay;
|
u32 max_to_self_delay;
|
||||||
struct amount_msat min_effective_htlc_capacity;
|
struct amount_msat min_effective_htlc_capacity;
|
||||||
struct channel_config unused_config;
|
struct channel_config unused_config;
|
||||||
|
struct channel_inflight *inflight;
|
||||||
int hsmfd;
|
int hsmfd;
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
|
|
||||||
@ -2338,6 +2339,7 @@ void peer_restart_dualopend(struct peer *peer,
|
|||||||
&max_to_self_delay,
|
&max_to_self_delay,
|
||||||
&min_effective_htlc_capacity);
|
&min_effective_htlc_capacity);
|
||||||
|
|
||||||
|
inflight = channel_current_inflight(channel);
|
||||||
msg = towire_dualopend_reinit(NULL,
|
msg = towire_dualopend_reinit(NULL,
|
||||||
chainparams,
|
chainparams,
|
||||||
peer->ld->our_features,
|
peer->ld->our_features,
|
||||||
@ -2360,7 +2362,7 @@ void peer_restart_dualopend(struct peer *peer,
|
|||||||
channel->our_msat,
|
channel->our_msat,
|
||||||
&channel->channel_info.theirbase,
|
&channel->channel_info.theirbase,
|
||||||
&channel->channel_info.remote_per_commit,
|
&channel->channel_info.remote_per_commit,
|
||||||
NULL, /* FIXME! */
|
inflight->funding_psbt,
|
||||||
channel->opener,
|
channel->opener,
|
||||||
channel->scid != NULL,
|
channel->scid != NULL,
|
||||||
channel->remote_funding_locked,
|
channel->remote_funding_locked,
|
||||||
@ -2368,7 +2370,7 @@ void peer_restart_dualopend(struct peer *peer,
|
|||||||
channel->shutdown_scriptpubkey[REMOTE] != NULL,
|
channel->shutdown_scriptpubkey[REMOTE] != NULL,
|
||||||
channel->shutdown_scriptpubkey[LOCAL],
|
channel->shutdown_scriptpubkey[LOCAL],
|
||||||
channel->remote_upfront_shutdown_script,
|
channel->remote_upfront_shutdown_script,
|
||||||
false, /* FIXME! */
|
inflight->remote_tx_sigs,
|
||||||
channel->fee_states,
|
channel->fee_states,
|
||||||
channel->channel_flags,
|
channel->channel_flags,
|
||||||
send_msg);
|
send_msg);
|
||||||
@ -2385,40 +2387,45 @@ void peer_start_dualopend(struct peer *peer,
|
|||||||
int hsmfd;
|
int hsmfd;
|
||||||
u32 max_to_self_delay;
|
u32 max_to_self_delay;
|
||||||
struct amount_msat min_effective_htlc_capacity;
|
struct amount_msat min_effective_htlc_capacity;
|
||||||
struct uncommitted_channel *uc;
|
|
||||||
const u8 *msg;
|
const u8 *msg;
|
||||||
|
struct channel *channel;
|
||||||
|
|
||||||
assert(!peer->uncommitted_channel);
|
/* And we never touch this. */
|
||||||
uc = peer->uncommitted_channel = new_uncommitted_channel(peer);
|
assert(!peer_unsaved_channel(peer));
|
||||||
|
channel = new_unsaved_channel(peer,
|
||||||
|
peer->ld->config.fee_base,
|
||||||
|
peer->ld->config.fee_per_satoshi);
|
||||||
|
|
||||||
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, uc->dbid,
|
|
||||||
|
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->unsaved_dbid,
|
||||||
HSM_CAP_COMMITMENT_POINT
|
HSM_CAP_COMMITMENT_POINT
|
||||||
| HSM_CAP_SIGN_REMOTE_TX);
|
| HSM_CAP_SIGN_REMOTE_TX);
|
||||||
|
|
||||||
uc->open_daemon = new_channel_subd(peer->ld,
|
channel->owner = new_channel_subd(peer->ld,
|
||||||
"lightning_dualopend",
|
"lightning_dualopend",
|
||||||
uc, UNCOMMITTED, &peer->id,
|
channel, CHANNEL,
|
||||||
uc->log, true,
|
&peer->id,
|
||||||
dualopend_wire_name,
|
channel->log, true,
|
||||||
dual_opend_msg,
|
dualopend_wire_name,
|
||||||
opend_channel_errmsg,
|
dual_opend_msg,
|
||||||
opend_channel_set_billboard,
|
channel_errmsg,
|
||||||
take(&pps->peer_fd),
|
channel_set_billboard,
|
||||||
take(&pps->gossip_fd),
|
take(&pps->peer_fd),
|
||||||
take(&pps->gossip_store_fd),
|
take(&pps->gossip_fd),
|
||||||
take(&hsmfd), NULL);
|
take(&pps->gossip_store_fd),
|
||||||
|
take(&hsmfd), NULL);
|
||||||
|
|
||||||
if (!uc->open_daemon) {
|
if (!channel->owner) {
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
errmsg = tal_fmt(tmpctx,
|
errmsg = tal_fmt(tmpctx,
|
||||||
"Running lightning_dualopend: %s",
|
"Running lightning_dualopend: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
uncommitted_channel_disconnect(uc, LOG_BROKEN, errmsg);
|
unsaved_channel_disconnect(channel, LOG_BROKEN, errmsg);
|
||||||
tal_free(uc);
|
tal_free(channel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_config(peer->ld, &uc->our_config,
|
channel_config(peer->ld, &channel->our_config,
|
||||||
&max_to_self_delay,
|
&max_to_self_delay,
|
||||||
&min_effective_htlc_capacity);
|
&min_effective_htlc_capacity);
|
||||||
|
|
||||||
@ -2429,19 +2436,19 @@ void peer_start_dualopend(struct peer *peer,
|
|||||||
* considers reasonable to avoid double-spending of the
|
* considers reasonable to avoid double-spending of the
|
||||||
* funding transaction.
|
* funding transaction.
|
||||||
*/
|
*/
|
||||||
uc->minimum_depth = peer->ld->config.anchor_confirms;
|
channel->minimum_depth = peer->ld->config.anchor_confirms;
|
||||||
|
|
||||||
msg = towire_dualopend_init(NULL, chainparams,
|
msg = towire_dualopend_init(NULL, chainparams,
|
||||||
peer->ld->our_features,
|
peer->ld->our_features,
|
||||||
peer->their_features,
|
peer->their_features,
|
||||||
&uc->our_config,
|
&channel->our_config,
|
||||||
max_to_self_delay,
|
max_to_self_delay,
|
||||||
min_effective_htlc_capacity,
|
min_effective_htlc_capacity,
|
||||||
pps, &uc->local_basepoints,
|
pps, &channel->local_basepoints,
|
||||||
&uc->local_funding_pubkey,
|
&channel->local_funding_pubkey,
|
||||||
uc->minimum_depth,
|
channel->minimum_depth,
|
||||||
feerate_min(peer->ld, NULL),
|
feerate_min(peer->ld, NULL),
|
||||||
feerate_max(peer->ld, NULL),
|
feerate_max(peer->ld, NULL),
|
||||||
send_msg);
|
send_msg);
|
||||||
subd_send_msg(uc->open_daemon, take(msg));
|
subd_send_msg(channel->owner, take(msg));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user