dualopend: tell lightningd what remote alias the peer sent.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-01-31 13:46:17 +10:30
parent 2d93ddbdf1
commit 9c80a5cebb
5 changed files with 21 additions and 9 deletions

View file

@ -936,7 +936,8 @@ void lockin_complete(struct channel *channel,
}
bool channel_on_channel_ready(struct channel *channel,
struct pubkey *next_per_commitment_point)
const struct pubkey *next_per_commitment_point,
const struct short_channel_id *remote_alias)
{
if (channel->remote_channel_ready) {
channel_internal_error(channel,
@ -945,6 +946,13 @@ bool channel_on_channel_ready(struct channel *channel,
}
update_per_commit_point(channel, next_per_commitment_point);
/* FIXME: we should apply this even if it changed! */
if (channel->alias[REMOTE] == NULL) {
channel->alias[REMOTE]
= tal_dup_or_null(channel, struct short_channel_id,
remote_alias);
}
log_debug(channel->log, "Got channel_ready");
channel->remote_channel_ready = true;
@ -1034,12 +1042,11 @@ static void peer_got_channel_ready(struct channel *channel, const u8 *msg)
return;
}
if (!channel_on_channel_ready(channel, &next_per_commitment_point))
if (!channel_on_channel_ready(channel,
&next_per_commitment_point,
alias_remote))
return;
if (channel->alias[REMOTE] == NULL)
channel->alias[REMOTE] = tal_steal(channel, alias_remote);
/* Remember that we got the lockin */
wallet_channel_save(channel->peer->ld->wallet, channel);

View file

@ -33,7 +33,8 @@ struct command_result *cancel_channel_before_broadcast(struct command *cmd,
/* Update the channel info on channel_ready */
bool channel_on_channel_ready(struct channel *channel,
struct pubkey *next_per_commitment_point);
const struct pubkey *next_per_commitment_point,
const struct short_channel_id *remote_alias);
/* Record channel open (coin movement notifications) */
void channel_record_open(struct channel *channel, u32 blockheight, bool record_push);

View file

@ -1940,8 +1940,11 @@ static void handle_peer_locked(struct subd *dualopend, const u8 *msg)
{
struct pubkey remote_per_commit;
struct channel *channel = dualopend->channel;
struct short_channel_id *remote_alias;
if (!fromwire_dualopend_peer_locked(msg, &remote_per_commit)) {
if (!fromwire_dualopend_peer_locked(msg, msg,
&remote_per_commit,
&remote_alias)) {
channel_internal_error(channel,
"Bad WIRE_DUALOPEND_PEER_LOCKED: %s",
tal_hex(msg, msg));
@ -1950,7 +1953,7 @@ static void handle_peer_locked(struct subd *dualopend, const u8 *msg)
/* Updates channel with the next per-commit point etc, calls
* channel_internal_error on failure */
if (!channel_on_channel_ready(channel, &remote_per_commit))
if (!channel_on_channel_ready(channel, &remote_per_commit, remote_alias))
return;
/* Remember that we got the lock-in */

View file

@ -1563,7 +1563,7 @@ static u8 *handle_channel_ready(struct state *state, u8 *msg)
/* We save when the peer locks, so we do the right
* thing on reconnects */
if (!state->channel_ready[REMOTE]) {
msg = towire_dualopend_peer_locked(NULL, &remote_per_commit);
msg = towire_dualopend_peer_locked(NULL, &remote_per_commit, tlvs->short_channel_id);
wire_sync_write(REQ_FD, take(msg));
}

View file

@ -222,6 +222,7 @@ msgtype,dualopend_tx_sigs_sent,7012
# dualopend->peer peer locked channel
msgtype,dualopend_peer_locked,7018
msgdata,dualopend_peer_locked,remote_per_commit,pubkey,
msgdata,dualopend_peer_locked,remote_alias,?short_channel_id,
# dualopend->master this channel has been locked
msgtype,dualopend_channel_locked,7019

Can't render this file because it has a wrong number of fields in line 16.