Remove private transactions
This commit is contained in:
@@ -64,7 +64,6 @@ extern crate ethcore;
|
||||
extern crate ethcore_logger;
|
||||
extern crate ethcore_miner as miner;
|
||||
extern crate ethcore_network as network;
|
||||
extern crate ethcore_private_tx;
|
||||
extern crate ethcore_sync as sync;
|
||||
extern crate ethereum_types;
|
||||
extern crate ethkey;
|
||||
|
||||
@@ -22,7 +22,6 @@ use ethcore::{
|
||||
client::{BlockChainClient, BlockId},
|
||||
error::{CallError, Error as EthcoreError, ErrorKind},
|
||||
};
|
||||
use ethcore_private_tx::Error as PrivateTransactionError;
|
||||
use jsonrpc_core::{Error, ErrorCode, Result as RpcResult, Value};
|
||||
use rlp::DecoderError;
|
||||
use types::{blockchain_info::BlockChainInfo, transaction::Error as TransactionError};
|
||||
@@ -47,7 +46,6 @@ mod codes {
|
||||
#[cfg(any(test, feature = "accounts"))]
|
||||
pub const PASSWORD_INVALID: i64 = -32021;
|
||||
pub const ACCOUNT_ERROR: i64 = -32023;
|
||||
pub const PRIVATE_ERROR: i64 = -32024;
|
||||
pub const REQUEST_REJECTED: i64 = -32040;
|
||||
pub const REQUEST_REJECTED_LIMIT: i64 = -32041;
|
||||
pub const REQUEST_NOT_FOUND: i64 = -32042;
|
||||
@@ -70,14 +68,6 @@ pub fn unimplemented(details: Option<String>) -> Error {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn light_unimplemented(details: Option<String>) -> Error {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
|
||||
message: "This request is unsupported for light clients.".into(),
|
||||
data: details.map(Value::String),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unsupported<T: Into<String>>(msg: T, details: Option<T>) -> Error {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(codes::UNSUPPORTED_REQUEST),
|
||||
@@ -374,22 +364,6 @@ pub fn password(error: ::accounts::SignError) -> Error {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn private_message(error: PrivateTransactionError) -> Error {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(codes::PRIVATE_ERROR),
|
||||
message: "Private transactions call failed.".into(),
|
||||
data: Some(Value::String(format!("{:?}", error))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn private_message_block_id_not_supported() -> Error {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(codes::PRIVATE_ERROR),
|
||||
message: "Pending block id not supported.".into(),
|
||||
data: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn transaction_message(error: &TransactionError) -> String {
|
||||
use self::TransactionError::*;
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ mod parity_accounts;
|
||||
mod parity_set;
|
||||
#[cfg(any(test, feature = "accounts"))]
|
||||
mod personal;
|
||||
mod private;
|
||||
mod pubsub;
|
||||
#[cfg(any(test, feature = "accounts"))]
|
||||
mod secretstore;
|
||||
@@ -53,7 +52,6 @@ pub use self::{
|
||||
net::NetClient,
|
||||
parity::ParityClient,
|
||||
parity_set::ParitySetClient,
|
||||
private::PrivateClient,
|
||||
pubsub::PubSubClient,
|
||||
signer::SignerClient,
|
||||
signing::SigningQueueClient,
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Ethereum.
|
||||
|
||||
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Private transaction signing RPC implementation.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use rlp::Rlp;
|
||||
|
||||
use ethcore_private_tx::Provider as PrivateTransactionManager;
|
||||
use ethereum_types::{Address, H160, H256, U256};
|
||||
use types::transaction::SignedTransaction;
|
||||
|
||||
use jsonrpc_core::Error;
|
||||
use v1::{
|
||||
helpers::{errors, fake_sign},
|
||||
metadata::Metadata,
|
||||
traits::Private,
|
||||
types::{
|
||||
block_number_to_id, BlockNumber, Bytes, CallRequest, PrivateTransactionReceipt,
|
||||
PrivateTransactionReceiptAndTransaction, TransactionRequest,
|
||||
},
|
||||
};
|
||||
|
||||
/// Private transaction manager API endpoint implementation.
|
||||
pub struct PrivateClient {
|
||||
private: Option<Arc<PrivateTransactionManager>>,
|
||||
}
|
||||
|
||||
impl PrivateClient {
|
||||
/// Creates a new instance.
|
||||
pub fn new(private: Option<Arc<PrivateTransactionManager>>) -> Self {
|
||||
PrivateClient { private }
|
||||
}
|
||||
|
||||
fn unwrap_manager(&self) -> Result<&PrivateTransactionManager, Error> {
|
||||
match self.private {
|
||||
Some(ref arc) => Ok(&**arc),
|
||||
None => Err(errors::light_unimplemented(None)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Private for PrivateClient {
|
||||
type Metadata = Metadata;
|
||||
|
||||
fn send_transaction(&self, request: Bytes) -> Result<PrivateTransactionReceipt, Error> {
|
||||
let signed_transaction = Rlp::new(&request.into_vec())
|
||||
.as_val()
|
||||
.map_err(errors::rlp)
|
||||
.and_then(|tx| SignedTransaction::new(tx).map_err(errors::transaction))?;
|
||||
let client = self.unwrap_manager()?;
|
||||
let receipt = client
|
||||
.create_private_transaction(signed_transaction)
|
||||
.map_err(errors::private_message)?;
|
||||
Ok(receipt.into())
|
||||
}
|
||||
|
||||
fn compose_deployment_transaction(
|
||||
&self,
|
||||
block_number: BlockNumber,
|
||||
request: Bytes,
|
||||
validators: Vec<H160>,
|
||||
gas_price: U256,
|
||||
) -> Result<PrivateTransactionReceiptAndTransaction, Error> {
|
||||
let signed_transaction = Rlp::new(&request.into_vec())
|
||||
.as_val()
|
||||
.map_err(errors::rlp)
|
||||
.and_then(|tx| SignedTransaction::new(tx).map_err(errors::transaction))?;
|
||||
let client = self.unwrap_manager()?;
|
||||
|
||||
let addresses: Vec<Address> = validators.into_iter().map(Into::into).collect();
|
||||
let id = match block_number {
|
||||
BlockNumber::Pending => return Err(errors::private_message_block_id_not_supported()),
|
||||
num => block_number_to_id(num),
|
||||
};
|
||||
|
||||
let (transaction, contract_address) = client
|
||||
.public_creation_transaction(id, &signed_transaction, addresses.as_slice(), gas_price)
|
||||
.map_err(errors::private_message)?;
|
||||
let tx_hash = transaction.hash(None);
|
||||
let request = TransactionRequest {
|
||||
from: Some(signed_transaction.sender()),
|
||||
to: None,
|
||||
nonce: Some(transaction.nonce),
|
||||
gas_price: Some(transaction.gas_price),
|
||||
gas: Some(transaction.gas),
|
||||
value: Some(transaction.value),
|
||||
data: Some(transaction.data.into()),
|
||||
condition: None,
|
||||
};
|
||||
|
||||
Ok(PrivateTransactionReceiptAndTransaction {
|
||||
transaction: request,
|
||||
receipt: PrivateTransactionReceipt {
|
||||
transaction_hash: tx_hash,
|
||||
contract_address,
|
||||
status_code: 0,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
fn private_call(
|
||||
&self,
|
||||
block_number: BlockNumber,
|
||||
request: CallRequest,
|
||||
) -> Result<Bytes, Error> {
|
||||
let id = match block_number {
|
||||
BlockNumber::Pending => return Err(errors::private_message_block_id_not_supported()),
|
||||
num => block_number_to_id(num),
|
||||
};
|
||||
|
||||
let request = CallRequest::into(request);
|
||||
let signed = fake_sign::sign_call(request)?;
|
||||
let client = self.unwrap_manager()?;
|
||||
let executed_result = client
|
||||
.private_call(id, &signed)
|
||||
.map_err(errors::private_message)?;
|
||||
Ok(executed_result.output.into())
|
||||
}
|
||||
|
||||
fn private_contract_key(&self, contract_address: H160) -> Result<H256, Error> {
|
||||
let client = self.unwrap_manager()?;
|
||||
let key = client
|
||||
.contract_key_id(&contract_address)
|
||||
.map_err(errors::private_message)?;
|
||||
Ok(key)
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ pub use self::{
|
||||
metadata::Metadata,
|
||||
traits::{
|
||||
Debug, Eth, EthFilter, EthPubSub, EthSigning, Net, Parity, ParityAccounts,
|
||||
ParityAccountsInfo, ParitySet, ParitySetAccounts, ParitySigning, Personal, Private, PubSub,
|
||||
ParityAccountsInfo, ParitySet, ParitySetAccounts, ParitySigning, Personal, PubSub,
|
||||
SecretStore, Signer, Traces, Web3,
|
||||
},
|
||||
types::Origin,
|
||||
|
||||
@@ -26,7 +26,6 @@ pub mod parity_accounts;
|
||||
pub mod parity_set;
|
||||
pub mod parity_signing;
|
||||
pub mod personal;
|
||||
pub mod private;
|
||||
pub mod pubsub;
|
||||
pub mod secretstore;
|
||||
pub mod signer;
|
||||
@@ -44,7 +43,6 @@ pub use self::{
|
||||
parity_set::{ParitySet, ParitySetAccounts},
|
||||
parity_signing::ParitySigning,
|
||||
personal::Personal,
|
||||
private::Private,
|
||||
pubsub::PubSub,
|
||||
secretstore::SecretStore,
|
||||
signer::Signer,
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Ethereum.
|
||||
|
||||
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! SecretStore-specific rpc interface.
|
||||
|
||||
use ethereum_types::{H160, H256, U256};
|
||||
use jsonrpc_core::Error;
|
||||
use jsonrpc_derive::rpc;
|
||||
|
||||
use v1::types::{
|
||||
BlockNumber, Bytes, CallRequest, PrivateTransactionReceipt,
|
||||
PrivateTransactionReceiptAndTransaction,
|
||||
};
|
||||
|
||||
/// Private transaction management RPC interface.
|
||||
#[rpc(server)]
|
||||
pub trait Private {
|
||||
/// RPC Metadata
|
||||
type Metadata;
|
||||
|
||||
/// Sends private transaction; Transaction will be added to the validation queue and sent out when ready.
|
||||
#[rpc(name = "private_sendTransaction")]
|
||||
fn send_transaction(&self, _: Bytes) -> Result<PrivateTransactionReceipt, Error>;
|
||||
|
||||
/// Creates a transaction for contract's deployment from origin (signed transaction)
|
||||
#[rpc(name = "private_composeDeploymentTransaction")]
|
||||
fn compose_deployment_transaction(
|
||||
&self,
|
||||
_: BlockNumber,
|
||||
_: Bytes,
|
||||
_: Vec<H160>,
|
||||
_: U256,
|
||||
) -> Result<PrivateTransactionReceiptAndTransaction, Error>;
|
||||
|
||||
/// Make a call to the private contract
|
||||
#[rpc(name = "private_call")]
|
||||
fn private_call(&self, _: BlockNumber, _: CallRequest) -> Result<Bytes, Error>;
|
||||
|
||||
/// Retrieve the id of the key associated with the contract
|
||||
#[rpc(name = "private_contractKey")]
|
||||
fn private_contract_key(&self, _: H160) -> Result<H256, Error>;
|
||||
}
|
||||
@@ -32,7 +32,6 @@ mod histogram;
|
||||
mod index;
|
||||
mod log;
|
||||
mod node_kind;
|
||||
mod private_receipt;
|
||||
mod provenance;
|
||||
mod receipt;
|
||||
mod rpc_settings;
|
||||
@@ -65,7 +64,6 @@ pub use self::{
|
||||
index::Index,
|
||||
log::Log,
|
||||
node_kind::{Availability, Capability, NodeKind},
|
||||
private_receipt::{PrivateTransactionReceipt, PrivateTransactionReceiptAndTransaction},
|
||||
provenance::Origin,
|
||||
receipt::Receipt,
|
||||
rpc_settings::RpcSettings,
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity Ethereum.
|
||||
|
||||
// Parity Ethereum 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 Ethereum 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 Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use ethcore_private_tx::Receipt as EthPrivateReceipt;
|
||||
use ethereum_types::{H160, H256};
|
||||
use v1::types::TransactionRequest;
|
||||
|
||||
/// Receipt
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PrivateTransactionReceipt {
|
||||
/// Transaction Hash
|
||||
pub transaction_hash: H256,
|
||||
/// Private contract address
|
||||
pub contract_address: H160,
|
||||
/// Status code
|
||||
#[serde(rename = "status")]
|
||||
pub status_code: u8,
|
||||
}
|
||||
|
||||
impl From<EthPrivateReceipt> for PrivateTransactionReceipt {
|
||||
fn from(r: EthPrivateReceipt) -> Self {
|
||||
PrivateTransactionReceipt {
|
||||
transaction_hash: r.hash,
|
||||
contract_address: r.contract_address,
|
||||
status_code: r.status_code,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Receipt and Transaction
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct PrivateTransactionReceiptAndTransaction {
|
||||
/// Receipt
|
||||
pub receipt: PrivateTransactionReceipt,
|
||||
/// Transaction
|
||||
pub transaction: TransactionRequest,
|
||||
}
|
||||
Reference in New Issue
Block a user