code.vegaprotocol.io/vega@v0.79.0/cmd/vega/commands/nodewallet/root.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  	"context"
    20  
    21  	"code.vegaprotocol.io/vega/core/admin"
    22  	"code.vegaprotocol.io/vega/core/config"
    23  	"code.vegaprotocol.io/vega/core/nodewallets"
    24  
    25  	"github.com/fatih/color"
    26  	"github.com/jessevdk/go-flags"
    27  )
    28  
    29  var (
    30  	yellow = color.New(color.FgYellow).SprintFunc()
    31  	green  = color.New(color.FgGreen).SprintFunc()
    32  )
    33  
    34  type RootCmd struct {
    35  	// Global options
    36  	config.VegaHomeFlag
    37  	config.PassphraseFlag
    38  
    39  	// Subcommands
    40  	Show     showCmd     `command:"show"     description:"List the wallets registers into the nodewallet"`
    41  	Generate generateCmd `command:"generate" description:"Generate and register a wallet into the nodewallet"`
    42  	Import   importCmd   `command:"import"   description:"Import the configuration of a wallet required by the vega node"`
    43  	Verify   verifyCmd   `command:"verify"   description:"Verify the configuration imported in the nodewallet"`
    44  	Reload   reloadCmd   `command:"reload"   description:"Reload node wallet of a running node instance"`
    45  }
    46  
    47  var rootCmd RootCmd
    48  
    49  func NodeWallet(ctx context.Context, parser *flags.Parser) error {
    50  	rootCmd = RootCmd{
    51  		Generate: generateCmd{
    52  			Config: nodewallets.NewDefaultConfig(),
    53  		},
    54  		Import: importCmd{
    55  			Config: nodewallets.NewDefaultConfig(),
    56  		},
    57  		Verify: verifyCmd{
    58  			Config: nodewallets.NewDefaultConfig(),
    59  		},
    60  		Reload: reloadCmd{
    61  			Config: admin.NewDefaultConfig(),
    62  		},
    63  	}
    64  
    65  	var (
    66  		short = "Manages the node wallet"
    67  		long  = `The nodewallet is a wallet owned by the vega node, it contains all
    68  	the information to login to other wallets from external blockchain that
    69  	vega will need to run properly (e.g and ethereum wallet, which allow vega
    70  	to sign transaction to be verified on the ethereum blockchain) available
    71  	wallet: eth, vega`
    72  	)
    73  
    74  	_, err := parser.AddCommand("nodewallet", short, long, &rootCmd)
    75  	return err
    76  }