Browse Source

lightningd: handle the case where the db contains a resolved HTLC without a preimage.

We need to handle this case (old db) before the next commit, which actually
fixes it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
fee-tracking2
Rusty Russell 6 years ago
parent
commit
65f6813706
  1. 9
      lightningd/peer_htlcs.c
  2. 1
      tests/test_connection.py

9
lightningd/peer_htlcs.c

@ -1704,7 +1704,7 @@ void htlcs_reconnect(struct lightningd *ld,
/* For fulfilled HTLCs, we fulfill incoming before outgoing is
* completely resolved, so it's possible that we don't find
* the incoming. FIXME: iff hout->preimage! */
* the incoming. */
for (hin = htlc_in_map_first(htlcs_in, &ini); hin;
hin = htlc_in_map_next(htlcs_in, &ini)) {
if (hout->origin_htlc_id == hin->dbid) {
@ -1716,6 +1716,13 @@ void htlcs_reconnect(struct lightningd *ld,
break;
}
}
if (!hout->in && !hout->preimage) {
/* FIXME: COMPAT_V061 only */
log_broken(ld->log,
"Missing preimage for orphaned HTLC; replacing with zeros");
hout->preimage = talz(hout, struct preimage);
}
}
}

1
tests/test_connection.py

@ -1333,7 +1333,6 @@ def test_restart_multi_htlc_rexmit(node_factory, bitcoind, executor):
wait_for(lambda: [p['status'] for p in l1.rpc.listpayments()['payments']] == ['complete', 'complete'])
@pytest.mark.xfail(strict=True)
@unittest.skipIf(not DEVELOPER, "needs dev-disconnect")
def test_fulfill_incoming_first(node_factory, bitcoind):
"""Test that we handle the case where we completely resolve incoming htlc

Loading…
Cancel
Save