laconicd/cmd/emintcli/keys.go
Federico Kunze 375a7a074d
local testnet command (#378)
* evm: fix non-determinism

* fixes

* typo

* fix tests

* local testnet command

* fix testnet cmd (#383)

fix export-eth-key

generate eth type account in genesis.json file

* fixes

* update docker

* minor changes

* fix build-docker-local-ethermint

* fix dockerfile

* update Makefile

* update denoms

* update genesis file

* update makefile

* fix docker-compose.yml images

* fix localnet execution (#398)

* finish documentation

* changelog and comment rpc tests workflow

* update codecov

* update testnet docs

* fix docker-compose execution

* update docs

* fix errors and make testnet work (#403)

* fix errors and make testnet work

* Update Dockerfile

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>

* wip - fix db

* fixes emintd nodes and syncs nodes

* starts daemon and rpc server in bg

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>

* update entrypoint and docs

* update logs

* try fix rpc

* build docker image

* Update Dockerfile

Co-authored-by: Holechain <nrgh@foxmail.com>
Co-authored-by: Alessio Treglia <quadrispro@ubuntu.com>
Co-authored-by: Daniel Choi <choidanielw@gmail.com>
2020-07-31 17:42:04 -04:00

75 lines
1.8 KiB
Go

package main
import (
"bufio"
"io"
"github.com/cosmos/cosmos-sdk/client/flags"
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ethermint/crypto"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
const (
flagDryRun = "dry-run"
)
// keyCommands registers a sub-tree of commands to interact with
// local private key storage.
func keyCommands() *cobra.Command {
cmd := &cobra.Command{
Use: "keys",
Short: "Add or view local private keys",
Long: `Keys allows you to manage your local keystore for tendermint.
These keys may be in any format supported by go-crypto and can be
used by light-clients, full nodes, or any other application that
needs to sign with a private key.`,
}
addCmd := clientkeys.AddKeyCommand()
addCmd.RunE = runAddCmd
cmd.AddCommand(
clientkeys.MnemonicKeyCommand(),
addCmd,
clientkeys.ExportKeyCommand(),
clientkeys.ImportKeyCommand(),
clientkeys.ListKeysCmd(),
clientkeys.ShowKeysCmd(),
flags.LineBreak,
clientkeys.DeleteKeyCommand(),
clientkeys.ParseKeyStringCommand(),
clientkeys.MigrateCommand(),
flags.LineBreak,
unsafeExportEthKeyCommand(),
)
return cmd
}
func getKeybase(transient bool, buf io.Reader) (keyring.Keybase, error) {
if transient {
return keyring.NewInMemory(keyring.WithKeygenFunc(crypto.EthermintKeygenFunc)), nil
}
return keyring.NewKeyring(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
buf,
keyring.WithKeygenFunc(crypto.EthermintKeygenFunc))
}
func runAddCmd(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin())
kb, err := getKeybase(viper.GetBool(flagDryRun), inBuf)
if err != nil {
return err
}
return clientkeys.RunAddCmd(cmd, args, kb, inBuf)
}