forked from cerc-io/laconicd-deprecated
Cosmos PR changes (#158)
* Changes necessary for enforced custom account encoding/decoding and keyring keybase changes * updates cosmos dependency and fixes inconsistency in gas usage for simulated/real txs * Update PR changes * Remove unused password prompt when using OS keyring * Update from changes to sdk * Update to merged PR commit :the_horns: * updated code to handle keyring backend options * update documentation and replace cosmos-sdk with fork (temporarily) * update cosmos dependency from fork * update documentation
This commit is contained in:
+17
-6
@@ -6,10 +6,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
ethcrypto "github.com/ethereum/go-ethereum/crypto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/input"
|
||||
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||
emintcrypto "github.com/cosmos/ethermint/crypto"
|
||||
@@ -27,17 +29,26 @@ func exportEthKeyCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
func runExportCmd(cmd *cobra.Command, args []string) error {
|
||||
kb, err := clientkeys.NewKeyBaseFromHomeFlag()
|
||||
kb, err := clientkeys.NewKeyringFromHomeFlag(cmd.InOrStdin())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Get password from input or standard input
|
||||
buf := bufio.NewReader(cmd.InOrStdin())
|
||||
decryptPassword, err := input.GetPassword(
|
||||
"**WARNING this is an unsafe way to export your unencrypted private key**\nEnter key password:",
|
||||
buf)
|
||||
if err != nil {
|
||||
decryptPassword := ""
|
||||
conf := true
|
||||
keyringBackend := viper.GetString(flags.FlagKeyringBackend)
|
||||
switch keyringBackend {
|
||||
case flags.KeyringBackendFile:
|
||||
decryptPassword, err = input.GetPassword(
|
||||
"**WARNING this is an unsafe way to export your unencrypted private key**\nEnter key password:",
|
||||
buf)
|
||||
case flags.KeyringBackendOS:
|
||||
conf, err = input.GetConfirmation(
|
||||
"**WARNING** this is an unsafe way to export your unencrypted private key, are you sure?",
|
||||
buf)
|
||||
}
|
||||
if err != nil || !conf {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
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/keys"
|
||||
@@ -48,21 +51,22 @@ func keyCommands() *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func getKeybase(dryrun bool) (keys.Keybase, error) {
|
||||
func getKeybase(cmd *cobra.Command, dryrun bool, buf io.Reader) (keys.Keybase, error) {
|
||||
if dryrun {
|
||||
return keys.NewInMemory(keys.WithKeygenFunc(ethermintKeygenFunc)), nil
|
||||
}
|
||||
|
||||
return clientkeys.NewKeyBaseFromHomeFlag(keys.WithKeygenFunc(ethermintKeygenFunc))
|
||||
return clientkeys.NewKeyringFromHomeFlag(buf, keys.WithKeygenFunc(ethermintKeygenFunc))
|
||||
}
|
||||
|
||||
func runAddCmd(cmd *cobra.Command, args []string) error {
|
||||
kb, err := getKeybase(viper.GetBool(flagDryRun))
|
||||
inBuf := bufio.NewReader(cmd.InOrStdin())
|
||||
kb, err := getKeybase(cmd, viper.GetBool(flagDryRun), inBuf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientkeys.RunAddCmd(cmd, args, kb)
|
||||
return clientkeys.RunAddCmd(cmd, args, kb, inBuf)
|
||||
}
|
||||
|
||||
func ethermintKeygenFunc(bz [32]byte) tmcrypto.PrivKey {
|
||||
|
||||
Reference in New Issue
Block a user