removing extra crate

This commit is contained in:
Nikolay Volf 2016-02-24 09:55:09 +03:00
parent bceafe9094
commit 5bd355e0af
9 changed files with 26 additions and 55 deletions

View File

@ -1,13 +0,0 @@
[package]
description = "Ethcore Ethereum tools"
homepage = "http://ethcore.io"
license = "GPL-3.0"
name = "ethtools"
version = "0.9.99"
authors = ["Ethcore <admin@ethcore.io>"]
[dependencies]
ethcore-util = { path = "../util" }
rustc-serialize = "0.3"
ethcore-devtools = { path = "../devtools" }
log = "0.3"

View File

@ -1 +0,0 @@
# ethtools

View File

@ -1,24 +0,0 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
//! Ethereum Tools Library
extern crate ethcore_util as util;
extern crate rustc_serialize;
extern crate ethcore_devtools as devtools;
#[macro_use] extern crate log;
pub mod geth_keys;

View File

@ -618,6 +618,8 @@ impl KeyDirectory {
Err(_) => Err(KeyFileLoadError::ParseError(KeyFileParseError::InvalidJson)) Err(_) => Err(KeyFileLoadError::ParseError(KeyFileParseError::InvalidJson))
} }
} }
} }

View File

@ -16,16 +16,9 @@
//! Geth keys import/export tool //! Geth keys import/export tool
use util::hash::*; use common::*;
use util::keys::store::SecretStore; use keys::store::SecretStore;
use util::keys::directory::KeyFileContent; use keys::directory::KeyFileContent;
use std::path::{Path, PathBuf};
use std::result::*;
use std::fs;
use std::str::FromStr;
use std::io;
use std::io::Read;
use rustc_serialize::json::Json;
/// 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)>, io::Error> { pub fn enumerate_geth_keys(path: &Path) -> Result<Vec<(Address, String)>, io::Error> {
@ -86,6 +79,7 @@ pub fn import_geth_key(secret_store: &mut SecretStore, geth_keyfile_path: &Path)
/// Imports all geth keys in the directory /// Imports all geth keys in the directory
pub fn import_geth_keys(secret_store: &mut SecretStore, geth_keyfiles_directory: &Path) -> Result<(), ImportError> { pub fn import_geth_keys(secret_store: &mut SecretStore, geth_keyfiles_directory: &Path) -> Result<(), ImportError> {
use std::path::PathBuf;
let geth_files = try!(enumerate_geth_keys(geth_keyfiles_directory)); let geth_files = try!(enumerate_geth_keys(geth_keyfiles_directory));
for &(ref address, ref file_path) in geth_files.iter() { for &(ref address, ref file_path) in geth_files.iter() {
let mut path = PathBuf::new(); let mut path = PathBuf::new();
@ -101,10 +95,9 @@ pub fn import_geth_keys(secret_store: &mut SecretStore, geth_keyfiles_directory:
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::path::Path; use common::*;
use util::hash::*; use keys::store::SecretStore;
use util::keys::store::SecretStore;
use std::str::FromStr;
#[test] #[test]
fn can_enumerate() { fn can_enumerate() {
@ -136,7 +129,7 @@ mod tests {
#[test] #[test]
fn imports_as_scrypt_keys() { fn imports_as_scrypt_keys() {
use util::keys::directory::{KeyDirectory, KeyFileKdf}; use keys::directory::{KeyDirectory, KeyFileKdf};
let temp = ::devtools::RandomTempPath::create_dir(); let temp = ::devtools::RandomTempPath::create_dir();
{ {
let mut secret_store = SecretStore::new_in(temp.as_path()); let mut secret_store = SecretStore::new_in(temp.as_path());
@ -158,8 +151,7 @@ mod tests {
#[test] #[test]
fn can_decrypt_with_imported() { fn can_decrypt_with_imported() {
use util::keys::store::EncryptedHashMap; use keys::store::EncryptedHashMap;
use util::bytes::*;
let temp = ::devtools::RandomTempPath::create_dir(); let temp = ::devtools::RandomTempPath::create_dir();
let mut secret_store = SecretStore::new_in(temp.as_path()); let mut secret_store = SecretStore::new_in(temp.as_path());

View File

@ -18,3 +18,4 @@
pub mod directory; pub mod directory;
pub mod store; pub mod store;
mod geth_import;

View File

@ -75,6 +75,20 @@ impl SecretStore {
} }
} }
/// trys to import keys in the known locations
pub fn try_import_existing(&mut self) {
use std::path::PathBuf;
use keys::geth_import;
let mut import_path = PathBuf::new();
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) {
warn!(target: "sstore", "Error retrieving geth keys: {:?}", e)
}
}
/// Lists all accounts and corresponding key ids /// Lists all accounts and corresponding key ids
pub fn accounts(&self) -> Result<Vec<(Address, H128)>, ::std::io::Error> { pub fn accounts(&self) -> Result<Vec<(Address, H128)>, ::std::io::Error> {
let accounts = try!(self.directory.list()).iter().map(|key_id| self.directory.get(key_id)) let accounts = try!(self.directory.list()).iter().map(|key_id| self.directory.get(key_id))