github.com/quantosnetwork/Quantos@v0.0.0-20220306172517-e20b28c5a29a/cmd/address.go (about)

     1  // Package cmd /*
     2  package cmd
     3  
     4  import (
     5  	"fmt"
     6  	"github.com/quantosnetwork/Quantos/address"
     7  
     8  	"github.com/spf13/cobra"
     9  )
    10  
    11  // addressCmd represents the address command
    12  var addressCmd = &cobra.Command{
    13  	Use:   "address",
    14  	Short: "QBit (Quantos) address manager",
    15  	Long:  `QBit (Quantos) address manager`,
    16  	Run: func(cmd *cobra.Command, args []string) {
    17  		fmt.Println("address called")
    18  	},
    19  }
    20  
    21  //var bip39 bool
    22  
    23  var newAddressCmd = &cobra.Command{
    24  	Use:   "new-address",
    25  	Short: "create a new wallet address",
    26  	Long:  "create a new wallet address",
    27  	Run: func(cmd *cobra.Command, args []string) {
    28  
    29  		//	bip39 := true
    30  
    31  		compress, _ := cmd.Flags().GetBool("compress")
    32  		pass, _ := cmd.Flags().GetString("pass")
    33  		mnemonic, _ := cmd.Flags().GetString("mnemonic")
    34  		address.NewQBITAddress(compress, pass, mnemonic)
    35  		//address.NewAddress(compress, pass, mnemonic)
    36  
    37  	},
    38  }
    39  
    40  func init() {
    41  	rootCmd.AddCommand(addressCmd)
    42  
    43  	newAddressCmd.Flags().BoolP("bip39", "b", false, "mnemonic code for generating deterministic keys")
    44  	newAddressCmd.Flags().BoolP("compress", "c", true, "generate a compressed public key")
    45  	newAddressCmd.Flags().String("pass", "", "protect bip39 address with passphrase")
    46  	newAddressCmd.Flags().Int("number", 10, "set number of keys to generate")
    47  	newAddressCmd.Flags().String("mnemonic", "", "optional list of words to re-generate a root key")
    48  
    49  	addressCmd.AddCommand(newAddressCmd)
    50  
    51  	// Here you will define your flags and configuration settings.
    52  
    53  	// Cobra supports Persistent Flags which will work for this command
    54  	// and all subcommands, e.g.:
    55  	// addressCmd.PersistentFlags().String("foo", "", "A help for foo")
    56  
    57  	// Cobra supports local flags which will only run when this command
    58  	// is called directly, e.g.:
    59  	// addressCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
    60  }