From 70d3fc640ae6f78057216af059d5ae1503cbcaaa Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Thu, 3 Jan 2019 20:33:35 -0500 Subject: [PATCH] channeldb/db: prevent filtering channels with unconfirmed close txs In this commit, we address an issue with the FetchWaitingCloseChannels method where it would not properly return channels that are unconfirmed and also have an unconfirmed closing transaction because they were filtered out. We fix this by fetching channels that remain unconfirmed that are also waiting for a confirmed closing transaction. This will allow the recently added test TestFetchWaitingCloseChannels to pass. --- channeldb/db.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/channeldb/db.go b/channeldb/db.go index 0f9183185..d71656a72 100644 --- a/channeldb/db.go +++ b/channeldb/db.go @@ -450,9 +450,20 @@ func (d *DB) FetchPendingChannels() ([]*OpenChannel, error) { } // FetchWaitingCloseChannels will return all channels that have been opened, -// but now is waiting for a closing transaction to be confirmed. +// but are now waiting for a closing transaction to be confirmed. +// +// NOTE: This includes channels that are also pending to be opened. func (d *DB) FetchWaitingCloseChannels() ([]*OpenChannel, error) { - return fetchChannels(d, false, true) + waitingClose, err := fetchChannels(d, false, true) + if err != nil { + return nil, err + } + pendingWaitingClose, err := fetchChannels(d, true, true) + if err != nil { + return nil, err + } + + return append(waitingClose, pendingWaitingClose...), nil } // fetchChannels attempts to retrieve channels currently stored in the