diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-20 06:11:20 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-05-20 06:11:20 +0800 |
commit | b14ee6ce16c44b5ab5215380d51ffa919a5d0be3 (patch) | |
tree | a0f1f714e89761b00a50de1940da14fe1ff9cb20 | |
parent | 87a05c8f38dd34728e4375dee51fcd20da1048ec (diff) | |
parent | 32b8565022d7d6ccb437769b5ed68121c5c34657 (diff) | |
download | dexon-b14ee6ce16c44b5ab5215380d51ffa919a5d0be3.tar dexon-b14ee6ce16c44b5ab5215380d51ffa919a5d0be3.tar.gz dexon-b14ee6ce16c44b5ab5215380d51ffa919a5d0be3.tar.bz2 dexon-b14ee6ce16c44b5ab5215380d51ffa919a5d0be3.tar.lz dexon-b14ee6ce16c44b5ab5215380d51ffa919a5d0be3.tar.xz dexon-b14ee6ce16c44b5ab5215380d51ffa919a5d0be3.tar.zst dexon-b14ee6ce16c44b5ab5215380d51ffa919a5d0be3.zip |
Merge pull request #1046 from tgerring/issue1045
Allow unlocking multiple accounts
-rw-r--r-- | cmd/geth/main.go | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index df0af3e79..2afc92f10 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -364,12 +364,20 @@ func execJSFiles(ctx *cli.Context) { func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (passphrase string) { var err error // Load startup keys. XXX we are going to need a different format - // Attempt to unlock the account - passphrase = getPassPhrase(ctx, "", false) + if len(account) == 0 { utils.Fatalf("Invalid account address '%s'", account) } - err = am.Unlock(common.HexToAddress(account), passphrase) + // Attempt to unlock the account 3 times + attempts := 3 + for tries := 0; tries < attempts; tries++ { + msg := fmt.Sprintf("Unlocking account %s...%s | Attempt %d/%d", account[:8], account[len(account)-6:], tries+1, attempts) + passphrase = getPassPhrase(ctx, msg, false) + err = am.Unlock(common.HexToAddress(account), passphrase) + if err == nil { + break + } + } if err != nil { utils.Fatalf("Unlock account failed '%v'", err) } @@ -384,15 +392,18 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) { am := eth.AccountManager() account := ctx.GlobalString(utils.UnlockedAccountFlag.Name) - if len(account) > 0 { - if account == "primary" { - primaryAcc, err := am.Primary() - if err != nil { - utils.Fatalf("no primary account: %v", err) + accounts := strings.Split(account, " ") + for _, account := range accounts { + if len(account) > 0 { + if account == "primary" { + primaryAcc, err := am.Primary() + if err != nil { + utils.Fatalf("no primary account: %v", err) + } + account = primaryAcc.Hex() } - account = primaryAcc.Hex() + unlockAccount(ctx, am, account) } - unlockAccount(ctx, am, account) } // Start auxiliary services if enabled. if ctx.GlobalBool(utils.RPCEnabledFlag.Name) { |