df: update channel_id when opening; closing; disconnecting

We were missing the channel_id for accepter opens; it's also a good idea
to reset it to 0xFF when we disconnect totally
This commit is contained in:
niftynei 2021-01-21 20:58:37 -06:00 committed by neil saitug
parent 474233f1b7
commit d8221aae76
2 changed files with 7 additions and 1 deletions

View File

@ -53,6 +53,9 @@ unsaved_channel_disconnect(struct channel *channel,
was_pending(command_fail(channel->open_attempt->cmd,
LIGHTNINGD, "%s", desc));
notify_disconnect(channel->peer->ld, &channel->peer->id);
channel->open_attempt = tal_free(channel->open_attempt);
if (list_empty(&channel->inflights))
memset(&channel->cid, 0xFF, sizeof(channel->cid));
}
void kill_unsaved_channel(struct channel *channel,
@ -655,6 +658,7 @@ openchannel2_hook_cb(struct openchannel2_payload *payload STEALS)
}
}
channel->cid = payload->channel_id;
channel->opener = REMOTE;
channel->open_attempt = new_channel_open_attempt(channel);
msg = towire_dualopend_got_offer_reply(NULL, payload->accepter_funding,
@ -1120,6 +1124,8 @@ opening_failed_cancel_commands(struct channel *channel,
/* FIXME: cancels? */
channel->open_attempt = tal_free(channel->open_attempt);
if (list_empty(&channel->inflights))
memset(&channel->cid, 0xFF, sizeof(channel->cid));
}
static void open_failed(struct subd *dualopend, const u8 *msg)
@ -1438,6 +1444,7 @@ static void rbf_got_offer(struct subd *dualopend, const u8 *msg)
return;
}
assert(channel_id_eq(&channel->cid, &payload->channel_id));
/* Fill in general channel info from channel */
payload->peer_id = channel->peer->id;
payload->feerate_our_max = feerate_max(dualopend->ld, NULL);

View File

@ -1152,7 +1152,6 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
if (!hook_payload->channel)
hook_payload->channel = peer_unsaved_channel(peer);
assert(hook_payload->channel);
plugin_hook_call_peer_connected(ld, hook_payload);
}