From 06f544a78cfafc90618f0cb1f2913ce38f418096 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Tue, 3 Sep 2019 14:03:31 -0700 Subject: [PATCH] cmd/lncli: return error upon missing channel backup when parsing --- cmd/lncli/commands.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 7457284d..da678dff 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -1567,12 +1567,12 @@ mnemonicCheck: "RESTORE THE WALLET!!!") // We'll also check to see if they provided any static channel backups, - // if so, then we'll also tack these onto the final innit wallet - // request. + // if so, then we'll also tack these onto the final init wallet request. + // We can ignore the errMissingChanBackup error as it's an optional + // field. backups, err := parseChanBackups(ctx) - if err != nil { - return fmt.Errorf("unable to parse chan "+ - "backups: %v", err) + if err != nil && err != errMissingChanBackup { + return fmt.Errorf("unable to parse chan backups: %v", err) } var chanBackups *lnrpc.ChanBackupSnapshot @@ -3931,6 +3931,10 @@ var restoreChanBackupCommand = cli.Command{ Action: actionDecorator(restoreChanBackup), } +// errMissingChanBackup is an error returned when we attempt to parse a channel +// backup from a CLI command and it is missing. +var errMissingChanBackup = errors.New("missing channel backup") + func parseChanBackups(ctx *cli.Context) (*lnrpc.RestoreChanBackupRequest, error) { switch { case ctx.IsSet("single_backup"): @@ -3983,7 +3987,7 @@ func parseChanBackups(ctx *cli.Context) (*lnrpc.RestoreChanBackupRequest, error) }, nil default: - return nil, nil + return nil, errMissingChanBackup } }