This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all
fake-hardware-wallet
to its own crate
* Removes some conditional compilation flags * Introduces `fake-hardware-wallet` crate
- Loading branch information
Showing
10 changed files
with
156 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
description = "Fake hardware-wallet, for OS' that don't support libusb" | ||
name = "fake-hardware-wallet" | ||
version = "0.0.1" | ||
license = "GPL-3.0" | ||
authors = ["Parity Technologies <admin@parity.io>"] | ||
|
||
[dependencies] | ||
ethereum-types = "0.3" | ||
ethkey = { path = "../../ethkey" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2015-2018 Parity Technologies (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/>. | ||
|
||
//! Dummy module for platforms that does not provide support for hardware wallets (libusb) | ||
extern crate ethereum_types; | ||
extern crate ethkey; | ||
|
||
use std::fmt; | ||
use ethereum_types::U256; | ||
use ethkey::{Address, Signature}; | ||
|
||
pub struct WalletInfo { | ||
pub address: Address, | ||
pub name: String, | ||
pub manufacturer: String, | ||
} | ||
|
||
#[derive(Debug)] | ||
/// `ErrorType` for devices with no `hardware wallet` | ||
pub enum Error { | ||
NoWallet, | ||
KeyNotFound, | ||
} | ||
|
||
pub struct TransactionInfo { | ||
/// Nonce | ||
pub nonce: U256, | ||
/// Gas price | ||
pub gas_price: U256, | ||
/// Gas limit | ||
pub gas_limit: U256, | ||
/// Receiver | ||
pub to: Option<Address>, | ||
/// Value | ||
pub value: U256, | ||
/// Data | ||
pub data: Vec<u8>, | ||
/// Chain ID | ||
pub chain_id: Option<u64>, | ||
} | ||
|
||
pub enum KeyPath { | ||
/// Ethereum. | ||
Ethereum, | ||
/// Ethereum classic. | ||
EthereumClassic, | ||
} | ||
|
||
/// `HardwareWalletManager` for devices with no `hardware wallet` | ||
pub struct HardwareWalletManager; | ||
|
||
impl HardwareWalletManager { | ||
pub fn new() -> Result<Self, Error> { | ||
Err(Error::NoWallet) | ||
} | ||
|
||
pub fn set_key_path(&self, _key_path: KeyPath) {} | ||
|
||
pub fn wallet_info(&self, _: &Address) -> Option<WalletInfo> { | ||
None | ||
} | ||
|
||
pub fn list_wallets(&self) -> Vec<WalletInfo> { | ||
Vec::with_capacity(0) | ||
} | ||
|
||
pub fn list_locked_wallets(&self) -> Result<Vec<String>, Error> { | ||
Err(Error::NoWallet) | ||
} | ||
|
||
pub fn pin_matrix_ack(&self, _: &str, _: &str) -> Result<bool, Error> { | ||
Err(Error::NoWallet) | ||
} | ||
|
||
pub fn sign_transaction(&self, _address: &Address, _transaction: &TransactionInfo, _rlp_transaction: &[u8]) -> Result<Signature, Error> { | ||
Err(Error::NoWallet) } | ||
|
||
pub fn sign_message(&self, _address: &Address, _msg: &[u8]) -> Result<Signature, Error> { | ||
Err(Error::NoWallet) | ||
} | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "") | ||
} | ||
} |