forked from cerc-io/laconicd-deprecated
+5
-12
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/input"
|
||||
"github.com/cosmos/cosmos-sdk/client/lcd"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
||||
@@ -106,26 +105,20 @@ func registerRoutes(rs *lcd.RestServer) {
|
||||
}
|
||||
|
||||
func unlockKeyFromNameAndPassphrase(accountName, passphrase string) (emintKey emintcrypto.PrivKeySecp256k1, err error) {
|
||||
keystore, err := keyring.New(
|
||||
keybase, err := keyring.NewKeyring(
|
||||
sdk.KeyringServiceName(),
|
||||
viper.GetString(flags.FlagKeyringBackend),
|
||||
viper.GetString(flags.FlagHome),
|
||||
os.Stdin,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
// With keyring key store, password is not required as it is pulled from the OS prompt
|
||||
// Exports private key from keyring using password
|
||||
armored, err := keystore.ExportPrivKeyArmor(accountName, passphrase)
|
||||
// With keyring keybase, password is not required as it is pulled from the OS prompt
|
||||
privKey, err := keybase.ExportPrivateKeyObject(accountName, passphrase)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
privKey, _, err := crypto.UnarmorDecryptPrivKey(armored, passphrase)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
|
||||
+9
-9
@@ -45,11 +45,11 @@ import (
|
||||
|
||||
// PublicEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
|
||||
type PublicEthAPI struct {
|
||||
cliCtx context.CLIContext
|
||||
backend Backend
|
||||
key emintcrypto.PrivKeySecp256k1
|
||||
nonceLock *AddrLocker
|
||||
keystoreLock sync.Mutex
|
||||
cliCtx context.CLIContext
|
||||
backend Backend
|
||||
key emintcrypto.PrivKeySecp256k1
|
||||
nonceLock *AddrLocker
|
||||
keybaseLock sync.Mutex
|
||||
}
|
||||
|
||||
// NewPublicEthAPI creates an instance of the public ETH Web3 API.
|
||||
@@ -123,11 +123,11 @@ func (e *PublicEthAPI) GasPrice() *hexutil.Big {
|
||||
|
||||
// Accounts returns the list of accounts available to this node.
|
||||
func (e *PublicEthAPI) Accounts() ([]common.Address, error) {
|
||||
e.keystoreLock.Lock()
|
||||
e.keybaseLock.Lock()
|
||||
|
||||
addresses := make([]common.Address, 0) // return [] instead of nil if empty
|
||||
|
||||
keystore, err := keyring.New(
|
||||
keybase, err := keyring.NewKeyring(
|
||||
sdk.KeyringServiceName(),
|
||||
viper.GetString(flags.FlagKeyringBackend),
|
||||
viper.GetString(flags.FlagHome),
|
||||
@@ -137,12 +137,12 @@ func (e *PublicEthAPI) Accounts() ([]common.Address, error) {
|
||||
return addresses, err
|
||||
}
|
||||
|
||||
infos, err := keystore.List()
|
||||
infos, err := keybase.List()
|
||||
if err != nil {
|
||||
return addresses, err
|
||||
}
|
||||
|
||||
e.keystoreLock.Unlock()
|
||||
e.keybaseLock.Unlock()
|
||||
|
||||
for _, info := range infos {
|
||||
addressBytes := info.GetPubKey().Address().Bytes()
|
||||
|
||||
Reference in New Issue
Block a user