Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parity-test-sync
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
parity-test-sync
Commits
ebd9eb17
Commit
ebd9eb17
authored
8 years ago
by
Arkadiy Paronyan
Browse files
Options
Downloads
Plain Diff
Merge pull request #871 from rphmeier/geth_keystore
Find geth data store cross-platform.
parents
8c447dcc
2f02b433
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
util/src/keys/geth_import.rs
+32
-0
32 additions, 0 deletions
util/src/keys/geth_import.rs
util/src/keys/store.rs
+2
-6
2 additions, 6 deletions
util/src/keys/store.rs
with
34 additions
and
6 deletions
util/src/keys/geth_import.rs
+
32
−
0
View file @
ebd9eb17
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
use
common
::
*
;
use
common
::
*
;
use
keys
::
store
::
SecretStore
;
use
keys
::
store
::
SecretStore
;
use
keys
::
directory
::
KeyFileContent
;
use
keys
::
directory
::
KeyFileContent
;
use
std
::
path
::
PathBuf
;
/// Enumerates all geth keys in the directory and returns collection of tuples `(accountId, filename)`
/// Enumerates all geth keys in the directory and returns collection of tuples `(accountId, filename)`
pub
fn
enumerate_geth_keys
(
path
:
&
Path
)
->
Result
<
Vec
<
(
Address
,
String
)
>
,
ImportError
>
{
pub
fn
enumerate_geth_keys
(
path
:
&
Path
)
->
Result
<
Vec
<
(
Address
,
String
)
>
,
ImportError
>
{
...
@@ -92,6 +93,37 @@ pub fn import_geth_keys(secret_store: &mut SecretStore, geth_keyfiles_directory:
...
@@ -92,6 +93,37 @@ pub fn import_geth_keys(secret_store: &mut SecretStore, geth_keyfiles_directory:
Ok
(())
Ok
(())
}
}
/// Gets the default geth keystore directory.
///
/// Based on https://github.com/ethereum/go-ethereum/blob/e553215/common/path.go#L75
pub
fn
keystore_dir
()
->
PathBuf
{
#[cfg(target_os
=
"macos"
)]
fn
data_dir
(
mut
home
:
PathBuf
)
->
PathBuf
{
home
.push
(
"Library"
);
home
.push
(
"Ethereum"
);
home
}
#[cfg(windows)]
fn
data_dir
(
mut
home
:
PathBuf
)
->
PathBuf
{
home
.push
(
"AppData"
);
home
.push
(
"Roaming"
);
home
.push
(
"Ethereum"
);
home
}
#[cfg(not(any(target_os
=
"macos"
,
windows)))]
fn
data_dir
(
mut
home
:
PathBuf
)
->
PathBuf
{
home
.push
(
".ethereum"
);
home
}
let
mut
data_dir
=
data_dir
(::
std
::
env
::
home_dir
()
.expect
(
"Failed to get home dir"
));
data_dir
.push
(
"keystore"
);
data_dir
}
#[cfg(test)]
#[cfg(test)]
mod
tests
{
mod
tests
{
use
super
::
*
;
use
super
::
*
;
...
...
This diff is collapsed.
Click to expand it.
util/src/keys/store.rs
+
2
−
6
View file @
ebd9eb17
...
@@ -150,7 +150,7 @@ impl AccountService {
...
@@ -150,7 +150,7 @@ impl AccountService {
self
.secret_store
.write
()
.unwrap
()
.collect_garbage
();
self
.secret_store
.write
()
.unwrap
()
.collect_garbage
();
}
}
/// Unlocks account for use (no expiration of unlock)
/// Unlocks account for use (no expiration of unlock)
pub
fn
unlock_account_no_expire
(
&
self
,
account
:
&
Address
,
pass
:
&
str
)
->
Result
<
(),
EncryptedHashMapError
>
{
pub
fn
unlock_account_no_expire
(
&
self
,
account
:
&
Address
,
pass
:
&
str
)
->
Result
<
(),
EncryptedHashMapError
>
{
self
.secret_store
.write
()
.unwrap
()
.unlock_account_with_expiration
(
account
,
pass
,
None
)
self
.secret_store
.write
()
.unwrap
()
.unlock_account_with_expiration
(
account
,
pass
,
None
)
}
}
...
@@ -183,13 +183,9 @@ impl SecretStore {
...
@@ -183,13 +183,9 @@ impl SecretStore {
/// trys to import keys in the known locations
/// trys to import keys in the known locations
pub
fn
try_import_existing
(
&
mut
self
)
{
pub
fn
try_import_existing
(
&
mut
self
)
{
use
std
::
path
::
PathBuf
;
use
keys
::
geth_import
;
use
keys
::
geth_import
;
let
mut
import_path
=
PathBuf
::
new
();
let
import_path
=
geth_import
::
keystore_dir
();
import_path
.push
(::
std
::
env
::
home_dir
()
.expect
(
"Failed to get home dir"
));
import_path
.push
(
".ethereum"
);
import_path
.push
(
"keystore"
);
if
let
Err
(
e
)
=
geth_import
::
import_geth_keys
(
self
,
&
import_path
)
{
if
let
Err
(
e
)
=
geth_import
::
import_geth_keys
(
self
,
&
import_path
)
{
trace!
(
target
:
"sstore"
,
"Geth key not imported: {:?}"
,
e
);
trace!
(
target
:
"sstore"
,
"Geth key not imported: {:?}"
,
e
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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