From 67a07adb0b4d96c50f0abe487d01110e8cd6b27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 15 Aug 2017 12:11:34 +0200 Subject: [PATCH] Add more descriptive error when signing/decrypting using hw wallet. --- rpc/src/v1/helpers/dispatch.rs | 8 ++++++++ rpc/src/v1/helpers/errors.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/rpc/src/v1/helpers/dispatch.rs b/rpc/src/v1/helpers/dispatch.rs index ddd238fd8..c72f1a890 100644 --- a/rpc/src/v1/helpers/dispatch.rs +++ b/rpc/src/v1/helpers/dispatch.rs @@ -512,6 +512,10 @@ pub fn execute( ).boxed() }, ConfirmationPayload::EthSignMessage(address, data) => { + if accounts.is_hardware_address(address) { + return future::err(errors::unsupported("Signing via hardware wallets is not supported.", None)).boxed(); + } + let hash = eth_data_hash(data); let res = signature(&accounts, address, hash, pass) .map(|result| result @@ -522,6 +526,10 @@ pub fn execute( future::done(res).boxed() }, ConfirmationPayload::Decrypt(address, data) => { + if accounts.is_hardware_address(address) { + return future::err(errors::unsupported("Decrypting via hardware wallets is not supported.", None)).boxed(); + } + let res = decrypt(&accounts, address, data, pass) .map(|result| result .map(RpcBytes) diff --git a/rpc/src/v1/helpers/errors.rs b/rpc/src/v1/helpers/errors.rs index 9be54991f..4c4af6f97 100644 --- a/rpc/src/v1/helpers/errors.rs +++ b/rpc/src/v1/helpers/errors.rs @@ -71,6 +71,14 @@ pub fn public_unsupported(details: Option) -> Error { } } +pub fn unsupported>(msg: T, details: Option) -> Error { + Error { + code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST), + message: msg.into(), + data: details.map(Into::into).map(Value::String), + } +} + pub fn request_not_found() -> Error { Error { code: ErrorCode::ServerError(codes::REQUEST_NOT_FOUND),