Add raw hash signing (#5423)
* add sign any * Add RPC signMessage call to JS API * Add signMessage to JSON RPC docs * PostSignTransaction -> EthSignMessage * fix doc typo * revert incorect naming
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
//! Account management (personal) rpc implementation
|
||||
use std::sync::{Arc, Weak};
|
||||
use std::collections::BTreeMap;
|
||||
use util::{Address};
|
||||
use util::Address;
|
||||
|
||||
use ethkey::{Brain, Generator, Secret};
|
||||
use ethstore::KeyFile;
|
||||
@@ -27,7 +27,7 @@ use jsonrpc_core::Error;
|
||||
use v1::helpers::errors;
|
||||
use v1::helpers::accounts::unwrap_provider;
|
||||
use v1::traits::ParityAccounts;
|
||||
use v1::types::{H160 as RpcH160, H256 as RpcH256, DappId, Derive, DeriveHierarchical, DeriveHash};
|
||||
use v1::types::{H160 as RpcH160, H256 as RpcH256, H520 as RpcH520, DappId, Derive, DeriveHierarchical, DeriveHash};
|
||||
|
||||
/// Account management (personal) rpc implementation.
|
||||
pub struct ParityAccountsClient {
|
||||
@@ -334,6 +334,17 @@ impl ParityAccounts for ParityAccountsClient {
|
||||
.map(Into::into)
|
||||
.map_err(|e| errors::account("Could not export account.", e))
|
||||
}
|
||||
|
||||
fn sign_message(&self, addr: RpcH160, password: String, message: RpcH256) -> Result<RpcH520, Error> {
|
||||
self.account_provider()?
|
||||
.sign(
|
||||
addr.into(),
|
||||
Some(password),
|
||||
message.into()
|
||||
)
|
||||
.map(Into::into)
|
||||
.map_err(|e| errors::account("Could not sign message.", e))
|
||||
}
|
||||
}
|
||||
|
||||
fn into_vec<A, B>(a: Vec<A>) -> Vec<B> where
|
||||
|
||||
@@ -140,7 +140,7 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningQueueClient<D> {
|
||||
fn post_sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>, Error> {
|
||||
let pending = self.pending.clone();
|
||||
self.dispatch(
|
||||
RpcConfirmationPayload::Signature((address.clone(), data).into()),
|
||||
RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()),
|
||||
DefaultAccount::Provided(address.into()),
|
||||
meta.origin
|
||||
).map(move |result| match result {
|
||||
@@ -216,7 +216,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningQueueClient<D> {
|
||||
|
||||
fn sign(&self, meta: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcH520, Error> {
|
||||
let res = self.dispatch(
|
||||
RpcConfirmationPayload::Signature((address.clone(), data).into()),
|
||||
RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()),
|
||||
address.into(),
|
||||
meta.origin,
|
||||
);
|
||||
|
||||
@@ -78,7 +78,7 @@ impl<D: Dispatcher + 'static> EthSigning for SigningUnsafeClient<D>
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn sign(&self, _: Metadata, address: RpcH160, data: RpcBytes) -> BoxFuture<RpcH520, Error> {
|
||||
self.handle(RpcConfirmationPayload::Signature((address.clone(), data).into()), address.into())
|
||||
self.handle(RpcConfirmationPayload::EthSignMessage((address.clone(), data).into()), address.into())
|
||||
.then(|res| match res {
|
||||
Ok(RpcConfirmationResponse::Signature(signature)) => Ok(signature),
|
||||
Err(e) => Err(e),
|
||||
|
||||
Reference in New Issue
Block a user