Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
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
Miguel Montes
nucleo
Commits
0c21660d
Commit
0c21660d
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Changes to allow us to unlock locked keys
parent
526ad7f5
No related branches found
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
+115
-0
115 additions, 0 deletions
bin/unlock.js
with
115 additions
and
0 deletions
bin/unlock.js
0 → 100755
+
115
−
0
View file @
0c21660d
#!/usr/bin/node
const
Libbfa
=
require
(
process
.
env
.
BFAHOME
+
'
/bin/libbfa.js
'
);
const
bfa
=
new
Libbfa
();
const
rl
=
require
(
'
readline
'
).
createInterface
(
{
input
:
process
.
stdin
,
output
:
process
.
stdout
}
);
var
web3
=
bfa
.
newweb3
();
// First time we try to unlock, we will use this empty passphrase.
var
passphrase
=
""
;
function
atLeastOneFailedSoGetNewPass
(
x
)
{
if
(
!
process
.
stdin
.
isTTY
)
bye
(
0
,
"
Stdin is not a tty. Will not try with other passwords.
"
);
rl
.
question
(
"
Enter another password to try:
"
,
(
answer
)
=>
{
passphrase
=
answer
;
if
(
answer
==
""
)
bye
(
0
,
"
Bye.
"
);
unlockall
();
}
);
}
function
bye
(
exitcode
,
msg
)
{
console
.
log
(
msg
);
rl
.
close
();
process
.
exit
(
exitcode
);
}
function
pluralEnglish
(
num
,
single
,
plural
)
{
if
(
num
==
1
)
return
single
;
return
plural
;
}
function
unlockall
()
{
var
wallets
=
new
Array
();
web3
.
eth
.
personal
.
bfalistWallets
()
.
then
(
function
pushone
(
x
)
{
var
failures
=
0
;
var
promises
=
new
Array
();
var
i
=
x
.
length
;
while
(
i
--
>
0
)
if
(
x
[
i
].
status
==
"
Locked
"
)
wallets
.
push
(
x
[
i
]
);
i
=
wallets
.
length
;
if
(
i
==
0
)
bye
(
0
,
"
List of accounts to unlock is empty.
"
);
while
(
i
--
>
0
)
{
var
j
=
wallets
[
i
].
accounts
.
length
;
while
(
j
--
>
0
)
{
var
addr
=
wallets
[
i
].
accounts
[
j
].
address
;
//console.log( "Trying to unlock " + addr + "." );
var
promise
=
web3
.
eth
.
personal
.
unlockAccount
(
addr
,
passphrase
,
0
)
.
catch
(
error
=>
{
failures
++
;
return
error
;
}
);
promises
.
push
(
promise
);
}
}
var
empty
=
""
;
if
(
passphrase
==
""
)
empty
=
"
with an empty passphrase
"
;
console
.
log
(
"
Attempting to unlock
"
+
promises
.
length
+
"
account
"
+
pluralEnglish
(
promises
.
length
,
""
,
"
s
"
)
+
empty
+
"
.
"
);
Promise
.
all
(
promises
)
.
then
(
function
(
x
)
{
if
(
failures
==
0
)
bye
(
0
,
"
OK.
"
);
console
.
log
(
failures
+
"
account
"
+
pluralEnglish
(
failures
,
"
is
"
,
"
s are
"
)
+
"
still locked.
"
);
atLeastOneFailedSoGetNewPass
();
},
function
(
x
)
{
console
.
log
(
x
);
bye
(
1
,
"
I can't imagine this text will ever be shown.
"
);
}
);
},
function
errWalletList
(
x
)
{
bye
(
1
,
x
);
}
)
}
web3
.
eth
.
personal
.
extend
({
methods
:
[{
name
:
'
bfalistWallets
'
,
call
:
'
personal_listWallets
'
,
params
:
0
}]
});
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