diff --git a/lightningd/htlc_end.c b/lightningd/htlc_end.c index 607da655c..626df0f51 100644 --- a/lightningd/htlc_end.c +++ b/lightningd/htlc_end.c @@ -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"); diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 91c0e52a0..21e6cf3ab 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -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); + } } }