Skip to content

channeld: handle funding_locked message before reestablish. #2373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ changes.
- You can no longer make giant unpayable "wumbo" invoices.
- CLTV of total route now correctly evaluated when finding best route.
- `riskfactor` arguments to `pay` and `getroute` now have an effect.
- Handle lnd sending premature 'funding_locked' message when we're expected 'reestablish';
we used to close channel if this happened.

### Security

Expand Down
18 changes: 16 additions & 2 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,7 @@ static void peer_reconnect(struct peer *peer,
remote_current_per_commitment_point;
struct secret last_local_per_commitment_secret;
bool dataloss_protect;
const u8 *premature_funding_locked = NULL;

dataloss_protect = local_feature_negotiated(peer->localfeatures,
LOCAL_DATA_LOSS_PROTECT);
Expand Down Expand Up @@ -2143,8 +2144,16 @@ static void peer_reconnect(struct peer *peer,
do {
clean_tmpctx();
msg = sync_crypto_read(tmpctx, &peer->cs, PEER_FD);
} while (handle_peer_gossip_or_error(PEER_FD, GOSSIP_FD, &peer->cs,
&peer->channel_id, msg));

/* Older LND sometimes sends funding_locked before reestablish! */
if (fromwire_peektype(msg) == WIRE_FUNDING_LOCKED
&& !premature_funding_locked) {
status_trace("Stashing early funding_locked msg!");
premature_funding_locked = tal_steal(peer, msg);
msg = NULL;
}
} while (!msg || handle_peer_gossip_or_error(PEER_FD, GOSSIP_FD, &peer->cs,
&peer->channel_id, msg));

if (dataloss_protect) {
if (!fromwire_channel_reestablish_option_data_loss_protect(msg,
Expand Down Expand Up @@ -2342,6 +2351,11 @@ static void peer_reconnect(struct peer *peer,
peer->channel->changes_pending[LOCAL] = true;

peer_billboard(true, "Reconnected, and reestablished.");

if (premature_funding_locked) {
handle_peer_funding_locked(peer, premature_funding_locked);
tal_free(premature_funding_locked);
}
}

/* Funding has locked in, and reached depth. */
Expand Down