mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-18 22:54:25 +01:00
lightningd: always tell connectd the channel id.
This means lightningd needs to create the temporary one and tell it to openingd/dualopend, rather than the other way around. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -79,7 +79,7 @@ msgdata,connectd_peer_disconnect_done,id,node_id,
|
|||||||
# Master -> connectd: make peer active immediately (we want to talk)
|
# Master -> connectd: make peer active immediately (we want to talk)
|
||||||
msgtype,connectd_peer_make_active,2004
|
msgtype,connectd_peer_make_active,2004
|
||||||
msgdata,connectd_peer_make_active,id,node_id,
|
msgdata,connectd_peer_make_active,id,node_id,
|
||||||
msgdata,connectd_peer_make_active,channel_id,?channel_id,
|
msgdata,connectd_peer_make_active,channel_id,channel_id,
|
||||||
|
|
||||||
# Connectd -> master: peer said something interesting (or you said make_active)
|
# Connectd -> master: peer said something interesting (or you said make_active)
|
||||||
# Plus fd for peer daemon.
|
# Plus fd for peer daemon.
|
||||||
|
|||||||
|
@@ -440,9 +440,9 @@ void peer_make_active(struct daemon *daemon, const u8 *msg)
|
|||||||
{
|
{
|
||||||
struct node_id id;
|
struct node_id id;
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
struct channel_id *channel_id;
|
struct channel_id channel_id;
|
||||||
|
|
||||||
if (!fromwire_connectd_peer_make_active(msg, msg, &id, &channel_id))
|
if (!fromwire_connectd_peer_make_active(msg, &id, &channel_id))
|
||||||
master_badmsg(WIRE_CONNECTD_PEER_MAKE_ACTIVE, msg);
|
master_badmsg(WIRE_CONNECTD_PEER_MAKE_ACTIVE, msg);
|
||||||
|
|
||||||
/* Races can happen: this might be gone by now. */
|
/* Races can happen: this might be gone by now. */
|
||||||
@@ -458,7 +458,7 @@ void peer_make_active(struct daemon *daemon, const u8 *msg)
|
|||||||
if (tal_count(peer->subds) != 0)
|
if (tal_count(peer->subds) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!activate_peer(peer, NULL, channel_id))
|
if (!activate_peer(peer, NULL, &channel_id))
|
||||||
tal_free(peer);
|
tal_free(peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -235,7 +235,6 @@ struct channel *new_unsaved_channel(struct peer *peer,
|
|||||||
"chan#%"PRIu64,
|
"chan#%"PRIu64,
|
||||||
channel->unsaved_dbid);
|
channel->unsaved_dbid);
|
||||||
|
|
||||||
memset(&channel->cid, 0xFF, sizeof(channel->cid));
|
|
||||||
channel->our_config.id = 0;
|
channel->our_config.id = 0;
|
||||||
channel->open_attempt = NULL;
|
channel->open_attempt = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -2595,6 +2595,11 @@ static struct command_result *json_openchannel_init(struct command *cmd,
|
|||||||
channel = new_unsaved_channel(peer,
|
channel = new_unsaved_channel(peer,
|
||||||
peer->ld->config.fee_base,
|
peer->ld->config.fee_base,
|
||||||
peer->ld->config.fee_per_satoshi);
|
peer->ld->config.fee_per_satoshi);
|
||||||
|
|
||||||
|
/* We derive initial channel_id *now*, so we can tell it to
|
||||||
|
* connectd. */
|
||||||
|
derive_tmp_channel_id(&channel->cid,
|
||||||
|
&channel->local_basepoints.revocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel->open_attempt
|
if (channel->open_attempt
|
||||||
@@ -2688,7 +2693,7 @@ static struct command_result *json_openchannel_init(struct command *cmd,
|
|||||||
/* Tell connectd to hand us this so we can start dualopend */
|
/* Tell connectd to hand us this so we can start dualopend */
|
||||||
subd_send_msg(peer->ld->connectd,
|
subd_send_msg(peer->ld->connectd,
|
||||||
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
||||||
NULL)));
|
&channel->cid)));
|
||||||
return command_still_pending(cmd);
|
return command_still_pending(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3099,6 +3104,11 @@ static struct command_result *json_queryrates(struct command *cmd,
|
|||||||
channel = new_unsaved_channel(peer,
|
channel = new_unsaved_channel(peer,
|
||||||
peer->ld->config.fee_base,
|
peer->ld->config.fee_base,
|
||||||
peer->ld->config.fee_per_satoshi);
|
peer->ld->config.fee_per_satoshi);
|
||||||
|
|
||||||
|
/* We derive initial channel_id *now*, so we can tell it to
|
||||||
|
* connectd. */
|
||||||
|
derive_tmp_channel_id(&channel->cid,
|
||||||
|
&channel->local_basepoints.revocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel->open_attempt
|
if (channel->open_attempt
|
||||||
@@ -3167,7 +3177,7 @@ static struct command_result *json_queryrates(struct command *cmd,
|
|||||||
/* Tell connectd to hand us this so we can start dualopend */
|
/* Tell connectd to hand us this so we can start dualopend */
|
||||||
subd_send_msg(peer->ld->connectd,
|
subd_send_msg(peer->ld->connectd,
|
||||||
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
||||||
NULL)));
|
&channel->cid)));
|
||||||
return command_still_pending(cmd);
|
return command_still_pending(cmd);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1079,6 +1079,7 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
|||||||
struct amount_sat *amount;
|
struct amount_sat *amount;
|
||||||
struct amount_msat *push_msat;
|
struct amount_msat *push_msat;
|
||||||
u32 *upfront_shutdown_script_wallet_index;
|
u32 *upfront_shutdown_script_wallet_index;
|
||||||
|
struct channel_id tmp_channel_id;
|
||||||
|
|
||||||
fc->cmd = cmd;
|
fc->cmd = cmd;
|
||||||
fc->cancels = tal_arr(fc, struct command *, 0);
|
fc->cancels = tal_arr(fc, struct command *, 0);
|
||||||
@@ -1207,6 +1208,8 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
|||||||
} else
|
} else
|
||||||
upfront_shutdown_script_wallet_index = NULL;
|
upfront_shutdown_script_wallet_index = NULL;
|
||||||
|
|
||||||
|
temporary_channel_id(&tmp_channel_id);
|
||||||
|
|
||||||
fc->open_msg
|
fc->open_msg
|
||||||
= towire_openingd_funder_start(fc,
|
= towire_openingd_funder_start(fc,
|
||||||
*amount,
|
*amount,
|
||||||
@@ -1214,12 +1217,13 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
|||||||
fc->our_upfront_shutdown_script,
|
fc->our_upfront_shutdown_script,
|
||||||
upfront_shutdown_script_wallet_index,
|
upfront_shutdown_script_wallet_index,
|
||||||
*feerate_per_kw,
|
*feerate_per_kw,
|
||||||
|
&tmp_channel_id,
|
||||||
fc->channel_flags);
|
fc->channel_flags);
|
||||||
|
|
||||||
/* Tell connectd to make this active; when it does, we can continue */
|
/* Tell connectd to make this active; when it does, we can continue */
|
||||||
subd_send_msg(peer->ld->connectd,
|
subd_send_msg(peer->ld->connectd,
|
||||||
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
||||||
NULL)));
|
&tmp_channel_id)));
|
||||||
return command_still_pending(cmd);
|
return command_still_pending(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1374,6 +1374,7 @@ void peer_active(struct lightningd *ld, const u8 *msg, int fd)
|
|||||||
channel = new_unsaved_channel(peer,
|
channel = new_unsaved_channel(peer,
|
||||||
peer->ld->config.fee_base,
|
peer->ld->config.fee_base,
|
||||||
peer->ld->config.fee_per_satoshi);
|
peer->ld->config.fee_per_satoshi);
|
||||||
|
channel->cid = *channel_id;
|
||||||
peer_start_dualopend(peer, peer_fd, channel);
|
peer_start_dualopend(peer, peer_fd, channel);
|
||||||
} else {
|
} else {
|
||||||
peer->uncommitted_channel = new_uncommitted_channel(peer);
|
peer->uncommitted_channel = new_uncommitted_channel(peer);
|
||||||
|
|||||||
@@ -240,10 +240,6 @@ static bool setup_channel_funder(struct state *state)
|
|||||||
* could do it for the we-are-funding case. */
|
* could do it for the we-are-funding case. */
|
||||||
set_reserve(state, state->localconf.dust_limit);
|
set_reserve(state, state->localconf.dust_limit);
|
||||||
|
|
||||||
/*~ Grab a random ID until the funding tx is created (we can't do that
|
|
||||||
* until we know their funding_pubkey) */
|
|
||||||
temporary_channel_id(&state->channel_id);
|
|
||||||
|
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
/* --dev-force-tmp-channel-id specified */
|
/* --dev-force-tmp-channel-id specified */
|
||||||
if (dev_force_tmp_channel_id)
|
if (dev_force_tmp_channel_id)
|
||||||
@@ -1308,6 +1304,7 @@ static u8 *handle_master_in(struct state *state)
|
|||||||
&state->upfront_shutdown_script[LOCAL],
|
&state->upfront_shutdown_script[LOCAL],
|
||||||
&state->local_upfront_shutdown_wallet_index,
|
&state->local_upfront_shutdown_wallet_index,
|
||||||
&state->feerate_per_kw,
|
&state->feerate_per_kw,
|
||||||
|
&state->channel_id,
|
||||||
&channel_flags))
|
&channel_flags))
|
||||||
master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
|
master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
|
||||||
msg = funder_channel_start(state, channel_flags);
|
msg = funder_channel_start(state, channel_flags);
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ msgdata,openingd_funder_start,len_upfront,u16,
|
|||||||
msgdata,openingd_funder_start,upfront_shutdown_script,u8,len_upfront
|
msgdata,openingd_funder_start,upfront_shutdown_script,u8,len_upfront
|
||||||
msgdata,openingd_funder_start,upfront_shutdown_wallet_index,?u32,
|
msgdata,openingd_funder_start,upfront_shutdown_wallet_index,?u32,
|
||||||
msgdata,openingd_funder_start,feerate_per_kw,u32,
|
msgdata,openingd_funder_start,feerate_per_kw,u32,
|
||||||
|
msgdata,openingd_funder_start,temporary_channel_id,channel_id,
|
||||||
msgdata,openingd_funder_start,channel_flags,u8,
|
msgdata,openingd_funder_start,channel_flags,u8,
|
||||||
|
|
||||||
# openingd->master: send back output script for 2-of-2 funding output
|
# openingd->master: send back output script for 2-of-2 funding output
|
||||||
|
|||||||
|
Reference in New Issue
Block a user