@@ -153,9 +153,12 @@ Note that exporting your key in unencrypted format is NOT supported.
153153
154154Keys are stored under <DATADIR>/keys.
155155It is safe to transfer the entire directory or the individual keys therein
156- between ethereum nodes.
156+ between ethereum nodes by simply copying .
157157Make sure you backup your keys regularly.
158158
159+ In order to use your account to send transactions, you need to unlock them using the
160+ '--unlock' option. The argument is a comma
161+
159162And finally. DO NOT FORGET YOUR PASSWORD.
160163` ,
161164 Subcommands : []cli.Command {
@@ -430,7 +433,7 @@ func execJSFiles(ctx *cli.Context) {
430433 ethereum .WaitForShutdown ()
431434}
432435
433- func unlockAccount (ctx * cli.Context , am * accounts.Manager , account string ) ( passphrase string ) {
436+ func unlockAccount (ctx * cli.Context , am * accounts.Manager , account string , i int ) {
434437 var err error
435438 // Load startup keys. XXX we are going to need a different format
436439
@@ -441,7 +444,7 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass
441444 attempts := 3
442445 for tries := 0 ; tries < attempts ; tries ++ {
443446 msg := fmt .Sprintf ("Unlocking account %s | Attempt %d/%d" , account , tries + 1 , attempts )
444- passphrase = getPassPhrase (ctx , msg , false )
447+ passphrase : = getPassPhrase (ctx , msg , false , i )
445448 err = am .Unlock (common .HexToAddress (account ), passphrase )
446449 if err == nil {
447450 break
@@ -451,7 +454,6 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass
451454 utils .Fatalf ("Unlock account failed '%v'" , err )
452455 }
453456 fmt .Printf ("Account '%s' unlocked.\n " , account )
454- return
455457}
456458
457459func blockRecovery (ctx * cli.Context ) {
@@ -492,16 +494,12 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
492494
493495 account := ctx .GlobalString (utils .UnlockedAccountFlag .Name )
494496 accounts := strings .Split (account , " " )
495- for _ , account := range accounts {
497+ for i , account := range accounts {
496498 if len (account ) > 0 {
497499 if account == "primary" {
498- primaryAcc , err := am .Primary ()
499- if err != nil {
500- utils .Fatalf ("no primary account: %v" , err )
501- }
502- account = primaryAcc .Hex ()
500+ utils .Fatalf ("the 'primary' keyword is deprecated. You can use indexes, but the indexes are not permanent, they can change if you add external keys, export your keys or copy your keystore to another node." )
503501 }
504- unlockAccount (ctx , am , account )
502+ unlockAccount (ctx , am , account , i )
505503 }
506504 }
507505 // Start auxiliary services if enabled.
@@ -535,7 +533,7 @@ func accountList(ctx *cli.Context) {
535533 }
536534}
537535
538- func getPassPhrase (ctx * cli.Context , desc string , confirmation bool ) (passphrase string ) {
536+ func getPassPhrase (ctx * cli.Context , desc string , confirmation bool , i int ) (passphrase string ) {
539537 passfile := ctx .GlobalString (utils .PasswordFileFlag .Name )
540538 if len (passfile ) == 0 {
541539 fmt .Println (desc )
@@ -559,14 +557,22 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool) (passphrase
559557 if err != nil {
560558 utils .Fatalf ("Unable to read password file '%s': %v" , passfile , err )
561559 }
562- passphrase = string (passbytes )
560+ // this is backwards compatible if the same password unlocks several accounts
561+ // it also has the consequence that trailing newlines will not count as part
562+ // of the password, so --password <(echo -n 'pass') will now work without -n
563+ passphrases := strings .Split (string (passbytes ), "\n " )
564+ if i >= len (passphrases ) {
565+ passphrase = passphrases [len (passphrases )- 1 ]
566+ } else {
567+ passphrase = passphrases [i ]
568+ }
563569 }
564570 return
565571}
566572
567573func accountCreate (ctx * cli.Context ) {
568574 am := utils .MakeAccountManager (ctx )
569- passphrase := getPassPhrase (ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true )
575+ passphrase := getPassPhrase (ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 )
570576 acct , err := am .NewAccount (passphrase )
571577 if err != nil {
572578 utils .Fatalf ("Could not create the account: %v" , err )
@@ -585,7 +591,7 @@ func importWallet(ctx *cli.Context) {
585591 }
586592
587593 am := utils .MakeAccountManager (ctx )
588- passphrase := getPassPhrase (ctx , "" , false )
594+ passphrase := getPassPhrase (ctx , "" , false , 0 )
589595
590596 acct , err := am .ImportPreSaleKey (keyJson , passphrase )
591597 if err != nil {
@@ -600,7 +606,7 @@ func accountImport(ctx *cli.Context) {
600606 utils .Fatalf ("keyfile must be given as argument" )
601607 }
602608 am := utils .MakeAccountManager (ctx )
603- passphrase := getPassPhrase (ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true )
609+ passphrase := getPassPhrase (ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 )
604610 acct , err := am .Import (keyfile , passphrase )
605611 if err != nil {
606612 utils .Fatalf ("Could not create the account: %v" , err )
0 commit comments