func cliConvertPrivValidatorToErisKey(cmd *cobra.Command, args []string) { cmd.ParseFlags(args) if len(args) == 0 { exit(fmt.Errorf("Please enter the path to the priv_validator.json")) } pvf := args[0] b, err := ioutil.ReadFile(pvf) ifExit(err) pv := new(PrivValidator) wire.ReadJSON(pv, b, &err) ifExit(err) keyStore := crypto.NewKeyStorePlain(DefaultKeyStore) key := &crypto.Key{ Id: uuid.NewRandom(), Type: crypto.KeyType{crypto.CurveTypeEd25519, crypto.AddrTypeRipemd160}, Address: pv.Address, PrivateKey: pv.PrivKey[:], } fmt.Printf("%X\n", key.Address) ifExit(keyStore.StoreKey(key, "")) }
func cliConvertErisKeyToPrivValidator(cmd *cobra.Command, args []string) { cmd.ParseFlags(args) if len(args) == 0 { exit(fmt.Errorf("Please enter the address of your key")) } addr := args[0] addrBytes, err := hex.DecodeString(addr) ifExit(err) keyStore := crypto.NewKeyStorePlain(DefaultKeyStore) key, err := keyStore.GetKey(addrBytes, "") ifExit(err) pub, err := key.Pubkey() ifExit(err) var pubKey account.PubKeyEd25519 copy(pubKey[:], pub) var privKey account.PrivKeyEd25519 copy(privKey[:], key.PrivateKey) privVal := PrivValidator{ Address: addrBytes, PubKey: pubKey, PrivKey: privKey, } fmt.Println(string(wire.JSONBytes(privVal))) }
func cliConvertPrivValidatorToErisKey(cmd *cobra.Command, args []string) { cmd.ParseFlags(args) if len(args) == 0 { exit(fmt.Errorf("Please enter the path to the priv_validator.json")) } pvf := args[0] b, err := ioutil.ReadFile(pvf) ifExit(err) key, err := coreConvertPrivValidatorToErisKey(b) ifExit(err) fmt.Printf("%X\n", key.Address) }
func cliConvertErisKeyToPrivValidator(cmd *cobra.Command, args []string) { cmd.ParseFlags(args) if len(args) == 0 { exit(fmt.Errorf("Please enter the address of your key")) } addr := args[0] addrBytes, err := hex.DecodeString(addr) ifExit(err) privVal, err := coreConvertErisKeyToPrivValidator(addrBytes) ifExit(err) fmt.Println(string(wire.JSONBytes(privVal))) }
func cliIntsToStrings(cmd *cobra.Command, args []string) { cmd.ParseFlags(args) if len(args) != 2 { Exit(fmt.Errorf("Please enter PermFlag and SetBit integers")) } pf, sb := args[0], args[1] perms, err := strconv.Atoi(pf) IfExit(err) setbits, err := strconv.Atoi(sb) IfExit(err) m := coreIntsToStrings(types.PermFlag(perms), types.PermFlag(setbits)) printStringPerms(m) }
func cliStringsToInts(cmd *cobra.Command, args []string) { cmd.ParseFlags(args) if len(args) == 0 { Exit(fmt.Errorf("Please enter at least one `<permission>:<value>` pair like `send:0 call:1 create_account:1`")) } bp := types.ZeroBasePermissions for _, a := range args { spl := strings.Split(a, ":") if len(spl) != 2 { Exit(fmt.Errorf("arguments must be like `send:1`, not %s", a)) } name, v := spl[0], spl[1] vi := v[0] - '0' pf, err := types.PermStringToFlag(name) IfExit(err) bp.Set(pf, vi > 0) } printPerms(bp, BitmaskFlag) }