Merge branch 'master' into softforktrigger
This commit is contained in:
@@ -176,9 +176,10 @@ Virtual Machine Options:
|
||||
--jitvm Enable the JIT VM.
|
||||
|
||||
Legacy Options:
|
||||
--geth Run in Geth-compatibility mode. Currently just sets
|
||||
the IPC path to be the same as Geth's. Overrides
|
||||
the --ipc-path/--ipcpath options.
|
||||
--geth Run in Geth-compatibility mode. Sets the IPC path
|
||||
to be the same as Geth's. Overrides the --ipc-path
|
||||
and --ipcpath options. Alters RPCs to reflect Geth
|
||||
bugs.
|
||||
--testnet Geth-compatible testnet mode. Equivalent to --chain
|
||||
testnet --keys-path $HOME/parity/testnet-keys.
|
||||
Overrides the --keys-path option.
|
||||
|
||||
@@ -24,7 +24,7 @@ use docopt::Docopt;
|
||||
|
||||
use die::*;
|
||||
use util::*;
|
||||
use util::keys::store::{ImportKeySet, AccountService};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use util::network_settings::NetworkSettings;
|
||||
use ethcore::client::{append_path, get_db_path, ClientConfig, Switch, VMType};
|
||||
use ethcore::ethereum;
|
||||
@@ -255,7 +255,10 @@ impl Configuration {
|
||||
sync_config
|
||||
}
|
||||
|
||||
pub fn account_service(&self) -> AccountService {
|
||||
pub fn account_service(&self) -> AccountProvider {
|
||||
use ethcore::ethstore::{import_accounts, EthStore};
|
||||
use ethcore::ethstore::dir::{GethDirectory, DirectoryType, DiskDirectory};
|
||||
|
||||
// Secret Store
|
||||
let passwords = self.args.flag_password.iter().flat_map(|filename| {
|
||||
BufReader::new(&File::open(filename).unwrap_or_else(|_| die!("{} Unable to read password file. Ensure it exists and permissions are correct.", filename)))
|
||||
@@ -264,18 +267,30 @@ impl Configuration {
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
}).collect::<Vec<_>>();
|
||||
let import_keys = match (self.args.flag_no_import_keys, self.args.flag_testnet) {
|
||||
(true, _) => ImportKeySet::None,
|
||||
(false, false) => ImportKeySet::Legacy,
|
||||
(false, true) => ImportKeySet::LegacyTestnet,
|
||||
};
|
||||
let account_service = AccountService::with_security(Path::new(&self.keys_path()), self.keys_iterations(), import_keys);
|
||||
|
||||
if !self.args.flag_no_import_keys {
|
||||
let dir_type = match self.args.flag_testnet {
|
||||
true => DirectoryType::Testnet,
|
||||
false => DirectoryType::Main,
|
||||
};
|
||||
|
||||
let from = GethDirectory::open(dir_type);
|
||||
let to = DiskDirectory::create(self.keys_path()).unwrap();
|
||||
if let Err(e) = import_accounts(&from, &to) {
|
||||
warn!("Could not import accounts {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
let dir = Box::new(DiskDirectory::create(self.keys_path()).unwrap());
|
||||
let iterations = self.keys_iterations();
|
||||
let account_service = AccountProvider::new(Box::new(EthStore::open_with_iterations(dir, iterations).unwrap()));
|
||||
|
||||
if let Some(ref unlocks) = self.args.flag_unlock {
|
||||
for d in unlocks.split(',') {
|
||||
let a = Address::from_str(clean_0x(d)).unwrap_or_else(|_| {
|
||||
die!("{}: Invalid address for --unlock. Must be 40 hex characters, without the 0x at the beginning.", d)
|
||||
});
|
||||
if passwords.iter().find(|p| account_service.unlock_account_no_expire(&a, p).is_ok()).is_none() {
|
||||
if passwords.iter().find(|p| account_service.unlock_account_permanently(a, (*p).clone()).is_ok()).is_none() {
|
||||
die!("No password given to unlock account {}. Pass the password using `--password`.", a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,20 +18,17 @@ use std::sync::Arc;
|
||||
use ethcore::client::Client;
|
||||
use ethcore::service::{NetSyncMessage, SyncMessage};
|
||||
use ethsync::EthSync;
|
||||
use util::keys::store::AccountService;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use util::{TimerToken, IoHandler, IoContext, NetworkService, NetworkIoMessage};
|
||||
|
||||
use informant::Informant;
|
||||
|
||||
const INFO_TIMER: TimerToken = 0;
|
||||
|
||||
const ACCOUNT_TICK_TIMER: TimerToken = 10;
|
||||
const ACCOUNT_TICK_MS: u64 = 60000;
|
||||
|
||||
pub struct ClientIoHandler {
|
||||
pub client: Arc<Client>,
|
||||
pub sync: Arc<EthSync>,
|
||||
pub accounts: Arc<AccountService>,
|
||||
pub accounts: Arc<AccountProvider>,
|
||||
pub info: Informant,
|
||||
pub network: Arc<NetworkService<SyncMessage>>,
|
||||
}
|
||||
@@ -39,13 +36,11 @@ pub struct ClientIoHandler {
|
||||
impl IoHandler<NetSyncMessage> for ClientIoHandler {
|
||||
fn initialize(&self, io: &IoContext<NetSyncMessage>) {
|
||||
io.register_timer(INFO_TIMER, 5000).expect("Error registering timer");
|
||||
io.register_timer(ACCOUNT_TICK_TIMER, ACCOUNT_TICK_MS).expect("Error registering account timer");
|
||||
}
|
||||
|
||||
fn timeout(&self, _io: &IoContext<NetSyncMessage>, timer: TimerToken) {
|
||||
match timer {
|
||||
INFO_TIMER => { self.info.tick(&self.client, Some(&self.sync)); }
|
||||
ACCOUNT_TICK_TIMER => { self.accounts.tick(); },
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
external_miner: external_miner.clone(),
|
||||
logger: logger.clone(),
|
||||
settings: network_settings.clone(),
|
||||
allow_pending_receipt_query: !conf.args.flag_geth,
|
||||
});
|
||||
|
||||
let dependencies = rpc::Dependencies {
|
||||
@@ -477,9 +478,15 @@ fn execute_signer(conf: Configuration) {
|
||||
}
|
||||
|
||||
fn execute_account_cli(conf: Configuration) {
|
||||
use util::keys::store::SecretStore;
|
||||
use ethcore::ethstore::{SecretStore, EthStore, import_accounts};
|
||||
use ethcore::ethstore::dir::DiskDirectory;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use rpassword::read_password;
|
||||
let mut secret_store = SecretStore::with_security(Path::new(&conf.keys_path()), conf.keys_iterations());
|
||||
|
||||
let dir = Box::new(DiskDirectory::create(conf.keys_path()).unwrap());
|
||||
let iterations = conf.keys_iterations();
|
||||
let secret_store = AccountProvider::new(Box::new(EthStore::open_with_iterations(dir, iterations).unwrap()));
|
||||
|
||||
if conf.args.cmd_new {
|
||||
println!("Please note that password is NOT RECOVERABLE.");
|
||||
print!("Type password: ");
|
||||
@@ -497,15 +504,22 @@ fn execute_account_cli(conf: Configuration) {
|
||||
println!("{:?}", new_address);
|
||||
return;
|
||||
}
|
||||
|
||||
if conf.args.cmd_list {
|
||||
println!("Known addresses:");
|
||||
for &(addr, _) in &secret_store.accounts().unwrap() {
|
||||
for addr in &secret_store.accounts() {
|
||||
println!("{:?}", addr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if conf.args.cmd_import {
|
||||
let imported = util::keys::import_keys_paths(&mut secret_store, &conf.args.arg_path).unwrap();
|
||||
let to = DiskDirectory::create(conf.keys_path()).unwrap();
|
||||
let mut imported = 0;
|
||||
for path in &conf.args.arg_path {
|
||||
let from = DiskDirectory::at(path);
|
||||
imported += import_accounts(&from, &to).unwrap_or_else(|e| die!("Could not import accounts {}", e)).len();
|
||||
}
|
||||
println!("Imported {} keys", imported);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ use ethsync::EthSync;
|
||||
use ethcore::miner::{Miner, ExternalMiner};
|
||||
use ethcore::client::Client;
|
||||
use util::RotatingLogger;
|
||||
use util::keys::store::AccountService;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use util::network_settings::NetworkSettings;
|
||||
|
||||
#[cfg(feature="rpc")]
|
||||
@@ -83,11 +83,12 @@ pub struct Dependencies {
|
||||
pub signer_queue: Arc<ConfirmationsQueue>,
|
||||
pub client: Arc<Client>,
|
||||
pub sync: Arc<EthSync>,
|
||||
pub secret_store: Arc<AccountService>,
|
||||
pub secret_store: Arc<AccountProvider>,
|
||||
pub miner: Arc<Miner>,
|
||||
pub external_miner: Arc<ExternalMiner>,
|
||||
pub logger: Arc<RotatingLogger>,
|
||||
pub settings: Arc<NetworkSettings>,
|
||||
pub allow_pending_receipt_query: bool,
|
||||
}
|
||||
|
||||
fn to_modules(apis: &[Api]) -> BTreeMap<String, String> {
|
||||
@@ -143,7 +144,7 @@ pub fn setup_rpc<T: Extendable>(server: T, deps: Arc<Dependencies>, apis: ApiSet
|
||||
server.add_delegate(NetClient::new(&deps.sync).to_delegate());
|
||||
},
|
||||
Api::Eth => {
|
||||
server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner).to_delegate());
|
||||
server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner, deps.allow_pending_receipt_query).to_delegate());
|
||||
server.add_delegate(EthFilterClient::new(&deps.client, &deps.miner).to_delegate());
|
||||
|
||||
if deps.signer_port.is_some() {
|
||||
|
||||
Reference in New Issue
Block a user