parent
588529e578
commit
6ab78a0091
@ -15,7 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Ethcore-specific rpc implementation.
|
||||
use util::{RotatingLogger};
|
||||
use util::{RotatingLogger, KeyPair};
|
||||
use util::misc::version_data;
|
||||
use std::sync::{Arc, Weak};
|
||||
use std::collections::{BTreeMap};
|
||||
@ -24,7 +24,7 @@ use ethcore::client::{MiningBlockChainClient};
|
||||
use jsonrpc_core::*;
|
||||
use ethcore::miner::MinerService;
|
||||
use v1::traits::Ethcore;
|
||||
use v1::types::{Bytes, U256};
|
||||
use v1::types::{Bytes, U256, H160};
|
||||
use v1::helpers::{errors, SigningQueue, ConfirmationsQueue, NetworkSettings};
|
||||
use v1::helpers::params::expect_no_params;
|
||||
|
||||
@ -173,4 +173,11 @@ impl<C, M> Ethcore for EthcoreClient<C, M> where M: MinerService + 'static, C: M
|
||||
|
||||
to_value(&random_phrase(12))
|
||||
}
|
||||
|
||||
fn phrase_to_address(&self, params: Params) -> Result<Value, Error> {
|
||||
try!(self.active());
|
||||
from_params::<(String,)>(params).and_then(|(phrase,)|
|
||||
to_value(&H160::from(KeyPair::from_phrase(&phrase).address()))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,9 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
|
||||
/// Returns a cryptographically random phrase sufficient for securely seeding a secret key.
|
||||
fn generate_secret_phrase(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Returns whatever address would be derived from the given phrase if it were to seed a brainwallet.
|
||||
fn phrase_to_address(&self, _: Params) -> Result<Value, Error>;
|
||||
|
||||
/// Should be used to convert object to io delegate.
|
||||
fn to_delegate(self) -> IoDelegate<Self> {
|
||||
let mut delegate = IoDelegate::new(Arc::new(self));
|
||||
@ -90,6 +93,7 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
|
||||
delegate.add_method("ethcore_gasPriceStatistics", Ethcore::gas_price_statistics);
|
||||
delegate.add_method("ethcore_unsignedTransactionsCount", Ethcore::unsigned_transactions_count);
|
||||
delegate.add_method("ethcore_generateSecretPhrase", Ethcore::generate_secret_phrase);
|
||||
delegate.add_method("ethcore_phraseToAddress", Ethcore::phrase_to_address);
|
||||
|
||||
delegate
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user