mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +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:
@@ -235,7 +235,6 @@ struct channel *new_unsaved_channel(struct peer *peer,
|
||||
"chan#%"PRIu64,
|
||||
channel->unsaved_dbid);
|
||||
|
||||
memset(&channel->cid, 0xFF, sizeof(channel->cid));
|
||||
channel->our_config.id = 0;
|
||||
channel->open_attempt = NULL;
|
||||
|
||||
|
||||
@@ -2595,6 +2595,11 @@ static struct command_result *json_openchannel_init(struct command *cmd,
|
||||
channel = new_unsaved_channel(peer,
|
||||
peer->ld->config.fee_base,
|
||||
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
|
||||
@@ -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 */
|
||||
subd_send_msg(peer->ld->connectd,
|
||||
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
||||
NULL)));
|
||||
&channel->cid)));
|
||||
return command_still_pending(cmd);
|
||||
}
|
||||
|
||||
@@ -3099,6 +3104,11 @@ static struct command_result *json_queryrates(struct command *cmd,
|
||||
channel = new_unsaved_channel(peer,
|
||||
peer->ld->config.fee_base,
|
||||
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
|
||||
@@ -3167,7 +3177,7 @@ static struct command_result *json_queryrates(struct command *cmd,
|
||||
/* Tell connectd to hand us this so we can start dualopend */
|
||||
subd_send_msg(peer->ld->connectd,
|
||||
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
||||
NULL)));
|
||||
&channel->cid)));
|
||||
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_msat *push_msat;
|
||||
u32 *upfront_shutdown_script_wallet_index;
|
||||
struct channel_id tmp_channel_id;
|
||||
|
||||
fc->cmd = cmd;
|
||||
fc->cancels = tal_arr(fc, struct command *, 0);
|
||||
@@ -1207,6 +1208,8 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
||||
} else
|
||||
upfront_shutdown_script_wallet_index = NULL;
|
||||
|
||||
temporary_channel_id(&tmp_channel_id);
|
||||
|
||||
fc->open_msg
|
||||
= towire_openingd_funder_start(fc,
|
||||
*amount,
|
||||
@@ -1214,12 +1217,13 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
||||
fc->our_upfront_shutdown_script,
|
||||
upfront_shutdown_script_wallet_index,
|
||||
*feerate_per_kw,
|
||||
&tmp_channel_id,
|
||||
fc->channel_flags);
|
||||
|
||||
/* Tell connectd to make this active; when it does, we can continue */
|
||||
subd_send_msg(peer->ld->connectd,
|
||||
take(towire_connectd_peer_make_active(NULL, &peer->id,
|
||||
NULL)));
|
||||
&tmp_channel_id)));
|
||||
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,
|
||||
peer->ld->config.fee_base,
|
||||
peer->ld->config.fee_per_satoshi);
|
||||
channel->cid = *channel_id;
|
||||
peer_start_dualopend(peer, peer_fd, channel);
|
||||
} else {
|
||||
peer->uncommitted_channel = new_uncommitted_channel(peer);
|
||||
|
||||
Reference in New Issue
Block a user