Browse Source

lightningd: fix inconsistency without COMPAT enabled.

We don't expect payment or payment->route_channels to be NULL without an
old db, but putting an assert there reveals that we try to fail an HTLC
which has already succeeded in 'test_onchain_unwatch'.

Obviously we only want to fail an HTLC which goes onchain if we don't
already have the preimage!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
fee-tracking2
Rusty Russell 6 years ago
parent
commit
6c96bcacd7
  1. 3
      lightningd/pay.c
  2. 4
      lightningd/peer_htlcs.c

3
lightningd/pay.c

@ -482,6 +482,9 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
PAYMENT_FAILED, NULL);
return;
}
#else
assert(payment);
assert(payment->route_channels);
#endif
/* This gives more details than a generic failure message */

4
lightningd/peer_htlcs.c

@ -860,8 +860,8 @@ void onchain_failed_our_htlc(const struct channel *channel,
struct lightningd *ld = channel->peer->ld;
struct htlc_out *hout = find_htlc_out_by_ripemd(channel, &htlc->ripemd);
/* Don't fail twice! */
if (hout->failuremsg || hout->failcode)
/* Don't fail twice (or if already succeeded)! */
if (hout->failuremsg || hout->failcode || hout->preimage)
return;
hout->failcode = WIRE_PERMANENT_CHANNEL_FAILURE;

Loading…
Cancel
Save