@ -25,6 +25,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
)
)
@ -111,7 +112,7 @@ func (ks *KeyStore) DeleteAccount(account *Account, passphrase string) error {
// SignHash calculates a ECDSA signature for the given hash. The produced signature
// SignHash calculates a ECDSA signature for the given hash. The produced signature
// is in the [R || S || V] format where V is 0 or 1.
// is in the [R || S || V] format where V is 0 or 1.
func ( ks * KeyStore ) SignHash ( address * Address , hash [ ] byte ) ( signature [ ] byte , _ error ) {
func ( ks * KeyStore ) SignHash ( address * Address , hash [ ] byte ) ( signature [ ] byte , _ error ) {
return ks . keystore . SignHash ( accounts . Account { Address : address . address } , hash )
return ks . keystore . SignHash ( accounts . Account { Address : address . address } , common . CopyBytes ( hash ) )
}
}
// SignTx signs the given transaction with the requested account.
// SignTx signs the given transaction with the requested account.
@ -130,7 +131,7 @@ func (ks *KeyStore) SignTx(account *Account, tx *Transaction, chainID *BigInt) (
// be decrypted with the given passphrase. The produced signature is in the
// be decrypted with the given passphrase. The produced signature is in the
// [R || S || V] format where V is 0 or 1.
// [R || S || V] format where V is 0 or 1.
func ( ks * KeyStore ) SignHashPassphrase ( account * Account , passphrase string , hash [ ] byte ) ( signature [ ] byte , _ error ) {
func ( ks * KeyStore ) SignHashPassphrase ( account * Account , passphrase string , hash [ ] byte ) ( signature [ ] byte , _ error ) {
return ks . keystore . SignHashWithPassphrase ( account . account , passphrase , hash )
return ks . keystore . SignHashWithPassphrase ( account . account , passphrase , common . CopyBytes ( hash ) )
}
}
// SignTxPassphrase signs the transaction if the private key matching the
// SignTxPassphrase signs the transaction if the private key matching the
@ -189,7 +190,7 @@ func (ks *KeyStore) ExportKey(account *Account, passphrase, newPassphrase string
// ImportKey stores the given encrypted JSON key into the key directory.
// ImportKey stores the given encrypted JSON key into the key directory.
func ( ks * KeyStore ) ImportKey ( keyJSON [ ] byte , passphrase , newPassphrase string ) ( account * Account , _ error ) {
func ( ks * KeyStore ) ImportKey ( keyJSON [ ] byte , passphrase , newPassphrase string ) ( account * Account , _ error ) {
acc , err := ks . keystore . Import ( keyJSON , passphrase , newPassphrase )
acc , err := ks . keystore . Import ( common . CopyBytes ( keyJSON ) , passphrase , newPassphrase )
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}
@ -198,7 +199,7 @@ func (ks *KeyStore) ImportKey(keyJSON []byte, passphrase, newPassphrase string)
// ImportECDSAKey stores the given encrypted JSON key into the key directory.
// ImportECDSAKey stores the given encrypted JSON key into the key directory.
func ( ks * KeyStore ) ImportECDSAKey ( key [ ] byte , passphrase string ) ( account * Account , _ error ) {
func ( ks * KeyStore ) ImportECDSAKey ( key [ ] byte , passphrase string ) ( account * Account , _ error ) {
privkey , err := crypto . ToECDSA ( key )
privkey , err := crypto . ToECDSA ( common . CopyBytes ( key ) )
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}
@ -212,7 +213,7 @@ func (ks *KeyStore) ImportECDSAKey(key []byte, passphrase string) (account *Acco
// ImportPreSaleKey decrypts the given Ethereum presale wallet and stores
// ImportPreSaleKey decrypts the given Ethereum presale wallet and stores
// a key file in the key directory. The key file is encrypted with the same passphrase.
// a key file in the key directory. The key file is encrypted with the same passphrase.
func ( ks * KeyStore ) ImportPreSaleKey ( keyJSON [ ] byte , passphrase string ) ( ccount * Account , _ error ) {
func ( ks * KeyStore ) ImportPreSaleKey ( keyJSON [ ] byte , passphrase string ) ( ccount * Account , _ error ) {
account , err := ks . keystore . ImportPreSaleKey ( keyJSON , passphrase )
account , err := ks . keystore . ImportPreSaleKey ( common . CopyBytes ( keyJSON ) , passphrase )
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}