aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-24 20:37:00 +0800
committerzelig <viktor.tron@gmail.com>2015-03-27 03:00:18 +0800
commitfd8d18ec280c3fe2c3d2651870c31c65b02039ba (patch)
treee079cd2306e48e8537b95e6c00730f611553a01e
parent859f1f08ca48de99408c825eba8d6ed4bfea3235 (diff)
downloaddexon-fd8d18ec280c3fe2c3d2651870c31c65b02039ba.tar
dexon-fd8d18ec280c3fe2c3d2651870c31c65b02039ba.tar.gz
dexon-fd8d18ec280c3fe2c3d2651870c31c65b02039ba.tar.bz2
dexon-fd8d18ec280c3fe2c3d2651870c31c65b02039ba.tar.lz
dexon-fd8d18ec280c3fe2c3d2651870c31c65b02039ba.tar.xz
dexon-fd8d18ec280c3fe2c3d2651870c31c65b02039ba.tar.zst
dexon-fd8d18ec280c3fe2c3d2651870c31c65b02039ba.zip
unlocking coinbase
- extract accounts.getKey method - if given empty address it retrieves coinbase (first account) - cli -unlock coinbase will unlock coinbase
-rw-r--r--accounts/account_manager.go15
-rw-r--r--cmd/ethereum/main.go5
2 files changed, 17 insertions, 3 deletions
diff --git a/accounts/account_manager.go b/accounts/account_manager.go
index 670d4337f..21ef46991 100644
--- a/accounts/account_manager.go
+++ b/accounts/account_manager.go
@@ -101,6 +101,17 @@ func (am *Manager) firstAddr() ([]byte, error) {
return addrs[0], nil
}
+func (am *Manager) getKey(addr []byte, keyAuth string) (*crypto.Key, error) {
+ if len(addr) == 0 {
+ var err error
+ addr, err = am.firstAddr()
+ if err != nil {
+ return nil, err
+ }
+ }
+ return am.keyStore.GetKey(addr, keyAuth)
+}
+
func (am *Manager) DeleteAccount(address []byte, auth string) error {
return am.keyStore.DeleteKey(address, auth)
}
@@ -119,7 +130,7 @@ func (am *Manager) Sign(a Account, toSign []byte) (signature []byte, err error)
// TimedUnlock unlocks the account with the given address.
// When timeout has passed, the account will be locked again.
func (am *Manager) TimedUnlock(addr []byte, keyAuth string, timeout time.Duration) error {
- key, err := am.keyStore.GetKey(addr, keyAuth)
+ key, err := am.getKey(addr, keyAuth)
if err != nil {
return err
}
@@ -132,7 +143,7 @@ func (am *Manager) TimedUnlock(addr []byte, keyAuth string, timeout time.Duratio
// stays unlocked until the program exits or until a TimedUnlock
// timeout (started after the call to Unlock) expires.
func (am *Manager) Unlock(addr []byte, keyAuth string) error {
- key, err := am.keyStore.GetKey(addr, keyAuth)
+ key, err := am.getKey(addr, keyAuth)
if err != nil {
return err
}
diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go
index 276480195..fea3fbf61 100644
--- a/cmd/ethereum/main.go
+++ b/cmd/ethereum/main.go
@@ -134,7 +134,7 @@ Exports the given account's private key into keyfile using the canonical EC form
The account needs to be unlocked, if it is not the user is prompted for a passphrase to unlock it.
For non-interactive use, the password can be specified with the --unlock flag:
- ethereum --unlock <passwrdfile> account export <address> <keyfile>
+ ethereum --password <passwrdfile> account export <address> <keyfile>
Note:
Since you can directly copy your encrypted accounts to another ethereum instance, this import/export mechanism is not needed when you transfer an account between nodes.
@@ -305,6 +305,9 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
account := ctx.GlobalString(utils.UnlockedAccountFlag.Name)
if len(account) > 0 {
+ if account == "coinbase" {
+ account = ""
+ }
unlockAccount(ctx, am, account)
}
// Start auxiliary services if enabled.