5858 gitCommit string // set via linker flagg
5959 nodeNameVersion string
6060 app * cli.App
61-
62- ExtraDataFlag = cli.StringFlag {
63- Name : "extradata" ,
64- Usage : "Extra data for the miner" ,
65- }
6661)
6762
6863func init () {
@@ -176,8 +171,12 @@ It is safe to transfer the entire directory or the individual keys therein
176171between ethereum nodes by simply copying.
177172Make sure you backup your keys regularly.
178173
179- In order to use your account to send transactions, you need to unlock them using the
180- '--unlock' option. The argument is a comma
174+ In order to use your account to send transactions, you need to unlock them using
175+ the '--unlock' option. The argument is a space separated list of addresses or
176+ indexes. If used non-interactively with a passwordfile, the file should contain
177+ the respective passwords one per line. If you unlock n accounts and the password
178+ file contains less than n entries, then the last password is meant to apply to
179+ all remaining accounts.
181180
182181And finally. DO NOT FORGET YOUR PASSWORD.
183182` ,
@@ -227,7 +226,7 @@ format to the newest format or change the password for an account.
227226
228227For non-interactive use the passphrase can be specified with the --password flag:
229228
230- ethereum --password <passwordfile> account new
229+ ethereum --password <passwordfile> account update <address>
231230
232231Since only one password can be given, only format update can be performed,
233232changing your password is only possible interactively.
@@ -354,7 +353,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
354353 utils .GpobaseStepDownFlag ,
355354 utils .GpobaseStepUpFlag ,
356355 utils .GpobaseCorrectionFactorFlag ,
357- ExtraDataFlag ,
356+ utils . ExtraDataFlag ,
358357 }
359358 app .Before = func (ctx * cli.Context ) error {
360359 utils .SetupLogger (ctx )
@@ -380,8 +379,8 @@ func main() {
380379
381380// makeExtra resolves extradata for the miner from a flag or returns a default.
382381func makeExtra (ctx * cli.Context ) []byte {
383- if ctx .GlobalIsSet (ExtraDataFlag .Name ) {
384- return []byte (ctx .GlobalString (ExtraDataFlag .Name ))
382+ if ctx .GlobalIsSet (utils . ExtraDataFlag .Name ) {
383+ return []byte (ctx .GlobalString (utils . ExtraDataFlag .Name ))
385384 }
386385 return makeDefaultExtra ()
387386}
@@ -517,28 +516,29 @@ func execJSFiles(ctx *cli.Context) {
517516 ethereum .WaitForShutdown ()
518517}
519518
520- func unlockAccount (ctx * cli.Context , am * accounts.Manager , addr string , i int ) (addrHex , auth string ) {
521- utils .CheckLegalese (utils . MustDataDir ( ctx ))
519+ func unlockAccount (ctx * cli.Context , am * accounts.Manager , addr string , i int , inputpassphrases [] string ) (addrHex , auth string , passphrases [] string ) {
520+ utils .CheckLegalese (ctx . GlobalString ( utils . DataDirFlag . Name ))
522521
523522 var err error
523+ passphrases = inputpassphrases
524524 addrHex , err = utils .ParamToAddress (addr , am )
525525 if err == nil {
526526 // Attempt to unlock the account 3 times
527527 attempts := 3
528528 for tries := 0 ; tries < attempts ; tries ++ {
529529 msg := fmt .Sprintf ("Unlocking account %s | Attempt %d/%d" , addr , tries + 1 , attempts )
530- auth = getPassPhrase (ctx , msg , false , i )
530+ auth , passphrases = getPassPhrase (ctx , msg , false , i , passphrases )
531531 err = am .Unlock (common .HexToAddress (addrHex ), auth )
532- if err == nil {
532+ if err == nil || passphrases != nil {
533533 break
534534 }
535535 }
536536 }
537537
538538 if err != nil {
539- utils .Fatalf ("Unlock account failed '%v'" , err )
539+ utils .Fatalf ("Unlock account '%s' (%v) failed: %v" , addr , addrHex , err )
540540 }
541- fmt .Printf ("Account '%s' unlocked.\n " , addr )
541+ fmt .Printf ("Account '%s' (%v) unlocked.\n " , addr , addrHex )
542542 return
543543}
544544
@@ -582,12 +582,13 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
582582 am := eth .AccountManager ()
583583 account := ctx .GlobalString (utils .UnlockedAccountFlag .Name )
584584 accounts := strings .Split (account , " " )
585+ var passphrases []string
585586 for i , account := range accounts {
586587 if len (account ) > 0 {
587588 if account == "primary" {
588589 utils .Fatalf ("the 'primary' keyword is deprecated. You can use integer 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." )
589590 }
590- unlockAccount (ctx , am , account , i )
591+ _ , _ , passphrases = unlockAccount (ctx , am , account , i , passphrases )
591592 }
592593 }
593594 // Start auxiliary services if enabled.
@@ -624,7 +625,7 @@ func accountList(ctx *cli.Context) {
624625 }
625626}
626627
627- func getPassPhrase (ctx * cli.Context , desc string , confirmation bool , i int ) (passphrase string ) {
628+ func getPassPhrase (ctx * cli.Context , desc string , confirmation bool , i int , inputpassphrases [] string ) (passphrase string , passphrases [] string ) {
628629 passfile := ctx .GlobalString (utils .PasswordFileFlag .Name )
629630 if len (passfile ) == 0 {
630631 fmt .Println (desc )
@@ -644,14 +645,17 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool, i int) (pas
644645 passphrase = auth
645646
646647 } else {
647- passbytes , err := ioutil .ReadFile (passfile )
648- if err != nil {
649- utils .Fatalf ("Unable to read password file '%s': %v" , passfile , err )
648+ passphrases = inputpassphrases
649+ if passphrases == nil {
650+ passbytes , err := ioutil .ReadFile (passfile )
651+ if err != nil {
652+ utils .Fatalf ("Unable to read password file '%s': %v" , passfile , err )
653+ }
654+ // this is backwards compatible if the same password unlocks several accounts
655+ // it also has the consequence that trailing newlines will not count as part
656+ // of the password, so --password <(echo -n 'pass') will now work without -n
657+ passphrases = strings .Split (string (passbytes ), "\n " )
650658 }
651- // this is backwards compatible if the same password unlocks several accounts
652- // it also has the consequence that trailing newlines will not count as part
653- // of the password, so --password <(echo -n 'pass') will now work without -n
654- passphrases := strings .Split (string (passbytes ), "\n " )
655659 if i >= len (passphrases ) {
656660 passphrase = passphrases [len (passphrases )- 1 ]
657661 } else {
@@ -665,7 +669,7 @@ func accountCreate(ctx *cli.Context) {
665669 utils .CheckLegalese (utils .MustDataDir (ctx ))
666670
667671 am := utils .MakeAccountManager (ctx )
668- passphrase := getPassPhrase (ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 )
672+ passphrase , _ := getPassPhrase (ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 , nil )
669673 acct , err := am .NewAccount (passphrase )
670674 if err != nil {
671675 utils .Fatalf ("Could not create the account: %v" , err )
@@ -682,8 +686,8 @@ func accountUpdate(ctx *cli.Context) {
682686 utils .Fatalf ("account address or index must be given as argument" )
683687 }
684688
685- addr , authFrom := unlockAccount (ctx , am , arg , 0 )
686- authTo := getPassPhrase (ctx , "Please give a new password. Do not forget this password." , true , 0 )
689+ addr , authFrom , passphrases := unlockAccount (ctx , am , arg , 0 , nil )
690+ authTo , _ := getPassPhrase (ctx , "Please give a new password. Do not forget this password." , true , 0 , passphrases )
687691 err := am .Update (common .HexToAddress (addr ), authFrom , authTo )
688692 if err != nil {
689693 utils .Fatalf ("Could not update the account: %v" , err )
@@ -703,7 +707,7 @@ func importWallet(ctx *cli.Context) {
703707 }
704708
705709 am := utils .MakeAccountManager (ctx )
706- passphrase := getPassPhrase (ctx , "" , false , 0 )
710+ passphrase , _ := getPassPhrase (ctx , "" , false , 0 , nil )
707711
708712 acct , err := am .ImportPreSaleKey (keyJson , passphrase )
709713 if err != nil {
@@ -720,7 +724,7 @@ func accountImport(ctx *cli.Context) {
720724 utils .Fatalf ("keyfile must be given as argument" )
721725 }
722726 am := utils .MakeAccountManager (ctx )
723- passphrase := getPassPhrase (ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 )
727+ passphrase , _ := getPassPhrase (ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 , nil )
724728 acct , err := am .Import (keyfile , passphrase )
725729 if err != nil {
726730 utils .Fatalf ("Could not create the account: %v" , err )
0 commit comments