From ec74aadce2db0d8e52b4e1540b38615e53d1a16e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 9 Oct 2018 19:21:52 +1030 Subject: [PATCH] lightningd: save outgoing HTLC's preimage to db. We can now wrap the 'missing preimage' hack in COMPAT_V061. Signed-off-by: Rusty Russell --- lightningd/peer_htlcs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index ffff21ca6..01a066376 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -77,7 +77,7 @@ static bool htlc_out_update_state(struct channel *channel, return false; wallet_htlc_update(channel->peer->ld->wallet, hout->dbid, newstate, - NULL); + hout->preimage); hout->hstate = newstate; return true; @@ -1718,10 +1718,15 @@ void htlcs_reconnect(struct lightningd *ld, } if (!hout->in && !hout->preimage) { - /* FIXME: COMPAT_V061 only */ +#ifdef COMPAT_V061 log_broken(ld->log, "Missing preimage for orphaned HTLC; replacing with zeros"); hout->preimage = talz(hout, struct preimage); +#else + fatal("Unable to find corresponding htlc_in %"PRIu64 + " for unfulfilled htlc_out %"PRIu64, + hout->origin_htlc_id, hout->dbid); +#endif } } }