From c6f210a46cfca545cb8e8b7b79ed356d78170d6a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 25 Sep 2017 21:50:20 +0200 Subject: [PATCH] htlcs: Needed to add origin_htlc_id to outgoing HTLCs While loading HTLCs from the database we might not yet have all the incoming HTLCs loaded when loading a dependent htlc_out. So we defer the wiring of the HTLCs until we are sure we have them loaded. This is also the first step towards keeping that association only in the database, since otherwise we cannot selectively load channels from DB. Signed-off-by: Christian Decker --- lightningd/htlc_end.h | 1 + wallet/wallet.c | 1 + 2 files changed, 2 insertions(+) diff --git a/lightningd/htlc_end.h b/lightningd/htlc_end.h index 73e1d3d37..9a502d2cc 100644 --- a/lightningd/htlc_end.h +++ b/lightningd/htlc_end.h @@ -47,6 +47,7 @@ struct htlc_out { * is saved to the database, must be >0 after saving to the * database. */ u64 dbid; + u64 origin_htlc_id; struct htlc_key key; u64 msatoshi; u32 cltv_expiry; diff --git a/wallet/wallet.c b/wallet/wallet.c index 91a379436..08d81d3b6 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -884,6 +884,7 @@ bool wallet_htlc_save_out(struct wallet *wallet, /* We absolutely need the incoming HTLC to be persisted before * we can persist it's dependent */ assert(out->in == NULL || out->in->dbid != 0); + out->origin_htlc_id = out->in?out->in->dbid:0; ok &= db_exec( __func__, wallet->db,