Merge pull request #3455 from wpaulino/cli-missing-chan-backup

cmd/lncli: return error upon missing channel backup when parsing
This commit is contained in:
Olaoluwa Osuntokun 2019-09-03 19:39:12 -07:00 committed by GitHub
commit 78c1c4930e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
}
}