Remove deprecated flags

This commit is contained in:
Artem Vorotnikov 2020-08-07 20:36:32 +03:00
parent 7dfa57999b
commit 751210c963
No known key found for this signature in database
GPG Key ID: E0148C3F2FBB7A20
33 changed files with 63 additions and 1457 deletions

View File

@ -166,8 +166,6 @@ fn main() {
fn key_dir(location: &str, password: Option<Password>) -> Result<Box<dyn KeyDirectory>, Error> {
let dir: RootDiskDirectory = match location {
"geth" => RootDiskDirectory::create(dir::geth(false))?,
"geth-test" => RootDiskDirectory::create(dir::geth(true))?,
path if path.starts_with("parity") => {
let chain = path.split('-').nth(1).unwrap_or("ethereum");
let path = dir::parity(chain);

View File

@ -27,7 +27,6 @@ use accounts_dir::{KeyDirectory, SetKeyError, VaultKey, VaultKeyDirectory};
use ethkey::{
self, Address, ExtendedKeyPair, KeyPair, Message, Password, Public, Secret, Signature,
};
use import;
use json::{self, OpaqueKeyFile, Uuid};
use presale::PresaleWallet;
use random::Random;
@ -330,38 +329,6 @@ impl SecretStore for EthStore {
fn local_path(&self) -> PathBuf {
self.store.dir.path().cloned().unwrap_or_else(PathBuf::new)
}
fn list_geth_accounts(&self, testnet: bool) -> Vec<Address> {
import::read_geth_accounts(testnet)
}
fn import_geth_accounts(
&self,
vault: SecretVaultRef,
desired: Vec<Address>,
testnet: bool,
) -> Result<Vec<StoreAccountRef>, Error> {
let imported_addresses = match vault {
SecretVaultRef::Root => import::import_geth_accounts(
&*self.store.dir,
desired.into_iter().collect(),
testnet,
),
SecretVaultRef::Vault(vault_name) => {
if let Some(vault) = self.store.vaults.lock().get(&vault_name) {
import::import_geth_accounts(
vault.as_key_directory(),
desired.into_iter().collect(),
testnet,
)
} else {
Err(Error::VaultNotFound)
}
}
};
imported_addresses.map(|a| a.into_iter().map(|a| StoreAccountRef::root(a)).collect())
}
}
/// Similar to `EthStore` but may store many accounts (with different passwords) for the same `Address`

View File

@ -16,8 +16,7 @@
use std::{collections::HashSet, fs, path::Path};
use accounts_dir::{DiskKeyFileManager, KeyDirectory, KeyFileManager, RootDiskDirectory};
use dir;
use accounts_dir::{DiskKeyFileManager, KeyDirectory, KeyFileManager};
use ethkey::Address;
use Error;
@ -66,37 +65,3 @@ pub fn import_accounts(
})
.collect()
}
/// Provide a `HashSet` of all accounts available for import from the Geth keystore.
pub fn read_geth_accounts(testnet: bool) -> Vec<Address> {
RootDiskDirectory::at(dir::geth(testnet))
.load()
.map(|d| d.into_iter().map(|a| a.address).collect())
.unwrap_or_else(|_| Vec::new())
}
/// Import specific `desired` accounts from the Geth keystore into `dst`.
pub fn import_geth_accounts(
dst: &dyn KeyDirectory,
desired: HashSet<Address>,
testnet: bool,
) -> Result<Vec<Address>, Error> {
let src = RootDiskDirectory::at(dir::geth(testnet));
let accounts = src.load()?;
let existing_accounts = dst
.load()?
.into_iter()
.map(|a| a.address)
.collect::<HashSet<_>>();
accounts
.into_iter()
.filter(|a| !existing_accounts.contains(&a.address))
.filter(|a| desired.contains(&a.address))
.map(|a| {
let address = a.address.clone();
dst.insert(a)?;
Ok(address)
})
.collect()
}

View File

@ -64,7 +64,7 @@ pub use self::{
account::{Crypto, SafeAccount},
error::Error,
ethstore::{EthMultiStore, EthStore},
import::{import_account, import_accounts, read_geth_accounts},
import::{import_account, import_accounts},
json::OpaqueKeyFile as KeyFile,
parity_wordlist::random_phrase,
presale::PresaleWallet,

View File

@ -221,15 +221,6 @@ pub trait SecretStore: SimpleSecretStore {
/// Returns local path of the store.
fn local_path(&self) -> PathBuf;
/// Lists all found geth accounts.
fn list_geth_accounts(&self, testnet: bool) -> Vec<Address>;
/// Imports geth accounts to the store/vault.
fn import_geth_accounts(
&self,
vault: SecretVaultRef,
desired: Vec<Address>,
testnet: bool,
) -> Result<Vec<StoreAccountRef>, Error>;
}
impl StoreAccountRef {

View File

@ -572,27 +572,6 @@ impl AccountProvider {
Ok(self.sstore.agree(&account, &password, other_public)?)
}
/// Returns the underlying `SecretStore` reference if one exists.
pub fn list_geth_accounts(&self, testnet: bool) -> Vec<Address> {
self.sstore
.list_geth_accounts(testnet)
.into_iter()
.map(|a| Address::from(a).into())
.collect()
}
/// Returns the underlying `SecretStore` reference if one exists.
pub fn import_geth_accounts(
&self,
desired: Vec<Address>,
testnet: bool,
) -> Result<Vec<Address>, Error> {
self.sstore
.import_geth_accounts(SecretVaultRef::Root, desired, testnet)
.map(|a| a.into_iter().map(|a| a.address).collect())
.map_err(Into::into)
}
/// Create new vault.
pub fn create_vault(&self, name: &str, password: &Password) -> Result<(), Error> {
self.sstore.create_vault(name, password).map_err(Into::into)

View File

@ -22,7 +22,6 @@ pub enum AccountCmd {
New(NewAccount),
List(ListAccounts),
Import(ImportAccounts),
ImportFromGeth(ImportFromGethAccounts),
}
#[derive(Debug, PartialEq)]
@ -46,16 +45,6 @@ pub struct ImportAccounts {
pub spec: SpecType,
}
/// Parameters for geth accounts' import
#[derive(Debug, PartialEq)]
pub struct ImportFromGethAccounts {
/// import mainnet (false) or testnet (true) accounts
pub testnet: bool,
/// directory to import accounts to
pub to: String,
pub spec: SpecType,
}
#[cfg(not(feature = "accounts"))]
pub fn execute(_cmd: AccountCmd) -> Result<String, String> {
Err("Account management is deprecated. Please see #9997 for alternatives:\nhttps://github.com/paritytech/parity-ethereum/issues/9997".into())
@ -65,10 +54,7 @@ pub fn execute(_cmd: AccountCmd) -> Result<String, String> {
mod command {
use super::*;
use accounts::{AccountProvider, AccountProviderSettings};
use ethstore::{
accounts_dir::RootDiskDirectory, import_account, import_accounts, read_geth_accounts,
EthStore, SecretStore, SecretVaultRef,
};
use ethstore::{accounts_dir::RootDiskDirectory, import_account, import_accounts, EthStore};
use helpers::{password_from_file, password_prompt};
use std::path::PathBuf;
@ -77,7 +63,6 @@ mod command {
AccountCmd::New(new_cmd) => new(new_cmd),
AccountCmd::List(list_cmd) => list(list_cmd),
AccountCmd::Import(import_cmd) => import(import_cmd),
AccountCmd::ImportFromGeth(import_geth_cmd) => import_geth(import_geth_cmd),
}
}
@ -148,25 +133,6 @@ mod command {
Ok(format!("{} account(s) imported", imported))
}
fn import_geth(i: ImportFromGethAccounts) -> Result<String, String> {
use ethstore::Error;
use std::io::ErrorKind;
let dir = Box::new(keys_dir(i.to, i.spec)?);
let secret_store = Box::new(secret_store(dir, None)?);
let geth_accounts = read_geth_accounts(i.testnet);
match secret_store.import_geth_accounts(SecretVaultRef::Root, geth_accounts, i.testnet) {
Ok(v) => Ok(format!(
"Successfully imported {} account(s) from geth.",
v.len()
)),
Err(Error::Io(ref io_err)) if io_err.kind() == ErrorKind::NotFound => {
Err("Failed to find geth keys folder.".into())
}
Err(err) => Err(format!("Import geth accounts failed. {}", err)),
}
}
}
#[cfg(feature = "accounts")]

View File

@ -235,17 +235,6 @@ usage! {
{
"Print the hashed light clients headers of the given --chain (default: mainnet) in a JSON format. To be used as hardcoded headers in a genesis file.",
}
// CMD removed in 2.0
CMD cmd_dapp
{
"Manage dapps",
ARG arg_dapp_path: (Option<String>) = None,
"<PATH>",
"Path to the dapps",
}
}
{
// Global flags and arguments
@ -321,7 +310,7 @@ usage! {
["Convenience Options"]
FLAG flag_unsafe_expose: (bool) = false, or |c: &Config| c.misc.as_ref()?.unsafe_expose,
"--unsafe-expose",
"All servers will listen on external interfaces and will be remotely accessible. It's equivalent with setting the following: --[ws,jsonrpc,ipfs-api,secretstore,stratum,dapps,secretstore-http]-interface=all --*-hosts=all This option is UNSAFE and should be used with great care!",
"All servers will listen on external interfaces and will be remotely accessible. It's equivalent with setting the following: --[ws,jsonrpc,ipfs-api,secretstore,stratum,secretstore-http]-interface=all --*-hosts=all This option is UNSAFE and should be used with great care!",
ARG arg_config: (String) = "$BASE/config.toml", or |_| None,
"-c, --config=[CONFIG]",
@ -494,9 +483,9 @@ usage! {
"--jsonrpc-interface=[IP]",
"Specify the hostname portion of the HTTP JSON-RPC API server, IP should be an interface's IP address, or all (all interfaces) or local.",
ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,private,parity_pubsub,traces,rpc,shh,shh_pubsub", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
ARG arg_jsonrpc_apis: (String) = "web3,eth,pubsub,net,parity,private,parity_pubsub,traces,shh,shh_pubsub", or |c: &Config| c.rpc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--jsonrpc-apis=[APIS]",
"Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc, shh, shh_pubsub",
"Specify the APIs available through the HTTP JSON-RPC interface using a comma-delimited list of API names. Possible names are: all, safe, debug, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, shh, shh_pubsub",
ARG arg_jsonrpc_hosts: (String) = "none", or |c: &Config| c.rpc.as_ref()?.hosts.as_ref().map(|vec| vec.join(",")),
"--jsonrpc-hosts=[HOSTS]",
@ -535,9 +524,9 @@ usage! {
"--ws-interface=[IP]",
"Specify the hostname portion of the WebSockets JSON-RPC server, IP should be an interface's IP address, or all (all interfaces) or local.",
ARG arg_ws_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,private,traces,rpc,shh,shh_pubsub", or |c: &Config| c.websockets.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
ARG arg_ws_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,private,traces,shh,shh_pubsub", or |c: &Config| c.websockets.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--ws-apis=[APIS]",
"Specify the JSON-RPC APIs available through the WebSockets interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc, shh, shh_pubsub",
"Specify the JSON-RPC APIs available through the WebSockets interface using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, shh, shh_pubsub",
ARG arg_ws_origins: (String) = "parity://*,chrome-extension://*,moz-extension://*", or |c: &Config| c.websockets.as_ref()?.origins.as_ref().map(|vec| vec.join(",")),
"--ws-origins=[URL]",
@ -560,9 +549,9 @@ usage! {
"--ipc-path=[PATH]",
"Specify custom path for JSON-RPC over IPC service.",
ARG arg_ipc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,parity_accounts,private,traces,rpc,shh,shh_pubsub", or |c: &Config| c.ipc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
ARG arg_ipc_apis: (String) = "web3,eth,pubsub,net,parity,parity_pubsub,parity_accounts,private,traces,shh,shh_pubsub", or |c: &Config| c.ipc.as_ref()?.apis.as_ref().map(|vec| vec.join(",")),
"--ipc-apis=[APIS]",
"Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, rpc, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, rpc, shh, shh_pubsub",
"Specify custom API set available via JSON-RPC over IPC using a comma-delimited list of API names. Possible names are: all, safe, web3, net, eth, pubsub, personal, signer, parity, parity_pubsub, parity_accounts, parity_set, traces, secretstore, shh, shh_pubsub. You can also disable a specific API by putting '-' in the front, example: all,-personal. 'safe' enables the following APIs: web3, net, eth, pubsub, parity, parity_pubsub, traces, shh, shh_pubsub",
["API and Console Options IPFS"]
FLAG flag_ipfs_api: (bool) = false, or |c: &Config| c.ipfs.as_ref()?.enable.clone(),
@ -925,210 +914,6 @@ usage! {
ARG arg_whisper_pool_size: (usize) = 10usize, or |c: &Config| c.whisper.as_ref()?.pool_size.clone(),
"--whisper-pool-size=[MB]",
"Target size of the whisper message pool in megabytes.",
["Legacy Options"]
// Options that are hidden from config, but are still unique for its functionality.
FLAG flag_geth: (bool) = false, or |_| None,
"--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. Includes the personal_ RPC by default.",
FLAG flag_import_geth_keys: (bool) = false, or |_| None,
"--import-geth-keys",
"Attempt to import keys from Geth client.",
// Options that either do nothing, or are replaced by other options.
// FLAG Removed in 1.6 or before.
FLAG flag_warp: (bool) = false, or |_| None,
"--warp",
"Does nothing; warp sync is enabled by default. Use --no-warp to disable.",
FLAG flag_jsonrpc: (bool) = false, or |_| None,
"-j, --jsonrpc",
"Does nothing; HTTP JSON-RPC is on by default now.",
FLAG flag_rpc: (bool) = false, or |_| None,
"--rpc",
"Does nothing; HTTP JSON-RPC is on by default now.",
FLAG flag_jsonrpc_off: (bool) = false, or |_| None,
"--jsonrpc-off",
"Equivalent to --no-jsonrpc.",
FLAG flag_webapp: (bool) = false, or |_| None,
"-w, --webapp",
"Does nothing; dapps server has been removed.",
FLAG flag_dapps_off: (bool) = false, or |_| None,
"--dapps-off",
"Equivalent to --no-dapps.",
FLAG flag_ipcdisable: (bool) = false, or |_| None,
"--ipcdisable",
"Equivalent to --no-ipc.",
FLAG flag_ipc_off: (bool) = false, or |_| None,
"--ipc-off",
"Equivalent to --no-ipc.",
FLAG flag_testnet: (bool) = false, or |_| None,
"--testnet",
"Testnet mode. Equivalent to --chain testnet. Overrides the --keys-path option.",
FLAG flag_nodiscover: (bool) = false, or |_| None,
"--nodiscover",
"Equivalent to --no-discovery.",
// FLAG Removed in 1.7.
FLAG flag_dapps_apis_all: (bool) = false, or |_| None,
"--dapps-apis-all",
"Dapps server is merged with HTTP JSON-RPC server. Use --jsonrpc-apis.",
// FLAG Removed in 1.11.
FLAG flag_public_node: (bool) = false, or |_| None,
"--public-node",
"Does nothing; Public node is removed from Parity.",
FLAG flag_force_ui: (bool) = false, or |_| None,
"--force-ui",
"Does nothing; UI is now a separate project.",
FLAG flag_no_ui: (bool) = false, or |_| None,
"--no-ui",
"Does nothing; UI is now a separate project.",
FLAG flag_ui_no_validation: (bool) = false, or |_| None,
"--ui-no-validation",
"Does nothing; UI is now a separate project.",
// FLAG Removed in 2.0.
FLAG flag_fast_and_loose: (bool) = false, or |_| None,
"--fast-and-loose",
"Does nothing; DB WAL is always activated.",
FLAG flag_no_dapps: (bool) = false, or |c: &Config| c.dapps.as_ref()?._legacy_disable.clone(),
"--no-dapps",
"Disable the Dapps server (e.g. status page).",
// ARG Removed in 1.6 or before.
ARG arg_etherbase: (Option<String>) = None, or |_| None,
"--etherbase=[ADDRESS]",
"Equivalent to --author ADDRESS.",
ARG arg_extradata: (Option<String>) = None, or |_| None,
"--extradata=[STRING]",
"Equivalent to --extra-data STRING.",
ARG arg_datadir: (Option<String>) = None, or |_| None,
"--datadir=[PATH]",
"Equivalent to --base-path PATH.",
ARG arg_networkid: (Option<u64>) = None, or |_| None,
"--networkid=[INDEX]",
"Equivalent to --network-id INDEX.",
ARG arg_peers: (Option<u16>) = None, or |_| None,
"--peers=[NUM]",
"Equivalent to --min-peers NUM.",
ARG arg_nodekey: (Option<String>) = None, or |_| None,
"--nodekey=[KEY]",
"Equivalent to --node-key KEY.",
ARG arg_rpcaddr: (Option<String>) = None, or |_| None,
"--rpcaddr=[IP]",
"Equivalent to --jsonrpc-interface IP.",
ARG arg_rpcport: (Option<u16>) = None, or |_| None,
"--rpcport=[PORT]",
"Equivalent to --jsonrpc-port PORT.",
ARG arg_rpcapi: (Option<String>) = None, or |_| None,
"--rpcapi=[APIS]",
"Equivalent to --jsonrpc-apis APIS.",
ARG arg_rpccorsdomain: (Option<String>) = None, or |_| None,
"--rpccorsdomain=[URL]",
"Equivalent to --jsonrpc-cors URL.",
ARG arg_ipcapi: (Option<String>) = None, or |_| None,
"--ipcapi=[APIS]",
"Equivalent to --ipc-apis APIS.",
ARG arg_ipcpath: (Option<String>) = None, or |_| None,
"--ipcpath=[PATH]",
"Equivalent to --ipc-path PATH.",
ARG arg_gasprice: (Option<String>) = None, or |_| None,
"--gasprice=[WEI]",
"Equivalent to --min-gas-price WEI.",
ARG arg_cache: (Option<u32>) = None, or |_| None,
"--cache=[MB]",
"Equivalent to --cache-size MB.",
// ARG Removed in 1.7.
ARG arg_dapps_port: (Option<u16>) = None, or |c: &Config| c.dapps.as_ref()?._legacy_port.clone(),
"--dapps-port=[PORT]",
"Does nothing; dapps server has been removed.",
ARG arg_dapps_interface: (Option<String>) = None, or |c: &Config| c.dapps.as_ref()?._legacy_interface.clone(),
"--dapps-interface=[IP]",
"Does nothing; dapps server has been removed.",
ARG arg_dapps_hosts: (Option<String>) = None, or |c: &Config| c.dapps.as_ref()?._legacy_hosts.as_ref().map(|vec| vec.join(",")),
"--dapps-hosts=[HOSTS]",
"Does nothing; dapps server has been removed.",
ARG arg_dapps_cors: (Option<String>) = None, or |c: &Config| c.dapps.as_ref()?._legacy_cors.clone(),
"--dapps-cors=[URL]",
"Does nothing; dapps server has been removed.",
ARG arg_dapps_user: (Option<String>) = None, or |c: &Config| c.dapps.as_ref()?._legacy_user.clone(),
"--dapps-user=[USERNAME]",
"Dapps server authentication has been removed.",
ARG arg_dapps_pass: (Option<String>) = None, or |c: &Config| c.dapps.as_ref()?._legacy_pass.clone(),
"--dapps-pass=[PASSWORD]",
"Dapps server authentication has been removed.",
// ARG removed in 1.11.
ARG arg_ui_interface: (Option<String>) = None, or |_| None,
"--ui-interface=[IP]",
"Does nothing; UI is now a separate project.",
ARG arg_ui_hosts: (Option<String>) = None, or |_| None,
"--ui-hosts=[HOSTS]",
"Does nothing; UI is now a separate project.",
ARG arg_ui_port: (Option<u16>) = None, or |_| None,
"--ui-port=[PORT]",
"Does nothing; UI is now a separate project.",
ARG arg_tx_queue_ban_count: (Option<u16>) = None, or |c: &Config| c.mining.as_ref()?.tx_queue_ban_count.clone(),
"--tx-queue-ban-count=[C]",
"Not supported.",
ARG arg_tx_queue_ban_time: (Option<u16>) = None, or |c: &Config| c.mining.as_ref()?.tx_queue_ban_time.clone(),
"--tx-queue-ban-time=[SEC]",
"Not supported.",
// ARG removed in 2.0.
ARG arg_dapps_path: (Option<String>) = None, or |c: &Config| c.dapps.as_ref()?._legacy_path.clone(),
"--dapps-path=[PATH]",
"Specify directory where dapps should be installed.",
ARG arg_ntp_servers: (Option<String>) = None, or |_| None,
"--ntp-servers=[HOSTS]",
"Does nothing; checking if clock is sync with NTP servers is now done on the UI.",
}
}
@ -1142,7 +927,6 @@ struct Config {
rpc: Option<Rpc>,
websockets: Option<Ws>,
ipc: Option<Ipc>,
dapps: Option<Dapps>,
secretstore: Option<SecretStore>,
private_tx: Option<PrivateTransactions>,
ipfs: Option<Ipfs>,
@ -1175,9 +959,6 @@ struct Operating {
light: Option<bool>,
no_persistent_txqueue: Option<bool>,
no_hardcoded_sync: Option<bool>,
#[serde(rename = "public_node")]
_legacy_public_node: Option<bool>,
}
#[derive(Default, Debug, PartialEq, Deserialize)]
@ -1206,17 +987,6 @@ struct PrivateTransactions {
#[serde(deny_unknown_fields)]
struct Ui {
path: Option<String>,
#[serde(rename = "force")]
_legacy_force: Option<bool>,
#[serde(rename = "disable")]
_legacy_disable: Option<bool>,
#[serde(rename = "port")]
_legacy_port: Option<u16>,
#[serde(rename = "interface")]
_legacy_interface: Option<String>,
#[serde(rename = "hosts")]
_legacy_hosts: Option<Vec<String>>,
}
#[derive(Default, Debug, PartialEq, Deserialize)]
@ -1279,27 +1049,6 @@ struct Ipc {
apis: Option<Vec<String>>,
}
#[derive(Default, Debug, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
struct Dapps {
#[serde(rename = "disable")]
_legacy_disable: Option<bool>,
#[serde(rename = "port")]
_legacy_port: Option<u16>,
#[serde(rename = "interface")]
_legacy_interface: Option<String>,
#[serde(rename = "hosts")]
_legacy_hosts: Option<Vec<String>>,
#[serde(rename = "cors")]
_legacy_cors: Option<String>,
#[serde(rename = "path")]
_legacy_path: Option<String>,
#[serde(rename = "user")]
_legacy_user: Option<String>,
#[serde(rename = "pass")]
_legacy_pass: Option<String>,
}
#[derive(Default, Debug, PartialEq, Deserialize)]
#[serde(deny_unknown_fields)]
struct SecretStore {
@ -1435,8 +1184,8 @@ struct Light {
#[cfg(test)]
mod tests {
use super::{
Account, Args, ArgsError, Config, Dapps, Footprint, Ipc, Ipfs, Light, Mining, Misc,
Network, Operating, Rpc, SecretStore, Snapshots, Ui, Whisper, Ws,
Account, Args, ArgsError, Config, Footprint, Ipc, Ipfs, Light, Mining, Misc, Network,
Operating, Rpc, SecretStore, Snapshots, Whisper, Ws,
};
use clap::ErrorKind as ClapErrorKind;
use toml;
@ -1456,21 +1205,12 @@ mod tests {
assert_eq!(args.arg_chain, "dev");
}
#[test]
fn should_not_crash_on_warp() {
let args = Args::parse(&["parity", "--warp"]);
assert!(args.is_ok());
let args = Args::parse(&["parity", "account", "list", "--warp"]);
assert!(args.is_ok());
}
#[test]
fn should_reject_invalid_values() {
let args = Args::parse(&["parity", "--cache=20"]);
let args = Args::parse(&["parity", "--jsonrpc-port=8545"]);
assert!(args.is_ok());
let args = Args::parse(&["parity", "--cache=asd"]);
let args = Args::parse(&["parity", "--jsonrpc-port=asd"]);
assert!(args.is_err());
}
@ -1550,29 +1290,18 @@ mod tests {
"~/.safe/1",
"--password",
"~/.safe/2",
"--ui-port",
"8123",
])
.unwrap();
assert_eq!(
args.arg_password,
vec!["~/.safe/1".to_owned(), "~/.safe/2".to_owned()]
);
assert_eq!(args.arg_ui_port, Some(8123));
let args = Args::parse(&[
"parity",
"--password",
"~/.safe/1,~/.safe/2",
"--ui-port",
"8123",
])
.unwrap();
let args = Args::parse(&["parity", "--password", "~/.safe/1,~/.safe/2"]).unwrap();
assert_eq!(
args.arg_password,
vec!["~/.safe/1".to_owned(), "~/.safe/2".to_owned()]
);
assert_eq!(args.arg_ui_port, Some(8123));
}
#[test]
@ -1638,7 +1367,6 @@ mod tests {
args,
Args {
// Commands
cmd_dapp: false,
cmd_daemon: false,
cmd_account: false,
cmd_account_new: false,
@ -1678,7 +1406,6 @@ mod tests {
arg_signer_sign_id: None,
arg_signer_reject_id: None,
arg_dapp_path: None,
arg_account_import_path: None,
arg_wallet_import_path: None,
arg_db_reset_num: 10,
@ -1691,7 +1418,6 @@ mod tests {
arg_auto_update_delay: 200u16,
arg_auto_update_check_frequency: 50u16,
arg_release_track: "current".into(),
flag_public_node: false,
flag_no_download: false,
flag_no_consensus: false,
arg_chain: "xyz".into(),
@ -1725,13 +1451,7 @@ mod tests {
arg_private_sstore_url: Some("http://localhost:8082".into()),
arg_private_sstore_threshold: Some(0),
flag_force_ui: false,
flag_no_ui: false,
arg_ui_port: None,
arg_ui_interface: None,
arg_ui_hosts: None,
arg_ui_path: "$HOME/.parity/signer".into(),
flag_ui_no_validation: false,
// -- Networking Options
flag_no_warp: false,
@ -1751,6 +1471,7 @@ mod tests {
flag_reserved_only: false,
flag_no_ancient_blocks: false,
flag_no_serve_light: false,
arg_warp_barrier: None,
// -- API and Console Options
// RPC
@ -1760,7 +1481,7 @@ mod tests {
arg_jsonrpc_port: 8545u16,
arg_jsonrpc_interface: "local".into(),
arg_jsonrpc_cors: "null".into(),
arg_jsonrpc_apis: "web3,eth,net,parity,traces,rpc,secretstore".into(),
arg_jsonrpc_apis: "web3,eth,net,parity,traces,secretstore".into(),
arg_jsonrpc_hosts: "none".into(),
arg_jsonrpc_server_threads: None,
arg_jsonrpc_threads: 4,
@ -1772,7 +1493,7 @@ mod tests {
flag_no_ws: false,
arg_ws_port: 8546u16,
arg_ws_interface: "local".into(),
arg_ws_apis: "web3,eth,net,parity,traces,rpc,secretstore".into(),
arg_ws_apis: "web3,eth,net,parity,traces,secretstore".into(),
arg_ws_origins: "none".into(),
arg_ws_hosts: "none".into(),
arg_ws_max_connections: 100,
@ -1780,13 +1501,9 @@ mod tests {
// IPC
flag_no_ipc: false,
arg_ipc_path: "$HOME/.parity/jsonrpc.ipc".into(),
arg_ipc_apis: "web3,eth,net,parity,parity_accounts,personal,traces,rpc,secretstore"
arg_ipc_apis: "web3,eth,net,parity,parity_accounts,personal,traces,secretstore"
.into(),
// DAPPS
arg_dapps_path: Some("$HOME/.parity/dapps".into()),
flag_no_dapps: false,
// SECRETSTORE
flag_no_secretstore: false,
flag_no_secretstore_http: false,
@ -1841,8 +1558,6 @@ mod tests {
arg_tx_queue_mem_limit: 4u32,
arg_tx_queue_locals: Some("0xdeadbeefcafe0000000000000000000000000000".into()),
arg_tx_queue_strategy: "gas_factor".into(),
arg_tx_queue_ban_count: Some(1u16),
arg_tx_queue_ban_time: Some(180u16),
flag_remove_solved: false,
arg_notify_work: Some("http://localhost:3001".into()),
flag_refuse_service_transactions: false,
@ -1864,7 +1579,6 @@ mod tests {
arg_cache_size_queue: 50u32,
arg_cache_size_state: 25u32,
arg_cache_size: Some(128),
flag_fast_and_loose: false,
arg_db_compaction: "ssd".into(),
arg_fat_db: "auto".into(),
flag_scale_verifiers: true,
@ -1896,48 +1610,10 @@ mod tests {
flag_whisper: false,
arg_whisper_pool_size: 20,
// -- Legacy Options
flag_warp: false,
flag_geth: false,
flag_testnet: false,
flag_import_geth_keys: false,
arg_warp_barrier: None,
arg_datadir: None,
arg_networkid: None,
arg_peers: None,
arg_nodekey: None,
flag_nodiscover: false,
flag_jsonrpc: false,
flag_jsonrpc_off: false,
flag_webapp: false,
flag_dapps_off: false,
flag_rpc: false,
arg_rpcaddr: None,
arg_rpcport: None,
arg_rpcapi: None,
arg_rpccorsdomain: None,
flag_ipcdisable: false,
flag_ipc_off: false,
arg_ipcapi: None,
arg_ipcpath: None,
arg_gasprice: None,
arg_etherbase: None,
arg_extradata: None,
arg_cache: None,
// Legacy-Dapps
arg_dapps_port: Some(8080),
arg_dapps_interface: Some("local".into()),
arg_dapps_hosts: Some("none".into()),
arg_dapps_cors: None,
arg_dapps_user: Some("test_user".into()),
arg_dapps_pass: Some("test_pass".into()),
flag_dapps_apis_all: false,
// -- Internal Options
flag_can_restart: false,
// -- Miscellaneous Options
arg_ntp_servers: None,
flag_version: false,
arg_logging: Some("own_tx=trace".into()),
arg_log_file: Some("/var/log/parity.log".into()),
@ -1996,7 +1672,6 @@ mod tests {
light: None,
no_hardcoded_sync: None,
no_persistent_txqueue: None,
_legacy_public_node: None,
}),
account: Some(Account {
unlock: Some(vec!["0x1".into(), "0x2".into(), "0x3".into()]),
@ -2005,14 +1680,7 @@ mod tests {
refresh_time: None,
fast_unlock: None,
}),
ui: Some(Ui {
path: None,
_legacy_force: None,
_legacy_disable: Some(true),
_legacy_port: None,
_legacy_interface: None,
_legacy_hosts: None,
}),
ui: None,
network: Some(Network {
warp: Some(false),
warp_barrier: None,
@ -2061,16 +1729,6 @@ mod tests {
path: None,
apis: Some(vec!["rpc".into(), "eth".into()]),
}),
dapps: Some(Dapps {
_legacy_disable: None,
_legacy_port: Some(8080),
_legacy_path: None,
_legacy_interface: None,
_legacy_hosts: None,
_legacy_cors: None,
_legacy_user: Some("username".into()),
_legacy_pass: Some("password".into())
}),
secretstore: Some(SecretStore {
disable: None,
disable_http: None,

View File

@ -8,10 +8,6 @@ max_peers = 100
# You won't be able to use IPC to interact with Parity.
disable = true
[dapps]
# You won't be able to access any web Dapps.
disable = true
[mining]
# Prepare a block to seal even when there are no miners connected.
force_sealing = true

View File

@ -6,7 +6,6 @@ auto_update = "none"
auto_update_delay = 200
auto_update_check_frequency = 50
release_track = "current"
public_node = false
no_download = false
no_consensus = false
no_persistent_txqueue = false
@ -34,10 +33,6 @@ sstore_url = "http://localhost:8082"
sstore_threshold = 0
[ui]
force = false
disable = false
port = 8180
interface = "127.0.0.1"
path = "$HOME/.parity/signer"
[network]
@ -62,7 +57,7 @@ disable = false
port = 8545
interface = "local"
cors = ["null"]
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
apis = ["web3", "eth", "net", "parity", "traces", "secretstore"]
hosts = ["none"]
allow_missing_blocks = false
@ -71,23 +66,13 @@ disable = false
port = 8546
interface = "local"
origins = ["none"]
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
apis = ["web3", "eth", "net", "parity", "traces", "secretstore"]
hosts = ["none"]
[ipc]
disable = false
path = "$HOME/.parity/jsonrpc.ipc"
apis = ["web3", "eth", "net", "parity", "parity_accounts", "personal", "traces", "rpc", "secretstore"]
[dapps]
disable = false
port = 8080
interface = "local"
hosts = ["none"]
path = "$HOME/.parity/dapps"
# authorization:
user = "test_user"
pass = "test_pass"
apis = ["web3", "eth", "net", "parity", "parity_accounts", "personal", "traces", "secretstore"]
[secretstore]
disable = false

View File

@ -8,9 +8,6 @@ chain = "./chain.json"
unlock = ["0x1", "0x2", "0x3"]
password = ["passwdfile path"]
[ui]
disable = true
[network]
warp = false
discovery = true
@ -35,11 +32,6 @@ port = 8180
[ipc]
apis = ["rpc", "eth"]
[dapps]
port = 8080
user = "username"
pass = "password"
[secretstore]
http_port = 8082
port = 8083

View File

@ -41,7 +41,7 @@ use std::{
};
use sync::{self, validate_node_url, NetworkConfiguration};
use account::{AccountCmd, ImportAccounts, ImportFromGethAccounts, ListAccounts, NewAccount};
use account::{AccountCmd, ImportAccounts, ListAccounts, NewAccount};
use blockchain::{
BlockchainCmd, ExportBlockchain, ExportState, ImportBlockchain, KillBlockchain, ResetBlockchain,
};
@ -55,9 +55,8 @@ use ethcore_logger::Config as LogConfig;
use ethcore_private_tx::{EncryptorConfig, ProviderConfig};
use export_hardcoded_sync::ExportHsyncCmd;
use helpers::{
geth_ipc_path, parity_ipc_path, to_address, to_addresses, to_block_id, to_bootnodes,
to_duration, to_mode, to_pending_set, to_price, to_queue_penalization, to_queue_strategy,
to_u256,
parity_ipc_path, to_address, to_addresses, to_block_id, to_bootnodes, to_duration, to_mode,
to_pending_set, to_price, to_queue_penalization, to_queue_strategy, to_u256,
};
use ipfs::Configuration as IpfsConfiguration;
use network::IpFilter;
@ -162,7 +161,6 @@ impl Configuration {
let fat_db = self.args.arg_fat_db.parse()?;
let compaction = self.args.arg_db_compaction.parse()?;
let warp_sync = !self.args.flag_no_warp;
let geth_compatibility = self.args.flag_geth;
let experimental_rpcs = self.args.flag_jsonrpc_experimental;
let ipfs_conf = self.ipfs_config();
let secretstore_conf = self.secretstore_config()?;
@ -258,13 +256,6 @@ impl Configuration {
unreachable!();
};
Cmd::Account(account_cmd)
} else if self.args.flag_import_geth_keys {
let account_cmd = AccountCmd::ImportFromGeth(ImportFromGethAccounts {
spec: spec,
to: dirs.keys,
testnet: self.args.flag_testnet,
});
Cmd::Account(account_cmd)
} else if self.args.cmd_wallet {
let presale_cmd = ImportWallet {
iterations: keys_iterations,
@ -442,7 +433,6 @@ impl Configuration {
vm_type: vm_type,
warp_sync: warp_sync,
warp_barrier: self.args.arg_warp_barrier,
geth_compatibility: geth_compatibility,
experimental_rpcs,
net_settings: self.network_settings()?,
ipfs_conf: ipfs_conf,
@ -502,12 +492,7 @@ impl Configuration {
}
fn author(&self) -> Result<Address, String> {
to_address(
self.args
.arg_etherbase
.clone()
.or(self.args.arg_author.clone()),
)
to_address(self.args.arg_author.clone())
}
fn engine_signer(&self) -> Result<Address, String> {
@ -528,7 +513,7 @@ impl Configuration {
}
fn cache_config(&self) -> CacheConfig {
match self.args.arg_cache_size.or(self.args.arg_cache) {
match self.args.arg_cache_size {
Some(size) => CacheConfig::new_with_total_cache_size(size),
None => CacheConfig::new(
self.args.arg_cache_size_db,
@ -553,13 +538,7 @@ impl Configuration {
}
fn chain(&self) -> Result<SpecType, String> {
let name = if self.args.flag_testnet {
"testnet".to_owned()
} else {
self.args.arg_chain.clone()
};
Ok(name.parse()?)
Ok(self.args.arg_chain.parse()?)
}
fn is_dev_chain(&self) -> Result<bool, String> {
@ -608,7 +587,7 @@ impl Configuration {
let cfg = AccountsConfig {
iterations: keys_iterations,
refresh_time: self.args.arg_accounts_refresh,
testnet: self.args.flag_testnet,
testnet: false,
password_files: self
.args
.arg_password
@ -747,9 +726,7 @@ impl Configuration {
U256::from_dec_str(&format!("{:.0}", wei_per_gas)).unwrap()
}
if let Some(dec) = self.args.arg_gasprice.as_ref() {
return Ok(GasPricerConfig::Fixed(to_u256(dec)?));
} else if let Some(dec) = self.args.arg_min_gas_price {
if let Some(dec) = self.args.arg_min_gas_price {
return Ok(GasPricerConfig::Fixed(U256::from(dec)));
} else if self.chain()? != SpecType::Foundation {
return Ok(GasPricerConfig::Fixed(U256::zero()));
@ -785,12 +762,7 @@ impl Configuration {
}
fn extra_data(&self) -> Result<Bytes, String> {
match self
.args
.arg_extradata
.as_ref()
.or(self.args.arg_extra_data.as_ref())
{
match &self.args.arg_extra_data {
Some(x) if x.len() <= 32 => Ok(x.as_bytes().to_owned()),
None => Ok(version_data()),
Some(_) => Err("Extra data must be at most 32 characters".into()),
@ -892,7 +864,7 @@ impl Configuration {
Some(Ok(key)) => Some(key),
Some(Err(err)) => return Err(err),
};
ret.discovery_enabled = !self.args.flag_no_discovery && !self.args.flag_nodiscover;
ret.discovery_enabled = !self.args.flag_no_discovery;
ret.max_peers = self.max_peers();
ret.min_peers = self.min_peers();
ret.snapshot_peers = self.snapshot_peers();
@ -916,23 +888,11 @@ impl Configuration {
}
fn network_id(&self) -> Option<u64> {
self.args.arg_network_id.or(self.args.arg_networkid)
self.args.arg_network_id
}
fn rpc_apis(&self) -> String {
let mut apis: Vec<&str> = self
.args
.arg_rpcapi
.as_ref()
.unwrap_or(&self.args.arg_jsonrpc_apis)
.split(",")
.collect();
if self.args.flag_geth {
apis.insert(0, "personal");
}
apis.join(",")
self.args.arg_jsonrpc_apis.clone()
}
fn cors(cors: &str) -> Option<Vec<String>> {
@ -946,11 +906,7 @@ impl Configuration {
}
fn rpc_cors(&self) -> Option<Vec<String>> {
let cors = self
.args
.arg_rpccorsdomain
.clone()
.unwrap_or_else(|| self.args.arg_jsonrpc_cors.to_owned());
let cors = self.args.arg_jsonrpc_cors.to_owned();
Self::cors(&cors)
}
@ -1002,24 +958,9 @@ impl Configuration {
fn ipc_config(&self) -> Result<IpcConfiguration, String> {
let conf = IpcConfiguration {
enabled: !(self.args.flag_ipcdisable
|| self.args.flag_ipc_off
|| self.args.flag_no_ipc),
enabled: !self.args.flag_no_ipc,
socket_addr: self.ipc_path(),
apis: {
let mut apis = self
.args
.arg_ipcapi
.clone()
.unwrap_or(self.args.arg_ipc_apis.clone());
if self.args.flag_geth {
if !apis.is_empty() {
apis.push_str(",");
}
apis.push_str("personal");
}
apis.parse()?
},
apis: self.args.arg_ipc_apis.parse()?,
};
Ok(conf)
@ -1029,8 +970,7 @@ impl Configuration {
let conf = HttpConfiguration {
enabled: self.rpc_enabled(),
interface: self.rpc_interface(),
port: self.args.arg_ports_shift
+ self.args.arg_rpcport.unwrap_or(self.args.arg_jsonrpc_port),
port: self.args.arg_ports_shift + self.args.arg_jsonrpc_port,
apis: self.rpc_apis().parse()?,
hosts: self.rpc_hosts(),
cors: self.rpc_cors(),
@ -1163,7 +1103,6 @@ impl Configuration {
.args
.arg_base_path
.as_ref()
.or_else(|| self.args.arg_datadir.as_ref())
.map_or_else(|| default_data_path(), |s| s.clone());
let data_path = replace_home("", &base_path);
let is_using_base_path = self.args.arg_base_path.is_some();
@ -1208,19 +1147,11 @@ impl Configuration {
}
fn ipc_path(&self) -> String {
if self.args.flag_geth {
geth_ipc_path(self.args.flag_testnet)
} else {
parity_ipc_path(
&self.directories().base,
&self
.args
.arg_ipcpath
.clone()
.unwrap_or(self.args.arg_ipc_path.clone()),
self.args.arg_ports_shift,
)
}
parity_ipc_path(
&self.directories().base,
&self.args.arg_ipc_path,
self.args.arg_ports_shift,
)
}
fn interface(&self, interface: &str) -> String {
@ -1237,12 +1168,7 @@ impl Configuration {
}
fn rpc_interface(&self) -> String {
let rpc_interface = self
.args
.arg_rpcaddr
.clone()
.unwrap_or(self.args.arg_jsonrpc_interface.clone());
self.interface(&rpc_interface)
self.interface(&self.args.arg_jsonrpc_interface)
}
fn ws_interface(&self) -> String {
@ -1326,7 +1252,7 @@ impl Configuration {
}
fn rpc_enabled(&self) -> bool {
!self.args.flag_jsonrpc_off && !self.args.flag_no_jsonrpc
!self.args.flag_no_jsonrpc
}
fn ws_enabled(&self) -> bool {
@ -1742,7 +1668,6 @@ mod tests {
tracing: Default::default(),
compaction: Default::default(),
vm_type: Default::default(),
geth_compatibility: false,
experimental_rpcs: false,
net_settings: Default::default(),
ipfs_conf: Default::default(),
@ -1874,7 +1799,7 @@ mod tests {
// given
// when
let conf = parse(&["parity", "--testnet", "--identity", "testname"]);
let conf = parse(&["parity", "--chain", "goerli", "--identity", "testname"]);
// then
assert_eq!(
@ -1891,49 +1816,6 @@ mod tests {
);
}
#[test]
fn should_parse_rpc_settings_with_geth_compatiblity() {
// given
fn assert(conf: Configuration) {
let net = conf.network_settings().unwrap();
assert_eq!(net.rpc_enabled, true);
assert_eq!(net.rpc_interface, "0.0.0.0".to_owned());
assert_eq!(net.rpc_port, 8000);
assert_eq!(conf.rpc_cors(), None);
assert_eq!(conf.rpc_apis(), "web3,eth".to_owned());
}
// when
let conf1 = parse(&[
"parity",
"-j",
"--jsonrpc-port",
"8000",
"--jsonrpc-interface",
"all",
"--jsonrpc-cors",
"*",
"--jsonrpc-apis",
"web3,eth",
]);
let conf2 = parse(&[
"parity",
"--rpc",
"--rpcport",
"8000",
"--rpcaddr",
"all",
"--rpccorsdomain",
"*",
"--rpcapi",
"web3,eth",
]);
// then
assert(conf1);
assert(conf2);
}
#[test]
fn should_parse_rpc_hosts() {
// given
@ -2005,33 +1887,9 @@ mod tests {
// when
let conf0 = parse(&["parity", "--ui-path=signer"]);
let conf1 = parse(&["parity", "--ui-path=signer", "--ui-no-validation"]);
let conf2 = parse(&["parity", "--ui-path=signer", "--ui-port", "3123"]);
let conf3 = parse(&["parity", "--ui-path=signer", "--ui-interface", "test"]);
let conf4 = parse(&["parity", "--ui-path=signer", "--force-ui"]);
// then
assert_eq!(conf0.directories().signer, "signer".to_owned());
assert!(conf1.ws_config().unwrap().hosts.is_some());
assert_eq!(
conf1.ws_config().unwrap().origins,
Some(vec![
"parity://*".into(),
"chrome-extension://*".into(),
"moz-extension://*".into()
])
);
assert_eq!(conf1.directories().signer, "signer".to_owned());
assert!(conf2.ws_config().unwrap().hosts.is_some());
assert_eq!(conf2.directories().signer, "signer".to_owned());
assert!(conf3.ws_config().unwrap().hosts.is_some());
assert_eq!(conf3.directories().signer, "signer".to_owned());
assert!(conf4.ws_config().unwrap().hosts.is_some());
assert_eq!(conf4.directories().signer, "signer".to_owned());
}
#[test]
@ -2122,7 +1980,7 @@ mod tests {
ApiSet::List(set) => assert_eq!(set, ApiSet::All.list_apis()),
_ => panic!("Incorrect rpc apis"),
}
// "web3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts");
// "web3,eth,net,personal,parity,parity_set,traces,parity_accounts");
assert_eq!(c.http_conf.hosts, None);
assert_eq!(c.ipfs_conf.hosts, None);
}
@ -2145,7 +2003,7 @@ mod tests {
ApiSet::List(set) => assert_eq!(set, ApiSet::All.list_apis()),
_ => panic!("Incorrect rpc apis"),
}
// "web3,eth,net,personal,parity,parity_set,traces,rpc,parity_accounts");
// "web3,eth,net,personal,parity,parity_set,traces,parity_accounts");
assert_eq!(c.http_conf.hosts, None);
assert_eq!(c.ipfs_conf.hosts, None);
}

View File

@ -1,300 +0,0 @@
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
use cli::Args;
use std::fmt;
#[derive(Debug, PartialEq)]
pub enum Deprecated {
DoesNothing(&'static str),
Replaced(&'static str, &'static str),
Removed(&'static str),
}
impl fmt::Display for Deprecated {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
Deprecated::DoesNothing(s) => {
write!(f, "Option '{}' does nothing. It's on by default.", s)
}
Deprecated::Replaced(old, new) => write!(
f,
"Option '{}' is deprecated. Please use '{}' instead.",
old, new
),
Deprecated::Removed(s) => write!(
f,
"Option '{}' has been removed and is no longer supported.",
s
),
}
}
}
pub fn find_deprecated(args: &Args) -> Vec<Deprecated> {
let mut result = vec![];
// Removed in 1.6 or before.
if args.flag_warp {
result.push(Deprecated::DoesNothing("--warp"));
}
if args.flag_jsonrpc {
result.push(Deprecated::DoesNothing("--jsonrpc"));
}
if args.flag_rpc {
result.push(Deprecated::DoesNothing("--rpc"));
}
if args.flag_jsonrpc_off {
result.push(Deprecated::Replaced("--jsonrpc-off", "--no-jsonrpc"));
}
if args.flag_webapp {
result.push(Deprecated::DoesNothing("--webapp"));
}
if args.flag_dapps_off {
result.push(Deprecated::Replaced("--dapps-off", "--no-dapps"));
}
if args.flag_ipcdisable {
result.push(Deprecated::Replaced("--ipcdisable", "--no-ipc"));
}
if args.flag_ipc_off {
result.push(Deprecated::Replaced("--ipc-off", "--no-ipc"));
}
if args.arg_etherbase.is_some() {
result.push(Deprecated::Replaced("--etherbase", "--author"));
}
if args.arg_extradata.is_some() {
result.push(Deprecated::Replaced("--extradata", "--extra-data"));
}
if args.flag_testnet {
result.push(Deprecated::Replaced("--testnet", "--chain testnet"));
}
if args.flag_nodiscover {
result.push(Deprecated::Replaced("--nodiscover", "--no-discovery"));
}
if args.arg_datadir.is_some() {
result.push(Deprecated::Replaced("--datadir", "--base-path"));
}
if args.arg_networkid.is_some() {
result.push(Deprecated::Replaced("--networkid", "--network-id"));
}
if args.arg_peers.is_some() {
result.push(Deprecated::Replaced("--peers", "--min-peers"));
}
if args.arg_nodekey.is_some() {
result.push(Deprecated::Replaced("--nodekey", "--node-key"));
}
if args.arg_rpcaddr.is_some() {
result.push(Deprecated::Replaced("--rpcaddr", "--jsonrpc-interface"));
}
if args.arg_rpcport.is_some() {
result.push(Deprecated::Replaced("--rpcport", "--jsonrpc-port"));
}
if args.arg_rpcapi.is_some() {
result.push(Deprecated::Replaced("--rpcapi", "--jsonrpc-api"));
}
if args.arg_rpccorsdomain.is_some() {
result.push(Deprecated::Replaced("--rpccorsdomain", "--jsonrpc-cors"));
}
if args.arg_ipcapi.is_some() {
result.push(Deprecated::Replaced("--ipcapi", "--ipc-apis"));
}
if args.arg_ipcpath.is_some() {
result.push(Deprecated::Replaced("--ipcpath", "--ipc-path"));
}
if args.arg_gasprice.is_some() {
result.push(Deprecated::Replaced("--gasprice", "--min-gas-price"));
}
if args.arg_cache.is_some() {
result.push(Deprecated::Replaced("--cache", "--cache-size"));
}
// Removed in 1.7.
if args.arg_dapps_port.is_some() {
result.push(Deprecated::Removed("--dapps-port"));
}
if args.arg_dapps_interface.is_some() {
result.push(Deprecated::Removed("--dapps-interface"));
}
if args.arg_dapps_hosts.is_some() {
result.push(Deprecated::Removed("--dapps-hosts"));
}
if args.arg_dapps_cors.is_some() {
result.push(Deprecated::Removed("--dapps-cors"));
}
if args.arg_dapps_user.is_some() {
result.push(Deprecated::Removed("--dapps-user"));
}
if args.arg_dapps_pass.is_some() {
result.push(Deprecated::Removed("--dapps-pass"));
}
if args.flag_dapps_apis_all {
result.push(Deprecated::Replaced("--dapps-apis-all", "--jsonrpc-apis"));
}
// Removed in 1.11.
if args.flag_public_node {
result.push(Deprecated::Removed("--public-node"));
}
if args.flag_force_ui {
result.push(Deprecated::Removed("--force-ui"));
}
if args.flag_no_ui {
result.push(Deprecated::Removed("--no-ui"));
}
if args.flag_ui_no_validation {
result.push(Deprecated::Removed("--ui-no-validation"));
}
if args.arg_ui_interface.is_some() {
result.push(Deprecated::Removed("--ui-interface"));
}
if args.arg_ui_hosts.is_some() {
result.push(Deprecated::Removed("--ui-hosts"));
}
if args.arg_ui_port.is_some() {
result.push(Deprecated::Removed("--ui-port"));
}
if args.arg_tx_queue_ban_count.is_some() {
result.push(Deprecated::Removed("--tx-queue-ban-count"));
}
if args.arg_tx_queue_ban_time.is_some() {
result.push(Deprecated::Removed("--tx-queue-ban-time"));
}
// Removed in 2.0.
if args.flag_fast_and_loose {
result.push(Deprecated::Removed("--fast-and-loose"));
}
if args.cmd_dapp {
result.push(Deprecated::Removed("parity dapp"));
}
if args.arg_dapp_path.is_some() {
result.push(Deprecated::Removed("--dapp-path"));
}
if args.flag_no_dapps {
result.push(Deprecated::Removed("--no-dapps"));
}
if args.arg_dapps_path.is_some() {
result.push(Deprecated::Removed("--dapps-path"));
}
if args.arg_ntp_servers.is_some() {
result.push(Deprecated::Removed("--ntp-servers"));
}
result
}
#[cfg(test)]
mod tests {
use super::{find_deprecated, Deprecated};
use cli::Args;
#[test]
fn test_find_deprecated() {
assert_eq!(find_deprecated(&Args::default()), vec![]);
assert_eq!(
find_deprecated(&{
let mut args = Args::default();
args.flag_warp = true;
args.flag_jsonrpc = true;
args.flag_rpc = true;
args.flag_jsonrpc_off = true;
args.flag_webapp = true;
args.flag_dapps_off = true;
args.flag_ipcdisable = true;
args.flag_ipc_off = true;
args.arg_etherbase = Some(Default::default());
args.arg_extradata = Some(Default::default());
args.arg_dapps_port = Some(Default::default());
args.arg_dapps_interface = Some(Default::default());
args.arg_dapps_hosts = Some(Default::default());
args.arg_dapps_cors = Some(Default::default());
args.arg_dapps_user = Some(Default::default());
args.arg_dapps_pass = Some(Default::default());
args.flag_dapps_apis_all = true;
args.flag_fast_and_loose = true;
args.arg_ntp_servers = Some(Default::default());
args
}),
vec![
Deprecated::DoesNothing("--warp"),
Deprecated::DoesNothing("--jsonrpc"),
Deprecated::DoesNothing("--rpc"),
Deprecated::Replaced("--jsonrpc-off", "--no-jsonrpc"),
Deprecated::DoesNothing("--webapp"),
Deprecated::Replaced("--dapps-off", "--no-dapps"),
Deprecated::Replaced("--ipcdisable", "--no-ipc"),
Deprecated::Replaced("--ipc-off", "--no-ipc"),
Deprecated::Replaced("--etherbase", "--author"),
Deprecated::Replaced("--extradata", "--extra-data"),
Deprecated::Removed("--dapps-port"),
Deprecated::Removed("--dapps-interface"),
Deprecated::Removed("--dapps-hosts"),
Deprecated::Removed("--dapps-cors"),
Deprecated::Removed("--dapps-user"),
Deprecated::Removed("--dapps-pass"),
Deprecated::Replaced("--dapps-apis-all", "--jsonrpc-apis"),
Deprecated::Removed("--fast-and-loose"),
Deprecated::Removed("--ntp-servers"),
]
);
}
}

View File

@ -25,7 +25,6 @@ use ethereum_types::{clean_0x, Address, U256};
use ethkey::Password;
use journaldb::Algorithm;
use miner::pool::PrioritizationStrategy;
use path;
use std::{
collections::HashSet,
fs::File,
@ -188,27 +187,6 @@ pub fn flush_stdout() {
io::stdout().flush().expect("stdout is flushable; qed");
}
/// Returns default geth ipc path.
pub fn geth_ipc_path(testnet: bool) -> String {
// Windows path should not be hardcoded here.
// Instead it should be a part of path::ethereum
if cfg!(windows) {
return r"\\.\pipe\geth.ipc".to_owned();
}
if testnet {
path::ethereum::with_testnet("geth.ipc")
.to_str()
.unwrap()
.to_owned()
} else {
path::ethereum::with_default("geth.ipc")
.to_str()
.unwrap()
.to_owned()
}
}
/// Formats and returns parity ipc path.
pub fn parity_ipc_path(base: &str, path: &str, shift: u16) -> String {
let mut path = path.to_owned();
@ -391,8 +369,8 @@ pub fn passwords_from_files(files: &[String]) -> Result<Vec<Password>, String> {
#[cfg(test)]
mod tests {
use super::{
geth_ipc_path, join_set, password_from_file, to_address, to_addresses, to_block_id,
to_bootnodes, to_duration, to_mode, to_pending_set, to_price, to_u256,
join_set, password_from_file, to_address, to_addresses, to_block_id, to_bootnodes,
to_duration, to_mode, to_pending_set, to_price, to_u256,
};
use ethcore::{
client::{BlockId, Mode},
@ -581,33 +559,6 @@ but the first password is trimmed
assert_eq!(to_price("2.33").unwrap(), 2.33);
}
#[test]
#[cfg(windows)]
fn test_geth_ipc_path() {
assert_eq!(geth_ipc_path(true), r"\\.\pipe\geth.ipc".to_owned());
assert_eq!(geth_ipc_path(false), r"\\.\pipe\geth.ipc".to_owned());
}
#[test]
#[cfg(not(windows))]
fn test_geth_ipc_path() {
use path;
assert_eq!(
geth_ipc_path(true),
path::ethereum::with_testnet("geth.ipc")
.to_str()
.unwrap()
.to_owned()
);
assert_eq!(
geth_ipc_path(false),
path::ethereum::with_default("geth.ipc")
.to_str()
.unwrap()
.to_owned()
);
}
#[test]
fn test_to_bootnodes() {
let one_bootnode = "enode://e731347db0521f3476e6bbbb83375dcd7133a1601425ebd15fd10f3835fd4c304fba6282087ca5a0deeafadf0aa0d4fd56c3323331901c1f38bd181c283e3e35@128.199.55.137:30303";

View File

@ -99,7 +99,6 @@ mod cache;
mod cli;
mod configuration;
mod db;
mod deprecated;
mod export_hardcoded_sync;
mod helpers;
mod informant;
@ -122,7 +121,6 @@ use std::{fs::File, io::BufReader, sync::Arc};
use cli::Args;
use configuration::{Cmd, Execute};
use deprecated::find_deprecated;
use hash::keccak_buffer;
#[cfg(feature = "memory_profiling")]
@ -267,10 +265,5 @@ where
Cr: Fn(String) + 'static + Send,
Rr: Fn() + 'static + Send,
{
let deprecated = find_deprecated(&conf.args);
for d in deprecated {
println!("{}", d);
}
execute(conf.into_command()?, logger, on_client_rq, on_updater_rq)
}

View File

@ -219,7 +219,6 @@ fn main_direct(force_can_restart: bool) -> i32 {
});
if let Some(spec_override) = take_spec_name_override() {
conf.args.flag_testnet = false;
conf.args.arg_chain = spec_override;
}

View File

@ -16,7 +16,7 @@
use std::{
cmp::PartialEq,
collections::{BTreeMap, HashSet},
collections::HashSet,
str::FromStr,
sync::{Arc, Weak},
};
@ -62,8 +62,6 @@ pub enum Api {
Parity,
/// Traces (Safe)
Traces,
/// Rpc (Safe)
Rpc,
/// Private transaction manager (Safe)
Private,
/// Whisper (Safe)
@ -102,7 +100,6 @@ impl FromStr for Api {
"personal" => Ok(Personal),
"private" => Ok(Private),
"pubsub" => Ok(EthPubSub),
"rpc" => Ok(Rpc),
"secretstore" => Ok(SecretStore),
"shh" => Ok(Whisper),
"shh_pubsub" => Ok(WhisperPubSub),
@ -171,33 +168,6 @@ impl FromStr for ApiSet {
}
}
fn to_modules(apis: &HashSet<Api>) -> BTreeMap<String, String> {
let mut modules = BTreeMap::new();
for api in apis {
let (name, version) = match *api {
Api::Debug => ("debug", "1.0"),
Api::Eth => ("eth", "1.0"),
Api::EthPubSub => ("pubsub", "1.0"),
Api::Net => ("net", "1.0"),
Api::Parity => ("parity", "1.0"),
Api::ParityAccounts => ("parity_accounts", "1.0"),
Api::ParityPubSub => ("parity_pubsub", "1.0"),
Api::ParitySet => ("parity_set", "1.0"),
Api::Personal => ("personal", "1.0"),
Api::Private => ("private", "1.0"),
Api::Rpc => ("rpc", "1.0"),
Api::SecretStore => ("secretstore", "1.0"),
Api::Signer => ("signer", "1.0"),
Api::Traces => ("traces", "1.0"),
Api::Web3 => ("web3", "1.0"),
Api::Whisper => ("shh", "1.0"),
Api::WhisperPubSub => ("shh_pubsub", "1.0"),
};
modules.insert(name.into(), version.into());
}
modules
}
macro_rules! add_signing_methods {
($namespace:ident, $handler:expr, $deps:expr, $dispatch:expr) => {{
let deps = &$deps;
@ -246,7 +216,6 @@ pub struct FullDependencies {
pub settings: Arc<NetworkSettings>,
pub net_service: Arc<dyn ManageNetwork>,
pub updater: Arc<Updater>,
pub geth_compatibility: bool,
pub experimental_rpcs: bool,
pub ws_address: Option<Host>,
pub fetch: FetchClient,
@ -301,9 +270,6 @@ impl FullDependencies {
&self.miner,
&self.external_miner,
EthClientOptions {
pending_nonce_from_queue: self.geth_compatibility,
allow_pending_receipt_query: !self.geth_compatibility,
send_block_number_in_get_work: !self.geth_compatibility,
gas_price_percentile: self.gas_price_percentile,
allow_missing_blocks: self.allow_missing_blocks,
allow_experimental_rpcs: self.experimental_rpcs,
@ -352,7 +318,6 @@ impl FullDependencies {
PersonalClient::new(
&self.accounts,
dispatcher.clone(),
self.geth_compatibility,
self.experimental_rpcs,
)
.to_delegate(),
@ -438,10 +403,6 @@ impl FullDependencies {
);
}
Api::Traces => handler.extend_with(TracesClient::new(&self.client).to_delegate()),
Api::Rpc => {
let modules = to_modules(&apis);
handler.extend_with(RpcClient::new(modules).to_delegate());
}
Api::SecretStore => {
#[cfg(feature = "accounts")]
handler.extend_with(SecretStoreClient::new(&self.accounts).to_delegate());
@ -511,7 +472,6 @@ pub struct LightDependencies<T> {
pub transaction_queue: Arc<RwLock<LightTransactionQueue>>,
pub ws_address: Option<Host>,
pub fetch: FetchClient,
pub geth_compatibility: bool,
pub experimental_rpcs: bool,
pub executor: Executor,
pub whisper_rpc: Option<::whisper::RpcFactory>,
@ -603,7 +563,6 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
PersonalClient::new(
&self.accounts,
dispatcher.clone(),
self.geth_compatibility,
self.experimental_rpcs,
)
.to_delegate(),
@ -677,10 +636,6 @@ impl<C: LightChainClient + 'static> LightDependencies<C> {
.to_delegate(),
),
Api::Traces => handler.extend_with(light::TracesClient.to_delegate()),
Api::Rpc => {
let modules = to_modules(&apis);
handler.extend_with(RpcClient::new(modules).to_delegate());
}
Api::SecretStore => {
#[cfg(feature = "accounts")]
handler.extend_with(SecretStoreClient::new(&self.accounts).to_delegate());
@ -738,7 +693,6 @@ impl ApiSet {
Api::Eth,
Api::EthPubSub,
Api::Parity,
Api::Rpc,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,
@ -802,7 +756,6 @@ mod test {
assert_eq!(Api::ParityAccounts, "parity_accounts".parse().unwrap());
assert_eq!(Api::ParitySet, "parity_set".parse().unwrap());
assert_eq!(Api::Traces, "traces".parse().unwrap());
assert_eq!(Api::Rpc, "rpc".parse().unwrap());
assert_eq!(Api::SecretStore, "secretstore".parse().unwrap());
assert_eq!(Api::Private, "private".parse().unwrap());
assert_eq!(Api::Whisper, "shh".parse().unwrap());
@ -834,7 +787,6 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Rpc,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,
@ -855,7 +807,6 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Rpc,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,
@ -880,7 +831,6 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Rpc,
Api::SecretStore,
Api::Whisper,
Api::WhisperPubSub,
@ -910,7 +860,6 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Rpc,
Api::SecretStore,
Api::Whisper,
Api::WhisperPubSub,
@ -939,7 +888,6 @@ mod test {
Api::Parity,
Api::ParityPubSub,
Api::Traces,
Api::Rpc,
Api::Whisper,
Api::WhisperPubSub,
Api::Private,

View File

@ -117,7 +117,6 @@ pub struct RunCmd {
pub fat_db: Switch,
pub compaction: DatabaseCompactionProfile,
pub vm_type: VMType,
pub geth_compatibility: bool,
pub experimental_rpcs: bool,
pub net_settings: NetworkSettings,
pub ipfs_conf: ipfs::Configuration,
@ -375,7 +374,6 @@ where
transaction_queue: txq,
ws_address: cmd.ws_conf.address(),
fetch: fetch,
geth_compatibility: cmd.geth_compatibility,
experimental_rpcs: cmd.experimental_rpcs,
executor: runtime.executor(),
whisper_rpc: whisper_factory,
@ -865,7 +863,6 @@ where
settings: Arc::new(cmd.net_settings.clone()),
net_service: manage_network.clone(),
updater: updater.clone(),
geth_compatibility: cmd.geth_compatibility,
experimental_rpcs: cmd.experimental_rpcs,
ws_address: cmd.ws_conf.address(),
fetch: fetch.clone(),

View File

@ -70,12 +70,6 @@ const EXTRA_INFO_PROOF: &str = "Object exists in blockchain (fetched earlier), e
/// Eth RPC options
#[derive(Copy, Clone)]
pub struct EthClientOptions {
/// Return nonce from transaction queue when pending block not available.
pub pending_nonce_from_queue: bool,
/// Returns receipt from pending blocks
pub allow_pending_receipt_query: bool,
/// Send additional block number when asking for work
pub send_block_number_in_get_work: bool,
/// Gas Price Percentile used as default gas price.
pub gas_price_percentile: usize,
/// Return 'null' instead of an error if ancient block sync is still in
@ -100,9 +94,6 @@ impl EthClientOptions {
impl Default for EthClientOptions {
fn default() -> Self {
EthClientOptions {
pending_nonce_from_queue: false,
allow_pending_receipt_query: true,
send_block_number_in_get_work: true,
gas_price_percentile: 50,
allow_missing_blocks: false,
allow_experimental_rpcs: false,
@ -788,9 +779,6 @@ where
fn transaction_count(&self, address: H160, num: Option<BlockNumber>) -> BoxFuture<U256> {
let res = match num.unwrap_or_default() {
BlockNumber::Pending if self.options.pending_nonce_from_queue => {
Ok(self.miner.next_nonce(&*self.client, &address))
}
BlockNumber::Pending => {
let info = self.client.chain_info();
let nonce = self
@ -953,11 +941,9 @@ where
}
fn transaction_receipt(&self, hash: H256) -> BoxFuture<Option<Receipt>> {
if self.options.allow_pending_receipt_query {
let best_block = self.client.chain_info().best_block_number;
if let Some(receipt) = self.miner.pending_receipt(best_block, &hash) {
return Box::new(future::ok(Some(receipt.into())));
}
let best_block = self.client.chain_info().best_block_number;
if let Some(receipt) = self.miner.pending_receipt(best_block, &hash) {
return Box::new(future::ok(Some(receipt.into())));
}
let receipt = self.client.transaction_receipt(TransactionId::Hash(hash));
@ -1067,19 +1053,12 @@ where
.as_secs();
if no_new_work_timeout > 0 && timestamp + no_new_work_timeout < now {
Err(errors::no_new_work())
} else if self.options.send_block_number_in_get_work {
Ok(Work {
pow_hash,
seed_hash: seed_hash.into(),
target,
number: Some(number),
})
} else {
Ok(Work {
pow_hash,
seed_hash: seed_hash.into(),
target,
number: None,
number: Some(number),
})
}
}

View File

@ -29,7 +29,6 @@ mod parity_set;
mod personal;
mod private;
mod pubsub;
mod rpc;
#[cfg(any(test, feature = "accounts"))]
mod secretstore;
mod signer;
@ -58,7 +57,6 @@ pub use self::{
parity_set::ParitySetClient,
private::PrivateClient,
pubsub::PubSubClient,
rpc::RpcClient,
signer::SignerClient,
signing::SigningQueueClient,
signing_unsafe::SigningUnsafeClient,

View File

@ -225,19 +225,6 @@ impl ParityAccounts for ParityAccountsClient {
Ok(true)
}
fn import_geth_accounts(&self, addresses: Vec<H160>) -> Result<Vec<H160>> {
self.deprecation_notice("parity_importGethAccounts");
self.accounts
.import_geth_accounts(into_vec(addresses), false)
.map(into_vec)
.map_err(|e| errors::account("Couldn't import Geth accounts", e))
}
fn geth_accounts(&self) -> Result<Vec<H160>> {
self.deprecation_notice("parity_listGethAccounts");
Ok(into_vec(self.accounts.list_geth_accounts(false)))
}
fn create_vault(&self, name: String, password: Password) -> Result<bool> {
self.deprecation_notice("parity_newVault");
@ -376,10 +363,3 @@ impl ParityAccounts for ParityAccountsClient {
.map_err(|e| errors::account("Could not sign message.", e))
}
}
fn into_vec<A, B>(a: Vec<A>) -> Vec<B>
where
A: Into<B>,
{
a.into_iter().map(Into::into).collect()
}

View File

@ -15,7 +15,7 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! Account management (personal) rpc implementation
use std::{sync::Arc, time::Duration};
use std::sync::Arc;
use accounts::AccountProvider;
use bytes::Bytes;
@ -48,7 +48,6 @@ use v1::{
pub struct PersonalClient<D: Dispatcher> {
accounts: Arc<AccountProvider>,
dispatcher: D,
allow_perm_unlock: bool,
allow_experimental_rpcs: bool,
deprecation_notice: DeprecationNotice,
}
@ -58,13 +57,11 @@ impl<D: Dispatcher> PersonalClient<D> {
pub fn new(
accounts: &Arc<AccountProvider>,
dispatcher: D,
allow_perm_unlock: bool,
allow_experimental_rpcs: bool,
) -> Self {
PersonalClient {
accounts: accounts.clone(),
dispatcher,
allow_perm_unlock,
allow_experimental_rpcs,
deprecation_notice: DeprecationNotice::default(),
}
@ -159,23 +156,14 @@ impl<D: Dispatcher + 'static> Personal for PersonalClient<D> {
}
};
let r = match (self.allow_perm_unlock, duration) {
(false, None) => store.unlock_account_temporarily(account, account_pass.into()),
(false, _) => {
let r = match duration {
None => store.unlock_account_temporarily(account, account_pass.into()),
_ => {
return Err(errors::unsupported(
"Time-unlocking is not supported when permanent unlock is disabled.",
Some("Use personal_sendTransaction or enable permanent unlocking, instead."),
Some("Use personal_sendTransaction instead."),
))
}
(true, Some(0)) => store.unlock_account_permanently(account, account_pass.into()),
(true, Some(d)) => store.unlock_account_timed(
account,
account_pass.into(),
Duration::from_secs(d.into()),
),
(true, None) => {
store.unlock_account_timed(account, account_pass.into(), Duration::from_secs(300))
}
};
match r {
Ok(_) => Ok(true),

View File

@ -1,66 +0,0 @@
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! RPC generic methods implementation.
use jsonrpc_core::Result;
use std::collections::BTreeMap;
use v1::traits::Rpc;
/// RPC generic methods implementation.
pub struct RpcClient {
modules: BTreeMap<String, String>,
valid_apis: Vec<String>,
}
impl RpcClient {
/// Creates new `RpcClient`.
pub fn new(modules: BTreeMap<String, String>) -> Self {
// geth 1.3.6 fails upon receiving unknown api
let valid_apis = vec!["web3", "eth", "net", "personal", "rpc"];
RpcClient {
modules,
valid_apis: valid_apis.into_iter().map(ToOwned::to_owned).collect(),
}
}
}
impl Rpc for RpcClient {
fn rpc_modules(&self) -> Result<BTreeMap<String, String>> {
let modules = self
.modules
.iter()
.fold(BTreeMap::new(), |mut map, (k, v)| {
map.insert(k.to_owned(), v.to_owned());
map
});
Ok(modules)
}
fn modules(&self) -> Result<BTreeMap<String, String>> {
let modules = self
.modules
.iter()
.filter(|&(k, _v)| self.valid_apis.contains(k))
.fold(BTreeMap::new(), |mut map, (k, v)| {
map.insert(k.to_owned(), v.to_owned());
map
});
Ok(modules)
}
}

View File

@ -49,7 +49,7 @@ pub use self::{
traits::{
Debug, Eth, EthFilter, EthPubSub, EthSigning, Net, Parity, ParityAccounts,
ParityAccountsInfo, ParitySet, ParitySetAccounts, ParitySigning, Personal, Private, PubSub,
Rpc, SecretStore, Signer, Traces, Web3,
SecretStore, Signer, Traces, Web3,
},
types::Origin,
};

View File

@ -142,9 +142,6 @@ impl EthTester {
&miner_service,
&external_miner,
EthClientOptions {
pending_nonce_from_queue: false,
allow_pending_receipt_query: true,
send_block_number_in_get_work: true,
gas_price_percentile: 50,
allow_experimental_rpcs: true,
allow_missing_blocks: false,

View File

@ -642,38 +642,6 @@ fn rpc_eth_transaction_count() {
);
}
#[test]
fn rpc_eth_transaction_count_next_nonce() {
let tester = EthTester::new_with_options(EthClientOptions::with(|options| {
options.pending_nonce_from_queue = true;
}));
tester.miner.increment_nonce(&1.into());
let request1 = r#"{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0x0000000000000000000000000000000000000001", "pending"],
"id": 1
}"#;
let response1 = r#"{"jsonrpc":"2.0","result":"0x1","id":1}"#;
assert_eq!(
tester.io.handle_request_sync(request1),
Some(response1.to_owned())
);
let request2 = r#"{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0x0000000000000000000000000000000000000002", "pending"],
"id": 1
}"#;
let response2 = r#"{"jsonrpc":"2.0","result":"0x0","id":1}"#;
assert_eq!(
tester.io.handle_request_sync(request2),
Some(response2.to_owned())
);
}
#[test]
fn rpc_eth_block_transaction_count_by_hash() {
let request = r#"{
@ -1341,24 +1309,6 @@ fn rpc_get_work_returns_correct_work_package() {
);
}
#[test]
fn rpc_get_work_should_not_return_block_number() {
let eth_tester = EthTester::new_with_options(EthClientOptions::with(|options| {
options.send_block_number_in_get_work = false;
}));
eth_tester.miner.set_author(miner::Author::External(
Address::from_str("d46e8dd67c5d32be8058bb8eb970870f07244567").unwrap(),
));
let request = r#"{"jsonrpc": "2.0", "method": "eth_getWork", "params": [], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":["0x76c7bd86693aee93d1a80a408a09a0585b1a1292afcb56192f171d925ea18e2d","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000800000000000000000000000000000000000000000000000000000000000"],"id":1}"#;
assert_eq!(
eth_tester.io.handle_request_sync(request),
Some(response.to_owned())
);
}
#[test]
fn rpc_get_work_should_timeout() {
let eth_tester = EthTester::default();

View File

@ -29,7 +29,6 @@ mod parity_set;
#[cfg(any(test, feature = "accounts"))]
mod personal;
mod pubsub;
mod rpc;
#[cfg(any(test, feature = "accounts"))]
mod secretstore;
mod signer;

View File

@ -77,7 +77,7 @@ fn setup_with(c: Config) -> PersonalTester {
let reservations = Arc::new(Mutex::new(nonce::Reservations::new(runtime.executor())));
let dispatcher = FullDispatcher::new(client, miner.clone(), reservations, 50);
let personal = PersonalClient::new(&accounts, dispatcher, false, c.allow_experimental_rpcs);
let personal = PersonalClient::new(&accounts, dispatcher, c.allow_experimental_rpcs);
let mut io = IoHandler::default();
io.extend_with(personal.to_delegate());
@ -383,39 +383,6 @@ fn ec_recover_invalid_signature() {
);
}
#[test]
fn should_not_unlock_account_temporarily_if_allow_perm_is_disabled() {
let tester = setup();
let address = tester.accounts.new_account(&"password123".into()).unwrap();
let request = r#"{
"jsonrpc": "2.0",
"method": "personal_unlockAccount",
"params": [
""#
.to_owned()
+ &format!("0x{:x}", address)
+ r#"",
"password123",
"0x100"
],
"id": 1
}"#;
let response = r#"{"jsonrpc":"2.0","error":{"code":-32000,"message":"Time-unlocking is not supported when permanent unlock is disabled.","data":"Use personal_sendTransaction or enable permanent unlocking, instead."},"id":1}"#;
assert_eq!(
tester.io.handle_request_sync(&request),
Some(response.into())
);
assert!(
tester
.accounts
.sign(address, None, Default::default())
.is_err(),
"Should not unlock account."
);
}
#[test]
fn should_unlock_account_permanently() {
let tester = setup();

View File

@ -1,52 +0,0 @@
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
use jsonrpc_core::IoHandler;
use std::collections::BTreeMap;
use v1::{Rpc, RpcClient};
fn rpc_client() -> RpcClient {
let mut modules = BTreeMap::new();
modules.insert("rpc".to_owned(), "1.0".to_owned());
modules.insert("web3".to_owned(), "1.0".to_owned());
modules.insert("ethcore".to_owned(), "1.0".to_owned());
RpcClient::new(modules)
}
#[test]
fn modules() {
let rpc = rpc_client().to_delegate();
let mut io = IoHandler::new();
io.extend_with(rpc);
let request = r#"{"jsonrpc": "2.0", "method": "modules", "params": [], "id": 1}"#;
let response = r#"{"jsonrpc":"2.0","result":{"rpc":"1.0","web3":"1.0"},"id":1}"#;
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
}
#[test]
fn rpc_modules() {
let rpc = rpc_client().to_delegate();
let mut io = IoHandler::new();
io.extend_with(rpc);
let request = r#"{"jsonrpc": "2.0", "method": "rpc_modules", "params": [], "id": 1}"#;
let response =
r#"{"jsonrpc":"2.0","result":{"ethcore":"1.0","rpc":"1.0","web3":"1.0"},"id":1}"#;
assert_eq!(io.handle_request_sync(request), Some(response.to_owned()));
}

View File

@ -28,7 +28,6 @@ pub mod parity_signing;
pub mod personal;
pub mod private;
pub mod pubsub;
pub mod rpc;
pub mod secretstore;
pub mod signer;
pub mod traces;
@ -47,7 +46,6 @@ pub use self::{
personal::Personal,
private::Private,
pubsub::PubSub,
rpc::Rpc,
secretstore::SecretStore,
signer::Signer,
traces::Traces,

View File

@ -86,14 +86,6 @@ pub trait ParityAccounts {
#[rpc(name = "parity_setAccountMeta")]
fn set_account_meta(&self, _: H160, _: String) -> Result<bool>;
/// Imports a number of Geth accounts, with the list provided as the argument.
#[rpc(name = "parity_importGethAccounts")]
fn import_geth_accounts(&self, _: Vec<H160>) -> Result<Vec<H160>>;
/// Returns the accounts available for importing from Geth.
#[rpc(name = "parity_listGethAccounts")]
fn geth_accounts(&self) -> Result<Vec<H160>>;
/// Create new vault.
#[rpc(name = "parity_newVault")]
fn create_vault(&self, _: String, _: Password) -> Result<bool>;

View File

@ -1,36 +0,0 @@
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
//! RPC interface.
use std::collections::BTreeMap;
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
/// RPC Interface.
#[rpc(server)]
pub trait Rpc {
/// Returns supported modules for Geth 1.3.6
/// @ignore
#[rpc(name = "modules")]
fn modules(&self) -> Result<BTreeMap<String, String>>;
/// Returns supported modules for Geth 1.4.0
/// @ignore
#[rpc(name = "rpc_modules")]
fn rpc_modules(&self) -> Result<BTreeMap<String, String>>;
}

View File

@ -289,16 +289,6 @@ fn home() -> PathBuf {
home_dir().expect("Failed to get home dir")
}
/// Geth path
pub fn geth(testnet: bool) -> PathBuf {
let mut base = geth_base();
if testnet {
base.push("testnet");
}
base.push("keystore");
base
}
/// Parity path for specific chain
pub fn parity(chain: &str) -> PathBuf {
let mut base = parity_base();
@ -321,13 +311,6 @@ mod platform {
home.push("keys");
home
}
pub fn geth_base() -> PathBuf {
let mut home = super::home();
home.push("Library");
home.push("Ethereum");
home
}
}
#[cfg(windows)]
@ -346,14 +329,6 @@ mod platform {
home.push("keys");
home
}
pub fn geth_base() -> PathBuf {
let mut home = super::home();
home.push("AppData");
home.push("Roaming");
home.push("Ethereum");
home
}
}
#[cfg(not(any(target_os = "macos", windows)))]
@ -371,12 +346,6 @@ mod platform {
home.push("keys");
home
}
pub fn geth_base() -> PathBuf {
let mut home = super::home();
home.push(".ethereum");
home
}
}
#[cfg(test)]