From 3b587a1c6dbcd96e88992366510ecd0815a722da Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 21 Feb 2019 11:52:56 +1030 Subject: [PATCH] lightningd: fix db error where we can have detached peer. An uncommitted channel should not keep the peer in the db, since the uncommitted channel isn't in the db itself. Fixes: #2367 Signed-off-by: Rusty Russell --- lightningd/peer_control.c | 10 ++++++++-- tests/test_connection.py | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index bfa3cf2af..3425468e6 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -139,10 +139,16 @@ static void delete_peer(struct peer *peer) /* Last one out deletes peer. */ void maybe_delete_peer(struct peer *peer) { - if (peer->uncommitted_channel) - return; if (!list_empty(&peer->channels)) return; + if (peer->uncommitted_channel) { + /* This isn't sufficient to keep it in db! */ + if (peer->dbid != 0) { + wallet_peer_delete(peer->ld->wallet, peer->dbid); + peer->dbid = 0; + } + return; + } delete_peer(peer); } diff --git a/tests/test_connection.py b/tests/test_connection.py index fe2dd84c8..f1930f370 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1510,7 +1510,6 @@ def test_restart_many_payments(node_factory): wait_for(lambda: 'pending' not in [p['status'] for p in n.rpc.listpayments()['payments']]) -@pytest.mark.xfail(strict=True) @unittest.skipIf(not DEVELOPER, "need dev-disconnect") def test_fail_unconfirmed(node_factory, bitcoind, executor): """Test that if we crash with an unconfirmed connection to a known