From 1133820ad624b4f326fd005dd810bdc693cb7146 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 2 Apr 2018 16:42:37 +0200 Subject: [PATCH] db: Add a cleanup migration to clear any dangling utxoset entries Signed-off-by: Christian Decker --- wallet/db.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wallet/db.c b/wallet/db.c index bbe3fd7a5..058863f30 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -270,6 +270,12 @@ char *dbmigrations[] = { /* Record the msatoshi actually sent in a payment. */ "ALTER TABLE payments ADD msatoshi_sent INTEGER;", "UPDATE payments SET msatoshi_sent = msatoshi;", + /* Delete dangling utxoset entries due to Issue #1280 */ + "DELETE FROM utxoset WHERE blockheight IN (" + " SELECT DISTINCT(blockheight)" + " FROM utxoset LEFT OUTER JOIN blocks on (blockheight == blocks.height) " + " WHERE blocks.hash IS NULL" + ");", NULL, };