diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-05-23 20:17:46 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-05-23 20:17:46 +0800 |
commit | 7f515b0e88d864c8ef272c16ea51a1f17e3472d1 (patch) | |
tree | 45aa901ac6c44596859cf1c5731f5592a607d7cc /accounts/account_manager.go | |
parent | b4dd3209b29870d58f5ba60831005ccdd9ea0f79 (diff) | |
parent | 64a6c2c1b6c81fddccc7d3d728b7a05c5814124b (diff) | |
download | dexon-7f515b0e88d864c8ef272c16ea51a1f17e3472d1.tar dexon-7f515b0e88d864c8ef272c16ea51a1f17e3472d1.tar.gz dexon-7f515b0e88d864c8ef272c16ea51a1f17e3472d1.tar.bz2 dexon-7f515b0e88d864c8ef272c16ea51a1f17e3472d1.tar.lz dexon-7f515b0e88d864c8ef272c16ea51a1f17e3472d1.tar.xz dexon-7f515b0e88d864c8ef272c16ea51a1f17e3472d1.tar.zst dexon-7f515b0e88d864c8ef272c16ea51a1f17e3472d1.zip |
Merge pull request #2564 from bas-vk/submit-tx
eth: add new RPC method (personal.) SignAndSendTransaction
Diffstat (limited to 'accounts/account_manager.go')
-rw-r--r-- | accounts/account_manager.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/accounts/account_manager.go b/accounts/account_manager.go index 3afadf6b2..bfb7556d6 100644 --- a/accounts/account_manager.go +++ b/accounts/account_manager.go @@ -147,9 +147,21 @@ func (am *Manager) Sign(addr common.Address, hash []byte) (signature []byte, err return crypto.Sign(hash, unlockedKey.PrivateKey) } +// SignWithPassphrase signs hash if the private key matching the given address can be +// decrypted with the given passphrase. +func (am *Manager) SignWithPassphrase(addr common.Address, passphrase string, hash []byte) (signature []byte, err error) { + _, key, err := am.getDecryptedKey(Account{Address: addr}, passphrase) + if err != nil { + return nil, err + } + + defer zeroKey(key.PrivateKey) + return crypto.Sign(hash, key.PrivateKey) +} + // Unlock unlocks the given account indefinitely. -func (am *Manager) Unlock(a Account, keyAuth string) error { - return am.TimedUnlock(a, keyAuth, 0) +func (am *Manager) Unlock(a Account, passphrase string) error { + return am.TimedUnlock(a, passphrase, 0) } // Lock removes the private key with the given address from memory. |