Skip to content
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

lightningd: don't crash if peer manages to spend onchain HTLC after we've abandoned upstream #6449

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lightningd/htlc_end.c
Expand Up @@ -203,9 +203,9 @@ struct htlc_out *htlc_out_check(const struct htlc_out *hout,
return corrupt(abortstr,
"Output failmsg, input preimage");
} else if (hout->preimage) {
if (hout->in->failonion)
return corrupt(abortstr,
"Output preimage, input failonion");
/* If we abandoned the HTLC to save the incoming channel,
* (see consider_failing_incoming), hout->in->failonion
* will be set! */
if (hout->in->badonion)
return corrupt(abortstr,
"Output preimage, input badonion");
Expand Down
17 changes: 12 additions & 5 deletions lightningd/peer_htlcs.c
Expand Up @@ -1464,11 +1464,18 @@ static void fulfill_our_htlc_out(struct channel *channel, struct htlc_out *hout,
if (hout->am_origin)
payment_succeeded(ld, &hout->payment_hash, hout->partid, hout->groupid, preimage);
else if (hout->in) {
fulfill_htlc(hout->in, preimage);
wallet_forwarded_payment_add(ld->wallet, hout->in,
FORWARD_STYLE_TLV,
channel_scid_or_local_alias(hout->key.channel), hout,
FORWARD_SETTLED, 0);
/* Did we abandon the incoming? Oops! */
if (hout->in->failonion) {
/* FIXME: Accounting? */
log_unusual(channel->log, "FUNDS LOSS of %s: peer took funds onchain before we could time out the HTLC, but we abandoned incoming HTLC to save the incoming channel",
fmt_amount_msat(tmpctx, hout->msat));
} else {
fulfill_htlc(hout->in, preimage);
wallet_forwarded_payment_add(ld->wallet, hout->in,
FORWARD_STYLE_TLV,
channel_scid_or_local_alias(hout->key.channel), hout,
FORWARD_SETTLED, 0);
}
}
}

Expand Down