diff --git a/ethcore/src/account_provider/mod.rs b/ethcore/src/account_provider/mod.rs index d4a5da49e98..e4289c60a57 100644 --- a/ethcore/src/account_provider/mod.rs +++ b/ethcore/src/account_provider/mod.rs @@ -18,19 +18,20 @@ mod stores; +use self::stores::{AddressBook, DappsSettingsStore, NewDappsPolicy}; + +use std::collections::{HashMap, HashSet}; +use std::fmt; +use std::time::{Instant, Duration}; + +use ethstore::accounts_dir::MemoryDirectory; +use ethstore::ethkey::{Address, Message, Public, Secret, Password, Random, Generator}; +use ethjson::misc::AccountMeta; use ethstore::{ SimpleSecretStore, SecretStore, Error as SSError, EthStore, EthMultiStore, random_string, SecretVaultRef, StoreAccountRef, OpaqueSecret, }; -use ethjson::misc::AccountMeta; -use ethstore::accounts_dir::MemoryDirectory; -use ethstore::ethkey::{Address, Message, Public, Secret, Password, Random, Generator}; -use ethjson::misc::AccountMeta; use parking_lot::RwLock; -use self::stores::{AddressBook, DappsSettingsStore, NewDappsPolicy}; -use std::collections::{HashMap, HashSet}; -use std::fmt; -use std::time::{Instant, Duration}; pub use ethstore::ethkey::Signature; pub use ethstore::{Derivation, IndexDerivation, KeyFile}; @@ -291,8 +292,12 @@ impl AccountProvider { /// Returns addresses of hardware accounts. pub fn hardware_accounts(&self) -> Result, Error> { - let accounts = self.hardware_store.as_ref().map_or_else(|| Vec::new(), |h| h.list_wallets()); - Ok(accounts.into_iter().map(|a| a.address).collect()) + if let Some(accounts) = self.hardware_store.as_ref().map(|h| h.list_wallets()) { + if !accounts.is_empty() { + return Ok(accounts.into_iter().map(|a| a.address).collect()); + } + } + Err(SSError::Custom("No hardware wallet accounts were found".into())) } /// Get a list of paths to locked hardware wallets diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 763043d62db..ee4980c0560 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -108,6 +108,7 @@ extern crate vm; extern crate wasm; extern crate memory_cache; extern crate journaldb; +extern crate tempdir; #[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android"))] extern crate hardware_wallet; @@ -115,9 +116,6 @@ extern crate hardware_wallet; #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows", target_os = "android")))] extern crate fake_hardware_wallet as hardware_wallet; -#[cfg(test)] -extern crate tempdir; - #[macro_use] extern crate ethabi_derive; #[macro_use] @@ -161,8 +159,6 @@ pub mod snapshot; pub mod spec; pub mod state; pub mod state_db; - -// Test helpers made public for usage outside ethcore pub mod trace; pub mod verification; diff --git a/util/fake-hardware-wallet/src/lib.rs b/util/fake-hardware-wallet/src/lib.rs index b00d1892ee8..2bf905d7bf7 100644 --- a/util/fake-hardware-wallet/src/lib.rs +++ b/util/fake-hardware-wallet/src/lib.rs @@ -33,7 +33,7 @@ pub struct WalletInfo { /// `ErrorType` for devices with no `hardware wallet` pub enum Error { NoWallet, - KeyNotFound, + KeyNotFound, } pub struct TransactionInfo { @@ -65,8 +65,8 @@ pub struct HardwareWalletManager; impl HardwareWalletManager { pub fn new() -> Result { - Err(Error::NoWallet) - } + Err(Error::NoWallet) + } pub fn set_key_path(&self, _key_path: KeyPath) {} @@ -96,6 +96,6 @@ impl HardwareWalletManager { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "") + write!(f, "No hardware wallet!!") } }