From 7adb1bcbaa9689e08e1e281d8cf65379adefc589 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 6 Mar 2020 16:11:48 +0100 Subject: [PATCH] chanbackup: disable channel backup for anchor types --- chanbackup/backup.go | 17 ++++++++++++++--- chanbackup/pubsub.go | 6 ++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/chanbackup/backup.go b/chanbackup/backup.go index ca3698a5..406cc1bf 100644 --- a/chanbackup/backup.go +++ b/chanbackup/backup.go @@ -62,6 +62,12 @@ func FetchBackupForChan(chanPoint wire.OutPoint, return nil, fmt.Errorf("unable to find target channel") } + // TODO(halseth): support chan backups for anchor types. + if targetChan.ChanType.HasAnchors() { + return nil, fmt.Errorf("channel type does not support " + + "backups yet") + } + // Once we have the target channel, we can assemble the backup using // the source to obtain any extra information that we may need. staticChanBackup, err := assembleChanBackup(chanSource, targetChan) @@ -85,14 +91,19 @@ func FetchStaticChanBackups(chanSource LiveChannelSource) ([]Single, error) { // Now that we have all the channels, we'll use the chanSource to // obtain any auxiliary information we need to craft a backup for each // channel. - staticChanBackups := make([]Single, len(openChans)) - for i, openChan := range openChans { + staticChanBackups := make([]Single, 0, len(openChans)) + for _, openChan := range openChans { + // TODO(halseth): support chan backups for anchor types. + if openChan.ChanType.HasAnchors() { + continue + } + chanBackup, err := assembleChanBackup(chanSource, openChan) if err != nil { return nil, err } - staticChanBackups[i] = *chanBackup + staticChanBackups = append(staticChanBackups, *chanBackup) } return staticChanBackups, nil diff --git a/chanbackup/pubsub.go b/chanbackup/pubsub.go index b9331820..2bc74898 100644 --- a/chanbackup/pubsub.go +++ b/chanbackup/pubsub.go @@ -213,6 +213,12 @@ func (s *SubSwapper) backupUpdater() { // For all new open channels, we'll create a new SCB // given the required information. for _, newChan := range chanUpdate.NewChans { + // TODO(halseth): support chan backups for + // anchor types. + if newChan.ChanType.HasAnchors() { + continue + } + log.Debugf("Adding channel %v to backup state", newChan.FundingOutpoint)