bump SDK commit (#324)

* bump SDK commit

* crypto: Secp256k1 algorithm

* crypto: fix codec and derivation issues

* lint
This commit is contained in:
Federico Kunze
2020-06-08 12:19:26 -04:00
committed by GitHub
parent a745e66f3e
commit 5614adc933
11 changed files with 323 additions and 53 deletions
+12 -5
View File
@@ -10,6 +10,7 @@ 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"
@@ -105,20 +106,26 @@ func registerRoutes(rs *lcd.RestServer) {
}
func unlockKeyFromNameAndPassphrase(accountName, passphrase string) (emintKey emintcrypto.PrivKeySecp256k1, err error) {
keybase, err := keyring.NewKeyring(
keystore, err := keyring.New(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
os.Stdin,
)
if err != nil {
return
return nil, err
}
// With keyring keybase, password is not required as it is pulled from the OS prompt
privKey, err := keybase.ExportPrivateKeyObject(accountName, passphrase)
// 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)
if err != nil {
return
return nil, err
}
privKey, _, err := crypto.UnarmorDecryptPrivKey(armored, passphrase)
if err != nil {
return nil, err
}
var ok bool
+9 -9
View File
@@ -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
keybaseLock sync.Mutex
cliCtx context.CLIContext
backend Backend
key emintcrypto.PrivKeySecp256k1
nonceLock *AddrLocker
keystoreLock sync.Mutex
}
// NewPublicEthAPI creates an instance of the public ETH Web3 API.
@@ -113,11 +113,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.keybaseLock.Lock()
e.keystoreLock.Lock()
addresses := make([]common.Address, 0) // return [] instead of nil if empty
keybase, err := keyring.NewKeyring(
keystore, err := keyring.New(
sdk.KeyringServiceName(),
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
@@ -127,12 +127,12 @@ func (e *PublicEthAPI) Accounts() ([]common.Address, error) {
return addresses, err
}
infos, err := keybase.List()
infos, err := keystore.List()
if err != nil {
return addresses, err
}
e.keybaseLock.Unlock()
e.keystoreLock.Unlock()
for _, info := range infos {
addressBytes := info.GetPubKey().Address().Bytes()