From 8f7a19d1a3c5967663fe8f850b24e75a2a259339 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 14 Feb 2018 16:38:54 +1030 Subject: [PATCH] onchain: handle case where multiple HTLCs exist for same payment_hash. We will have probably failed the others, but either way, don't try to fulfill an HTLC we've already failed. Fixes: #394 Signed-off-by: Rusty Russell --- lightningd/peer_htlcs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 6c174b0ba..1d84e2295 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -709,6 +709,11 @@ void onchain_fulfilled_htlc(struct channel *channel, if (hout->key.channel != channel) continue; + /* It's possible that we failed some and succeeded one, + * if we got multiple errors. */ + if (hout->failcode != 0 || hout->failuremsg) + continue; + if (!structeq(&hout->payment_hash, &payment_hash)) continue;