Remove support for hardware wallets (#10678)

This commit is contained in:
Artem Vorotnikov
2020-07-30 03:45:43 +03:00
parent c270599a23
commit 11fb967c6a
24 changed files with 13 additions and 2135 deletions

View File

@@ -57,10 +57,6 @@ impl super::Accounts for Signer {
data: filled.data,
};
if self.accounts.is_hardware_address(&filled.from) {
return hardware_signature(&*self.accounts, filled.from, t, chain_id).map(WithToken::No);
}
let hash = t.hash(chain_id);
let signature = signature(&*self.accounts, filled.from, hash, password)?;
@@ -76,24 +72,6 @@ impl super::Accounts for Signer {
password: SignWith,
hash: SignMessage,
) -> Result<WithToken<Signature>> {
if self.accounts.is_hardware_address(&address) {
return if let SignMessage::Data(data) = hash {
let signature = self
.accounts
.sign_message_with_hardware(&address, &data)
// TODO: is this correct? I guess the `token` is the wallet in this context
.map(WithToken::No)
.map_err(|e| errors::account("Error signing message with hardware_wallet", e));
signature
} else {
Err(errors::account(
"Error signing message with hardware_wallet",
"Message signing is unsupported",
))
};
}
match hash {
SignMessage::Data(data) => {
let hash = eth_data_hash(data);
@@ -109,13 +87,6 @@ impl super::Accounts for Signer {
password: SignWith,
data: Bytes,
) -> Result<WithToken<Bytes>> {
if self.accounts.is_hardware_address(&address) {
return Err(errors::unsupported(
"Decrypting via hardware wallets is not supported.",
None,
));
}
match password.clone() {
SignWith::Nothing => self
.accounts
@@ -173,27 +144,3 @@ fn signature(
_ => errors::password(e),
})
}
// obtain a hardware signature from the given account.
fn hardware_signature(
accounts: &AccountProvider,
address: Address,
t: Transaction,
chain_id: Option<u64>,
) -> Result<SignedTransaction> {
debug_assert!(accounts.is_hardware_address(&address));
let mut stream = rlp::RlpStream::new();
t.rlp_append_unsigned_transaction(&mut stream, chain_id);
let signature = accounts
.sign_transaction_with_hardware(&address, &t, chain_id, &stream.as_raw())
.map_err(|e| {
debug!(target: "miner", "Error signing transaction with hardware wallet: {}", e);
errors::account("Error signing transaction with hardware wallet", e)
})?;
SignedTransaction::new(t.with_signature(signature, chain_id)).map_err(|e| {
debug!(target: "miner", "Hardware wallet has produced invalid signature: {}", e);
errors::account("Invalid signature generated", e)
})
}

View File

@@ -34,7 +34,7 @@ use v1::{
errors,
},
traits::{ParityAccounts, ParityAccountsInfo},
types::{AccountInfo, Derive, DeriveHash, DeriveHierarchical, ExtAccountInfo, HwAccountInfo},
types::{AccountInfo, Derive, DeriveHash, DeriveHierarchical, ExtAccountInfo},
};
/// Account management (personal) rpc implementation.
@@ -85,35 +85,6 @@ impl ParityAccountsInfo for ParityAccountsClient {
.collect())
}
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>> {
self.deprecation_notice("parity_hardwareAccountsInfo");
let info = self
.accounts
.hardware_accounts_info()
.map_err(|e| errors::account("Could not fetch account info.", e))?;
Ok(info
.into_iter()
.map(|(a, v)| {
(
H160::from(a),
HwAccountInfo {
name: v.name,
manufacturer: v.meta,
},
)
})
.collect())
}
fn locked_hardware_accounts_info(&self) -> Result<Vec<String>> {
self.deprecation_notice("parity_lockedHardwareAccountsInfo");
self.accounts
.locked_hardware_accounts()
.map_err(|e| errors::account("Error communicating with hardware wallet.", e))
}
fn default_account(&self) -> Result<H160> {
self.deprecation_notice("parity_defaultAccount");
@@ -404,14 +375,6 @@ impl ParityAccounts for ParityAccountsClient {
.map(Into::into)
.map_err(|e| errors::account("Could not sign message.", e))
}
fn hardware_pin_matrix_ack(&self, path: String, pin: String) -> Result<bool> {
self.deprecation_notice("parity_hardwarePinMatrixAck");
self.accounts
.hardware_pin_matrix_ack(&path, &pin)
.map_err(|e| errors::account("Error communicating with hardware wallet.", e))
}
}
fn into_vec<A, B>(a: Vec<A>) -> Vec<B>

View File

@@ -22,7 +22,7 @@ use ethkey::Password;
use ethstore::KeyFile;
use jsonrpc_core::Result;
use jsonrpc_derive::rpc;
use v1::types::{AccountInfo, DeriveHash, DeriveHierarchical, ExtAccountInfo, HwAccountInfo};
use v1::types::{AccountInfo, DeriveHash, DeriveHierarchical, ExtAccountInfo};
/// Parity-specific read-only accounts rpc interface.
#[rpc(server)]
@@ -31,14 +31,6 @@ pub trait ParityAccountsInfo {
#[rpc(name = "parity_accountsInfo")]
fn accounts_info(&self) -> Result<BTreeMap<H160, AccountInfo>>;
/// Returns hardware accounts information.
#[rpc(name = "parity_hardwareAccountsInfo")]
fn hardware_accounts_info(&self) -> Result<BTreeMap<H160, HwAccountInfo>>;
/// Get a list of paths to locked hardware wallets
#[rpc(name = "parity_lockedHardwareAccountsInfo")]
fn locked_hardware_accounts_info(&self) -> Result<Vec<String>>;
/// Returns default account for dapp.
#[rpc(name = "parity_defaultAccount")]
fn default_account(&self) -> Result<H160>;
@@ -162,8 +154,4 @@ pub trait ParityAccounts {
/// Sign raw hash with the key corresponding to address and password.
#[rpc(name = "parity_signMessage")]
fn sign_message(&self, _: H160, _: Password, _: H256) -> Result<H520>;
/// Send a PinMatrixAck to a hardware wallet, unlocking it
#[rpc(name = "parity_hardwarePinMatrixAck")]
fn hardware_pin_matrix_ack(&self, _: String, _: String) -> Result<bool>;
}

View File

@@ -60,15 +60,6 @@ pub struct ExtAccountInfo {
pub uuid: Option<String>,
}
/// Hardware wallet information.
#[derive(Debug, Default, Clone, PartialEq, Serialize)]
pub struct HwAccountInfo {
/// Device name.
pub name: String,
/// Device manufacturer.
pub manufacturer: String,
}
/// account derived from a signature
/// as well as information that tells if it is valid for
/// the current chain

View File

@@ -49,9 +49,7 @@ mod work;
pub mod pubsub;
pub use self::{
account_info::{
AccountInfo, EthAccount, ExtAccountInfo, HwAccountInfo, RecoveredAccount, StorageProof,
},
account_info::{AccountInfo, EthAccount, ExtAccountInfo, RecoveredAccount, StorageProof},
block::{Block, BlockTransactions, Header, Rich, RichBlock, RichHeader},
block_number::{block_number_to_id, BlockNumber, LightBlockNumber},
bytes::Bytes,