good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
dd37064a
Commit
dd37064a
authored
Apr 12, 2017
by
Victor Farazdagi
Committed by
Felix Lange
Apr 12, 2017
Browse files
Options
Downloads
Patches
Plain Diff
cmd/swarm: add --password (#3748)
parent
9de25750
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/swarm/main.go
+18
-6
18 additions, 6 deletions
cmd/swarm/main.go
with
18 additions
and
6 deletions
cmd/swarm/main.go
+
18
−
6
View file @
dd37064a
...
@@ -237,6 +237,7 @@ Cleans database of corrupted entries.
...
@@ -237,6 +237,7 @@ Cleans database of corrupted entries.
utils
.
IPCDisabledFlag
,
utils
.
IPCDisabledFlag
,
utils
.
IPCApiFlag
,
utils
.
IPCApiFlag
,
utils
.
IPCPathFlag
,
utils
.
IPCPathFlag
,
utils
.
PasswordFileFlag
,
// bzzd-specific flags
// bzzd-specific flags
CorsStringFlag
,
CorsStringFlag
,
EthAPIFlag
,
EthAPIFlag
,
...
@@ -368,10 +369,10 @@ func getAccount(ctx *cli.Context, stack *node.Node) *ecdsa.PrivateKey {
...
@@ -368,10 +369,10 @@ func getAccount(ctx *cli.Context, stack *node.Node) *ecdsa.PrivateKey {
am
:=
stack
.
AccountManager
()
am
:=
stack
.
AccountManager
()
ks
:=
am
.
Backends
(
keystore
.
KeyStoreType
)[
0
]
.
(
*
keystore
.
KeyStore
)
ks
:=
am
.
Backends
(
keystore
.
KeyStoreType
)[
0
]
.
(
*
keystore
.
KeyStore
)
return
decryptStoreAccount
(
ks
,
keyid
)
return
decryptStoreAccount
(
ks
,
keyid
,
utils
.
MakePasswordList
(
ctx
)
)
}
}
func
decryptStoreAccount
(
ks
*
keystore
.
KeyStore
,
account
string
)
*
ecdsa
.
PrivateKey
{
func
decryptStoreAccount
(
ks
*
keystore
.
KeyStore
,
account
string
,
passwords
[]
string
)
*
ecdsa
.
PrivateKey
{
var
a
accounts
.
Account
var
a
accounts
.
Account
var
err
error
var
err
error
if
common
.
IsHexAddress
(
account
)
{
if
common
.
IsHexAddress
(
account
)
{
...
@@ -392,9 +393,9 @@ func decryptStoreAccount(ks *keystore.KeyStore, account string) *ecdsa.PrivateKe
...
@@ -392,9 +393,9 @@ func decryptStoreAccount(ks *keystore.KeyStore, account string) *ecdsa.PrivateKe
if
err
!=
nil
{
if
err
!=
nil
{
utils
.
Fatalf
(
"Can't load swarm account key: %v"
,
err
)
utils
.
Fatalf
(
"Can't load swarm account key: %v"
,
err
)
}
}
for
i
:=
1
;
i
<
=
3
;
i
++
{
for
i
:=
0
;
i
<
3
;
i
++
{
pass
phrase
:=
promp
tPass
p
hrase
(
fmt
.
Sprintf
(
"Unlocking swarm account %s [%d/3]"
,
a
.
Address
.
Hex
(),
i
)
)
pass
word
:=
ge
tPass
P
hrase
(
fmt
.
Sprintf
(
"Unlocking swarm account %s [%d/3]"
,
a
.
Address
.
Hex
(),
i
+
1
),
i
,
passwords
)
key
,
err
:=
keystore
.
DecryptKey
(
keyjson
,
pass
phrase
)
key
,
err
:=
keystore
.
DecryptKey
(
keyjson
,
pass
word
)
if
err
==
nil
{
if
err
==
nil
{
return
key
.
PrivateKey
return
key
.
PrivateKey
}
}
...
@@ -403,7 +404,18 @@ func decryptStoreAccount(ks *keystore.KeyStore, account string) *ecdsa.PrivateKe
...
@@ -403,7 +404,18 @@ func decryptStoreAccount(ks *keystore.KeyStore, account string) *ecdsa.PrivateKe
return
nil
return
nil
}
}
func
promptPassphrase
(
prompt
string
)
string
{
// getPassPhrase retrieves the password associated with bzz account, either by fetching
// from a list of pre-loaded passwords, or by requesting it interactively from user.
func
getPassPhrase
(
prompt
string
,
i
int
,
passwords
[]
string
)
string
{
// non-interactive
if
len
(
passwords
)
>
0
{
if
i
<
len
(
passwords
)
{
return
passwords
[
i
]
}
return
passwords
[
len
(
passwords
)
-
1
]
}
// fallback to interactive mode
if
prompt
!=
""
{
if
prompt
!=
""
{
fmt
.
Println
(
prompt
)
fmt
.
Println
(
prompt
)
}
}
...
...
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