Add loading of block test privkey if present

This commit is contained in:
Gustav Simonsson
2015-04-27 19:32:45 +02:00
parent 2a61611c4f
commit 34c94d5fcd
4 changed files with 35 additions and 9 deletions

View File

@ -179,6 +179,19 @@ func Decrypt(prv *ecdsa.PrivateKey, ct []byte) ([]byte, error) {
return key.Decrypt(rand.Reader, ct, nil, nil)
}
// Used only by block tests.
func ImportBlockTestKey(privKeyBytes []byte) error {
ks := NewKeyStorePassphrase(common.DefaultDataDir() + "/keys")
ecKey := ToECDSA(privKeyBytes)
key := &Key{
Id: uuid.NewRandom(),
Address: PubkeyToAddress(ecKey.PublicKey),
PrivateKey: ecKey,
}
err := ks.StoreKey(key, "")
return err
}
// creates a Key and stores that in the given KeyStore by decrypting a presale key JSON
func ImportPreSaleKey(keyStore KeyStore2, keyJSON []byte, password string) (*Key, error) {
key, err := decryptPreSaleKey(keyJSON, password)