code.vegaprotocol.io/vega@v0.79.0/cmd/vega/commands/nodewallet/verify.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package nodewallet 17 18 import ( 19 "fmt" 20 21 "code.vegaprotocol.io/vega/core/config" 22 "code.vegaprotocol.io/vega/core/nodewallets" 23 "code.vegaprotocol.io/vega/logging" 24 "code.vegaprotocol.io/vega/paths" 25 26 "github.com/jessevdk/go-flags" 27 ) 28 29 type verifyCmd struct { 30 Config nodewallets.Config 31 } 32 33 func (opts *verifyCmd) Execute(_ []string) error { 34 log := logging.NewLoggerFromConfig(logging.NewDefaultConfig()) 35 defer log.AtExit() 36 37 registryPass, err := rootCmd.PassphraseFile.Get("node wallet", false) 38 if err != nil { 39 return err 40 } 41 42 vegaPaths := paths.New(rootCmd.VegaHome) 43 44 _, conf, err := config.EnsureNodeConfig(vegaPaths) 45 if err != nil { 46 return err 47 } 48 49 opts.Config = conf.NodeWallet 50 51 if _, err := flags.NewParser(opts, flags.Default|flags.IgnoreUnknown).Parse(); err != nil { 52 return err 53 } 54 55 nw, err := nodewallets.GetNodeWallets(opts.Config, vegaPaths, registryPass) 56 if err != nil { 57 return fmt.Errorf("couldn't get node wallets: %w", err) 58 } 59 60 if err := nw.Verify(); err != nil { 61 return err 62 } 63 64 fmt.Println(green("ok")) 65 return nil 66 }