Allow unlocking multiple accounts #1045

Separate accounts with spaces when using --unlock
This commit is contained in:
Taylor Gerring 2015-05-19 13:40:41 -05:00
parent 46d6470c43
commit af8ada45e7

View File

@ -364,11 +364,12 @@ func execJSFiles(ctx *cli.Context) {
func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (passphrase string) { func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (passphrase string) {
var err error var err error
// Load startup keys. XXX we are going to need a different format // 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 { if len(account) == 0 {
utils.Fatalf("Invalid account address '%s'", account) utils.Fatalf("Invalid account address '%s'", account)
} }
// Attempt to unlock the account
passphrase = getPassPhrase(ctx, "Unlocking account "+account, false)
err = am.Unlock(common.HexToAddress(account), passphrase) err = am.Unlock(common.HexToAddress(account), passphrase)
if err != nil { if err != nil {
utils.Fatalf("Unlock account failed '%v'", err) utils.Fatalf("Unlock account failed '%v'", err)
@ -384,6 +385,8 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
am := eth.AccountManager() am := eth.AccountManager()
account := ctx.GlobalString(utils.UnlockedAccountFlag.Name) account := ctx.GlobalString(utils.UnlockedAccountFlag.Name)
accounts := strings.Split(account, " ")
for _, account := range accounts {
if len(account) > 0 { if len(account) > 0 {
if account == "primary" { if account == "primary" {
primaryAcc, err := am.Primary() primaryAcc, err := am.Primary()
@ -394,6 +397,7 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
} }
unlockAccount(ctx, am, account) unlockAccount(ctx, am, account)
} }
}
// Start auxiliary services if enabled. // Start auxiliary services if enabled.
if ctx.GlobalBool(utils.RPCEnabledFlag.Name) { if ctx.GlobalBool(utils.RPCEnabledFlag.Name) {
if err := utils.StartRPC(eth, ctx); err != nil { if err := utils.StartRPC(eth, ctx); err != nil {