Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
0fd251c7
Commit
0fd251c7
authored
Mar 08, 2016
by
Bas van Kervel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
console: allow optional password on the command line
parent
848e50d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
jeth.go
cmd/utils/jeth.go
+15
-9
No files found.
cmd/utils/jeth.go
View file @
0fd251c7
...
...
@@ -58,7 +58,7 @@ func (self *Jeth) err(call otto.FunctionCall, code int, msg string, id *int64) (
// UnlockAccount asks the user for the password and than executes the jeth.UnlockAccount callback in the jsre
func
(
self
*
Jeth
)
UnlockAccount
(
call
otto
.
FunctionCall
)
(
response
otto
.
Value
)
{
var
cmd
,
account
,
passwd
string
var
account
,
passwd
string
timeout
:=
int64
(
300
)
var
ok
bool
...
...
@@ -92,8 +92,7 @@ func (self *Jeth) UnlockAccount(call otto.FunctionCall) (response otto.Value) {
}
}
cmd
=
fmt
.
Sprintf
(
"jeth.unlockAccount('%s', '%s', %d)"
,
account
,
passwd
,
timeout
)
if
val
,
err
:=
call
.
Otto
.
Run
(
cmd
);
err
==
nil
{
if
val
,
err
:=
call
.
Otto
.
Call
(
"jeth.unlockAccount"
,
nil
,
account
,
passwd
,
timeout
);
err
==
nil
{
return
val
}
...
...
@@ -102,8 +101,10 @@ func (self *Jeth) UnlockAccount(call otto.FunctionCall) (response otto.Value) {
// NewAccount asks the user for the password and than executes the jeth.newAccount callback in the jsre
func
(
self
*
Jeth
)
NewAccount
(
call
otto
.
FunctionCall
)
(
response
otto
.
Value
)
{
var
passwd
string
if
len
(
call
.
ArgumentList
)
==
0
{
passwd
,
err
:=
PromptPassword
(
"Passphrase: "
,
true
)
var
err
error
passwd
,
err
=
PromptPassword
(
"Passphrase: "
,
true
)
if
err
!=
nil
{
return
otto
.
FalseValue
()
}
...
...
@@ -116,13 +117,18 @@ func (self *Jeth) NewAccount(call otto.FunctionCall) (response otto.Value) {
fmt
.
Println
(
"Passphrases don't match"
)
return
otto
.
FalseValue
()
}
}
else
if
len
(
call
.
ArgumentList
)
==
1
&&
call
.
Argument
(
0
)
.
IsString
()
{
passwd
,
_
=
call
.
Argument
(
0
)
.
ToString
()
}
else
{
fmt
.
Println
(
"expected 0 or 1 string argument"
)
return
otto
.
FalseValue
()
}
cmd
:=
fmt
.
Sprintf
(
"jeth.newAccount('%s')"
,
passwd
)
if
val
,
err
:=
call
.
Otto
.
Run
(
cmd
);
err
==
nil
{
return
val
}
if
ret
,
err
:=
call
.
Otto
.
Call
(
"jeth.newAccount"
,
nil
,
passwd
);
err
==
nil
{
return
ret
}
else
{
fmt
.
Println
(
"New account doesn't expect argument(s), you will be prompted for a password"
)
fmt
.
Printf
(
"%v
\n
"
,
err
)
return
otto
.
FalseValue
()
}
return
otto
.
FalseValue
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment