Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blockchain
nucleo
Commits
a10f02d8
Commit
a10f02d8
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
unlock.js no longer echo back the typed passphrase.
parent
e9837ab5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/unlock.js
+35
-24
35 additions, 24 deletions
bin/unlock.js
with
35 additions
and
24 deletions
bin/unlock.js
+
35
−
24
View file @
a10f02d8
#!/usr/bin/node
#!/usr/bin/node
const
Libbfa
=
require
(
process
.
env
.
BFAHOME
+
'
/bin/libbfa.js
'
);
const
Libbfa
=
require
(
process
.
env
.
BFAHOME
+
'
/bin/libbfa.js
'
);
const
bfa
=
new
Libbfa
();
const
bfa
=
new
Libbfa
();
const
rl
=
require
(
'
readline
'
).
createInterface
(
const
Writable
=
require
(
'
stream
'
).
Writable
;
{
input
:
process
.
stdin
,
output
:
process
.
stdout
}
var
mutableStdout
=
new
Writable
(
);
{
var
web3
=
bfa
.
newweb3
();
write
:
function
(
chunk
,
encoding
,
callback
)
{
if
(
!
this
.
muted
)
process
.
stdout
.
write
(
chunk
,
encoding
);
callback
();
}
}
);
mutableStdout
.
muted
=
false
;
const
rl
=
require
(
'
readline
'
).
createInterface
(
{
input
:
process
.
stdin
,
output
:
mutableStdout
,
terminal
:
true
,
historySize
:
0
}
);
var
web3
=
bfa
.
newweb3
();
// First time we try to unlock, we will use this empty passphrase.
// First time we try to unlock, we will use this empty passphrase.
// Do not edit.
var
passphrase
=
""
;
var
passphrase
=
""
;
function
atLeastOneFailedSoGetNewPass
(
x
)
function
atLeastOneFailedSoGetNewPass
(
x
)
{
{
if
(
!
process
.
stdin
.
isTTY
)
if
(
!
process
.
stdin
.
isTTY
)
bye
(
0
,
"
Stdin is not a tty. Will not try with other passwords.
"
);
bye
(
0
,
"
Stdin is not a tty. Will not try with other passwords.
"
);
// first we print the question
mutableStdout
.
muted
=
false
;
rl
.
question
(
rl
.
question
(
"
Enter another password to try:
"
,
"
Enter another password to try:
"
,
(
answer
)
=>
{
(
answer
)
=>
{
passphrase
=
answer
;
process
.
stdout
.
write
(
"
\n
"
);
mutableStdout
.
muted
=
false
;
passphrase
=
answer
;
if
(
answer
==
""
)
if
(
answer
==
""
)
bye
(
0
,
"
Bye.
"
);
bye
(
0
,
"
Bye.
"
);
unlockall
();
unlockall
();
}
}
);
);
// Asking the question is an async event, so
// we set the object to mute output while the
// user types his password.
mutableStdout
.
muted
=
true
;
}
}
function
bye
(
exitcode
,
msg
)
function
bye
(
exitcode
,
msg
)
...
@@ -31,13 +56,6 @@ function bye( exitcode, msg )
...
@@ -31,13 +56,6 @@ function bye( exitcode, msg )
process
.
exit
(
exitcode
);
process
.
exit
(
exitcode
);
}
}
function
pluralEnglish
(
num
,
single
,
plural
)
{
if
(
num
==
1
)
return
single
;
return
plural
;
}
function
unlockall
()
function
unlockall
()
{
{
var
wallets
=
new
Array
();
var
wallets
=
new
Array
();
...
@@ -61,7 +79,7 @@ function unlockall()
...
@@ -61,7 +79,7 @@ function unlockall()
{
{
var
addr
=
wallets
[
i
].
accounts
[
j
].
address
;
var
addr
=
wallets
[
i
].
accounts
[
j
].
address
;
//console.log( "Trying to unlock " + addr + "." );
//console.log( "Trying to unlock " + addr + "." );
var
promise
=
var
promise
=
web3
.
eth
.
personal
.
unlockAccount
(
addr
,
passphrase
,
0
)
web3
.
eth
.
personal
.
unlockAccount
(
addr
,
passphrase
,
0
)
.
catch
(
.
catch
(
error
=>
error
=>
...
@@ -79,7 +97,7 @@ function unlockall()
...
@@ -79,7 +97,7 @@ function unlockall()
console
.
log
(
console
.
log
(
"
Attempting to unlock
"
"
Attempting to unlock
"
+
promises
.
length
+
promises
.
length
+
"
account
"
+
pluralEnglish
(
promises
.
length
,
""
,
"
s
"
)
+
"
account
"
+
(
promises
.
length
==
1
?
''
:
'
s
'
)
+
empty
+
"
.
"
+
empty
+
"
.
"
);
);
Promise
.
all
(
promises
)
Promise
.
all
(
promises
)
...
@@ -88,7 +106,7 @@ function unlockall()
...
@@ -88,7 +106,7 @@ function unlockall()
{
{
if
(
failures
==
0
)
if
(
failures
==
0
)
bye
(
0
,
"
OK.
"
);
bye
(
0
,
"
OK.
"
);
console
.
log
(
failures
+
"
account
"
+
pluralEnglish
(
failures
,
"
is
"
,
"
s are
"
)
+
"
still locked.
"
);
console
.
log
(
failures
+
"
account
"
+
(
failures
==
1
?
"
is
"
:
"
s are
"
)
+
"
still locked.
"
);
atLeastOneFailedSoGetNewPass
();
atLeastOneFailedSoGetNewPass
();
},
},
function
(
x
)
function
(
x
)
...
@@ -105,11 +123,4 @@ function unlockall()
...
@@ -105,11 +123,4 @@ function unlockall()
)
)
}
}
web3
.
eth
.
personal
.
extend
({
methods
:
[{
name
:
'
bfalistWallets
'
,
call
:
'
personal_listWallets
'
,
params
:
0
}]
});
unlockall
();
unlockall
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment