From 4e0c276154024aae36d5bdf2b3ece6ce45fc9783 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 12 Feb 2020 13:41:48 +0100 Subject: [PATCH] rpcserver: don't skip pending channels in backup subscription The synchronous call to get all channel backups also include channels that are pending at the moment of the call. A previous commit added pending channels to the file based backup as well. So this is the last backup method that needs to be adjusted to also contain unconfirmed channels. --- lntest/itest/lnd_test.go | 6 +++--- rpcserver.go | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lntest/itest/lnd_test.go b/lntest/itest/lnd_test.go index dfe5ee10..69de3914 100644 --- a/lntest/itest/lnd_test.go +++ b/lntest/itest/lnd_test.go @@ -13675,9 +13675,9 @@ func testChannelBackupUpdates(net *lntest.NetworkHarness, t *harnessTest) { } } - // As these two channels were just open, we should've got two - // notifications for channel backups. - assertBackupNtfns(2) + // As these two channels were just opened, we should've got two times + // the pending and open notifications for channel backups. + assertBackupNtfns(2 * 2) // The on disk file should also exactly match the latest backup that we // have. diff --git a/rpcserver.go b/rpcserver.go index f4e13cd6..d7a27d90 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -5605,7 +5605,7 @@ func (r *rpcServer) SubscribeChannelBackups(req *lnrpc.ChannelBackupSubscription updateStream lnrpc.Lightning_SubscribeChannelBackupsServer) error { // First, we'll subscribe to the primary channel notifier so we can - // obtain events for new opened/closed channels. + // obtain events for new pending/opened/closed channels. chanSubscription, err := r.server.channelNotifier.SubscribeChannelEvents() if err != nil { return err @@ -5622,9 +5622,10 @@ func (r *rpcServer) SubscribeChannelBackups(req *lnrpc.ChannelBackupSubscription switch e.(type) { // We only care about new/closed channels, so we'll - // skip any events for pending/active/inactive channels. - case channelnotifier.PendingOpenChannelEvent: - continue + // skip any events for active/inactive channels. + // To make the subscription behave the same way as the + // synchronous call and the file based backup, we also + // include pending channels in the update. case channelnotifier.ActiveChannelEvent: continue case channelnotifier.InactiveChannelEvent: