update go-ethereum with patch 0044-import-extended-key-by-purpose (#1318)

This commit is contained in:
Andrea Franz 2018-12-12 11:13:10 +01:00 committed by GitHub
parent f2c6fef64c
commit e1c258d041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

4
Gopkg.lock generated
View File

@ -88,7 +88,7 @@
revision = "935e0e8a636ca4ba70b713f3e38a19e1b77739e8" revision = "935e0e8a636ca4ba70b713f3e38a19e1b77739e8"
[[projects]] [[projects]]
digest = "1:e221b8d0ccd91e9ee0a2ddda27ec75518dd683de945d01c87816f64ce418bf91" digest = "1:9919b13a30417311490b5e631bfecc14b20c1aeec85fb0ba5286efaa300622d6"
name = "github.com/ethereum/go-ethereum" name = "github.com/ethereum/go-ethereum"
packages = [ packages = [
".", ".",
@ -158,7 +158,7 @@
"trie", "trie",
] ]
pruneopts = "T" pruneopts = "T"
revision = "2ad6673303bb48f8e3c2865386cfa928e92dbcbd" revision = "97bb147b17ed32d82d0ce1dd110caa31d02923db"
source = "github.com/status-im/go-ethereum" source = "github.com/status-im/go-ethereum"
version = "v1.8.17" version = "v1.8.17"

View File

@ -144,7 +144,7 @@ func newKeyFromECDSA(privateKeyECDSA *ecdsa.PrivateKey) *Key {
return key return key
} }
func newKeyFromExtendedKey(extKey *extkeys.ExtendedKey) (*Key, error) { func newKeyForPurposeFromExtendedKey(keyPurpose extkeys.KeyPurpose, extKey *extkeys.ExtendedKey) (*Key, error) {
var ( var (
extChild1, extChild2 *extkeys.ExtendedKey extChild1, extChild2 *extkeys.ExtendedKey
err error err error
@ -152,13 +152,13 @@ func newKeyFromExtendedKey(extKey *extkeys.ExtendedKey) (*Key, error) {
if extKey.Depth == 0 { // we are dealing with master key if extKey.Depth == 0 { // we are dealing with master key
// CKD#1 - main account // CKD#1 - main account
extChild1, err = extKey.BIP44Child(extkeys.CoinTypeETH, 0) extChild1, err = extKey.ChildForPurpose(keyPurpose, 0)
if err != nil { if err != nil {
return &Key{}, err return &Key{}, err
} }
// CKD#2 - sub-accounts root // CKD#2 - sub-accounts root
extChild2, err = extKey.BIP44Child(extkeys.CoinTypeETH, 1) extChild2, err = extKey.ChildForPurpose(keyPurpose, 1)
if err != nil { if err != nil {
return &Key{}, err return &Key{}, err
} }

View File

@ -462,7 +462,13 @@ func (ks *KeyStore) ImportECDSA(priv *ecdsa.PrivateKey, passphrase string) (acco
// ImportExtendedKey stores ECDSA key (obtained from extended key) along with CKD#2 (root for sub-accounts) // ImportExtendedKey stores ECDSA key (obtained from extended key) along with CKD#2 (root for sub-accounts)
// If key file is not found, it is created. Key is encrypted with the given passphrase. // If key file is not found, it is created. Key is encrypted with the given passphrase.
func (ks *KeyStore) ImportExtendedKey(extKey *extkeys.ExtendedKey, passphrase string) (accounts.Account, error) { func (ks *KeyStore) ImportExtendedKey(extKey *extkeys.ExtendedKey, passphrase string) (accounts.Account, error) {
key, err := newKeyFromExtendedKey(extKey) return ks.ImportExtendedKeyForPurpose(extkeys.KeyPurposeWallet, extKey, passphrase)
}
// ImportExtendedKeyForPurpose stores ECDSA key (obtained from extended key) along with CKD#2 (root for sub-accounts)
// If key file is not found, it is created. Key is encrypted with the given passphrase.
func (ks *KeyStore) ImportExtendedKeyForPurpose(keyPurpose extkeys.KeyPurpose, extKey *extkeys.ExtendedKey, passphrase string) (accounts.Account, error) {
key, err := newKeyForPurposeFromExtendedKey(keyPurpose, extKey)
if err != nil { if err != nil {
zeroKey(key.PrivateKey) zeroKey(key.PrivateKey)
return accounts.Account{}, err return accounts.Account{}, err