@ -58,11 +58,6 @@ var (
gitCommit string // set via linker flagg
gitCommit string // set via linker flagg
nodeNameVersion string
nodeNameVersion string
app * cli . App
app * cli . App
ExtraDataFlag = cli . StringFlag {
Name : "extradata" ,
Usage : "Extra data for the miner" ,
}
)
)
func init ( ) {
func init ( ) {
@ -176,8 +171,12 @@ It is safe to transfer the entire directory or the individual keys therein
between ethereum nodes by simply copying .
between ethereum nodes by simply copying .
Make sure you backup your keys regularly .
Make sure you backup your keys regularly .
In order to use your account to send transactions , you need to unlock them using the
In order to use your account to send transactions , you need to unlock them using
' -- unlock ' option . The argument is a comma
the ' -- unlock ' option . The argument is a space separated list of addresses or
indexes . If used non - interactively with a passwordfile , the file should contain
the respective passwords one per line . If you unlock n accounts and the password
file contains less than n entries , then the last password is meant to apply to
all remaining accounts .
And finally . DO NOT FORGET YOUR PASSWORD .
And finally . DO NOT FORGET YOUR PASSWORD .
` ,
` ,
@ -227,7 +226,7 @@ format to the newest format or change the password for an account.
For non - interactive use the passphrase can be specified with the -- password flag :
For non - interactive use the passphrase can be specified with the -- password flag :
ethereum -- password < passwordfile > account new
ethereum -- password < passwordfile > account update < address >
Since only one password can be given , only format update can be performed ,
Since only one password can be given , only format update can be performed ,
changing your password is only possible interactively .
changing your password is only possible interactively .
@ -354,7 +353,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils . GpobaseStepDownFlag ,
utils . GpobaseStepDownFlag ,
utils . GpobaseStepUpFlag ,
utils . GpobaseStepUpFlag ,
utils . GpobaseCorrectionFactorFlag ,
utils . GpobaseCorrectionFactorFlag ,
ExtraDataFlag ,
utils . ExtraDataFlag ,
}
}
app . Before = func ( ctx * cli . Context ) error {
app . Before = func ( ctx * cli . Context ) error {
utils . SetupLogger ( ctx )
utils . SetupLogger ( ctx )
@ -380,8 +379,8 @@ func main() {
// makeExtra resolves extradata for the miner from a flag or returns a default.
// makeExtra resolves extradata for the miner from a flag or returns a default.
func makeExtra ( ctx * cli . Context ) [ ] byte {
func makeExtra ( ctx * cli . Context ) [ ] byte {
if ctx . GlobalIsSet ( ExtraDataFlag . Name ) {
if ctx . GlobalIsSet ( utils . ExtraDataFlag . Name ) {
return [ ] byte ( ctx . GlobalString ( ExtraDataFlag . Name ) )
return [ ] byte ( ctx . GlobalString ( utils . ExtraDataFlag . Name ) )
}
}
return makeDefaultExtra ( )
return makeDefaultExtra ( )
}
}
@ -517,28 +516,29 @@ func execJSFiles(ctx *cli.Context) {
ethereum . WaitForShutdown ( )
ethereum . WaitForShutdown ( )
}
}
func unlockAccount ( ctx * cli . Context , am * accounts . Manager , addr string , i int ) ( addrHex , auth string ) {
func unlockAccount ( ctx * cli . Context , am * accounts . Manager , addr string , i int , inputpassphrases [ ] string ) ( addrHex , auth string , passphrases [ ] string ) {
utils . CheckLegalese ( utils . MustDataDir ( ctx ) )
utils . CheckLegalese ( ctx . GlobalString ( utils . DataDirFlag . Name ) )
var err error
var err error
passphrases = inputpassphrases
addrHex , err = utils . ParamToAddress ( addr , am )
addrHex , err = utils . ParamToAddress ( addr , am )
if err == nil {
if err == nil {
// Attempt to unlock the account 3 times
// Attempt to unlock the account 3 times
attempts := 3
attempts := 3
for tries := 0 ; tries < attempts ; tries ++ {
for tries := 0 ; tries < attempts ; tries ++ {
msg := fmt . Sprintf ( "Unlocking account %s | Attempt %d/%d" , addr , tries + 1 , attempts )
msg := fmt . Sprintf ( "Unlocking account %s | Attempt %d/%d" , addr , tries + 1 , attempts )
auth = getPassPhrase ( ctx , msg , false , i )
auth , passphrases = getPassPhrase ( ctx , msg , false , i , passphrases )
err = am . Unlock ( common . HexToAddress ( addrHex ) , auth )
err = am . Unlock ( common . HexToAddress ( addrHex ) , auth )
if err == nil {
if err == nil || passphrases != nil {
break
break
}
}
}
}
}
}
if err != nil {
if err != nil {
utils . Fatalf ( "Unlock account failed '%v'" , err )
utils . Fatalf ( "Unlock account '%s' (%v) failed: %v" , addr , addrHex , err )
}
}
fmt . Printf ( "Account '%s' unlocked.\n" , addr )
fmt . Printf ( "Account '%s' (%v) unlocked.\n" , addr , addrHex )
return
return
}
}
@ -582,12 +582,13 @@ 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 , " " )
accounts := strings . Split ( account , " " )
var passphrases [ ] string
for i , account := range accounts {
for i , account := range accounts {
if len ( account ) > 0 {
if len ( account ) > 0 {
if account == "primary" {
if account == "primary" {
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." )
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." )
}
}
unlockAccount ( ctx , am , account , i )
_ , _ , passphrases = unlockAccount ( ctx , am , account , i , passphrases )
}
}
}
}
// Start auxiliary services if enabled.
// Start auxiliary services if enabled.
@ -624,7 +625,7 @@ func accountList(ctx *cli.Context) {
}
}
}
}
func getPassPhrase ( ctx * cli . Context , desc string , confirmation bool , i int ) ( passphrase string ) {
func getPassPhrase ( ctx * cli . Context , desc string , confirmation bool , i int , inputpassphrases [ ] string ) ( passphrase string , passphrases [ ] string ) {
passfile := ctx . GlobalString ( utils . PasswordFileFlag . Name )
passfile := ctx . GlobalString ( utils . PasswordFileFlag . Name )
if len ( passfile ) == 0 {
if len ( passfile ) == 0 {
fmt . Println ( desc )
fmt . Println ( desc )
@ -644,6 +645,8 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool, i int) (pas
passphrase = auth
passphrase = auth
} else {
} else {
passphrases = inputpassphrases
if passphrases == nil {
passbytes , err := ioutil . ReadFile ( passfile )
passbytes , err := ioutil . ReadFile ( passfile )
if err != nil {
if err != nil {
utils . Fatalf ( "Unable to read password file '%s': %v" , passfile , err )
utils . Fatalf ( "Unable to read password file '%s': %v" , passfile , err )
@ -651,7 +654,8 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool, i int) (pas
// this is backwards compatible if the same password unlocks several accounts
// this is backwards compatible if the same password unlocks several accounts
// it also has the consequence that trailing newlines will not count as part
// it also has the consequence that trailing newlines will not count as part
// of the password, so --password <(echo -n 'pass') will now work without -n
// of the password, so --password <(echo -n 'pass') will now work without -n
passphrases := strings . Split ( string ( passbytes ) , "\n" )
passphrases = strings . Split ( string ( passbytes ) , "\n" )
}
if i >= len ( passphrases ) {
if i >= len ( passphrases ) {
passphrase = passphrases [ len ( passphrases ) - 1 ]
passphrase = passphrases [ len ( passphrases ) - 1 ]
} else {
} else {
@ -665,7 +669,7 @@ func accountCreate(ctx *cli.Context) {
utils . CheckLegalese ( utils . MustDataDir ( ctx ) )
utils . CheckLegalese ( utils . MustDataDir ( ctx ) )
am := utils . MakeAccountManager ( ctx )
am := utils . MakeAccountManager ( ctx )
passphrase := getPassPhrase ( ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 )
passphrase , _ := getPassPhrase ( ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 , nil )
acct , err := am . NewAccount ( passphrase )
acct , err := am . NewAccount ( passphrase )
if err != nil {
if err != nil {
utils . Fatalf ( "Could not create the account: %v" , err )
utils . Fatalf ( "Could not create the account: %v" , err )
@ -682,8 +686,8 @@ func accountUpdate(ctx *cli.Context) {
utils . Fatalf ( "account address or index must be given as argument" )
utils . Fatalf ( "account address or index must be given as argument" )
}
}
addr , authFrom := unlockAccount ( ctx , am , arg , 0 )
addr , authFrom , passphrases := unlockAccount ( ctx , am , arg , 0 , nil )
authTo := getPassPhrase ( ctx , "Please give a new password. Do not forget this password." , true , 0 )
authTo , _ := getPassPhrase ( ctx , "Please give a new password. Do not forget this password." , true , 0 , passphrases )
err := am . Update ( common . HexToAddress ( addr ) , authFrom , authTo )
err := am . Update ( common . HexToAddress ( addr ) , authFrom , authTo )
if err != nil {
if err != nil {
utils . Fatalf ( "Could not update the account: %v" , err )
utils . Fatalf ( "Could not update the account: %v" , err )
@ -703,7 +707,7 @@ func importWallet(ctx *cli.Context) {
}
}
am := utils . MakeAccountManager ( ctx )
am := utils . MakeAccountManager ( ctx )
passphrase := getPassPhrase ( ctx , "" , false , 0 )
passphrase , _ := getPassPhrase ( ctx , "" , false , 0 , nil )
acct , err := am . ImportPreSaleKey ( keyJson , passphrase )
acct , err := am . ImportPreSaleKey ( keyJson , passphrase )
if err != nil {
if err != nil {
@ -720,7 +724,7 @@ func accountImport(ctx *cli.Context) {
utils . Fatalf ( "keyfile must be given as argument" )
utils . Fatalf ( "keyfile must be given as argument" )
}
}
am := utils . MakeAccountManager ( ctx )
am := utils . MakeAccountManager ( ctx )
passphrase := getPassPhrase ( ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 )
passphrase , _ := getPassPhrase ( ctx , "Your new account is locked with a password. Please give a password. Do not forget this password." , true , 0 , nil )
acct , err := am . Import ( keyfile , passphrase )
acct , err := am . Import ( keyfile , passphrase )
if err != nil {
if err != nil {
utils . Fatalf ( "Could not create the account: %v" , err )
utils . Fatalf ( "Could not create the account: %v" , err )