Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.
Merged
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli-signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "cli-signer"
version = "1.4.0"

[dependencies]
ethereum-types = "0.4"
futures = "0.1"
rpassword = "1.0"
parity-rpc = { path = "../rpc" }
Expand Down
1 change: 1 addition & 0 deletions cli-signer/rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "parity-rpc-client"
version = "1.4.0"

[dependencies]
ethereum-types = "0.4"
futures = "0.1"
log = "0.4"
serde = "1.0"
Expand Down
1 change: 1 addition & 0 deletions cli-signer/rpc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
pub mod client;
pub mod signer_client;

extern crate ethereum_types;
extern crate futures;
extern crate jsonrpc_core;
extern crate jsonrpc_ws_server as ws;
Expand Down
3 changes: 2 additions & 1 deletion cli-signer/rpc-client/src/signer_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

use client::{Rpc, RpcError};
use rpc::signer::{ConfirmationRequest, TransactionModification, U256, TransactionCondition};
use ethereum_types::U256;
use rpc::signer::{ConfirmationRequest, TransactionModification, TransactionCondition};
use serde;
use serde_json::{Value as JsonValue, to_value};
use std::path::PathBuf;
Expand Down
4 changes: 3 additions & 1 deletion cli-signer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

extern crate ethereum_types;
extern crate futures;
extern crate rpassword;

extern crate parity_rpc as rpc;
extern crate parity_rpc_client as client;

use rpc::signer::{U256, ConfirmationRequest};
use ethereum_types::U256;
use rpc::signer::ConfirmationRequest;
use client::signer_client::SignerRpc;
use std::io::{Write, BufRead, BufReader, stdout, stdin};
use std::path::PathBuf;
Expand Down
4 changes: 1 addition & 3 deletions rpc/src/v1/helpers/dispatch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ use jsonrpc_core::{BoxFuture, Result, Error};
use jsonrpc_core::futures::{future, Future, IntoFuture};
use v1::helpers::{TransactionRequest, FilledTransactionRequest, ConfirmationPayload};
use v1::types::{
H520 as RpcH520, Bytes as RpcBytes,
Bytes as RpcBytes,
RichRawTransaction as RpcRichRawTransaction,
ConfirmationPayload as RpcConfirmationPayload,
ConfirmationResponse,
Expand Down Expand Up @@ -309,7 +309,6 @@ pub fn execute<D: Dispatcher + 'static>(
let res = signer.sign_message(address, pass, SignMessage::Data(data))
.map(|result| result
.map(|s| H520(s.into_electrum()))
.map(RpcH520::from)
.map(ConfirmationResponse::Signature)
);

Expand All @@ -319,7 +318,6 @@ pub fn execute<D: Dispatcher + 'static>(
let res = signer.sign_message(address, pass, SignMessage::Hash(data))
.map(|result| result
.map(|rsv| H520(rsv.into_electrum()))
.map(RpcH520::from)
.map(ConfirmationResponse::Signature)
);

Expand Down
1 change: 1 addition & 0 deletions rpc/src/v1/helpers/external_signer/signing_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

use std::collections::BTreeMap;

use ethereum_types::U256;
use parking_lot::{Mutex, RwLock};
use super::oneshot;
Expand Down
3 changes: 2 additions & 1 deletion rpc/src/v1/helpers/secretstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

use std::collections::BTreeSet;
use rand::{Rng, OsRng};
use ethereum_types::{H256, H512};
use ethkey::{self, Public, Secret, Random, Generator, math};
use crypto;
use bytes::Bytes;
use jsonrpc_core::Error;
use v1::helpers::errors;
use v1::types::{H256, H512, EncryptedDocumentKey};
use v1::types::EncryptedDocumentKey;
use tiny_keccak::Keccak;

/// Initialization vector length.
Expand Down
7 changes: 4 additions & 3 deletions rpc/src/v1/helpers/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

use ethkey::{recover, public_to_address, Signature};
use ethereum_types::{H256, U64};
use jsonrpc_core::Result;
use v1::types::{Bytes, RecoveredAccount, H256, U64};
use v1::types::{Bytes, RecoveredAccount};
use v1::helpers::errors;
use v1::helpers::dispatch::eth_data_hash;
use hash::keccak;
Expand All @@ -35,7 +36,7 @@ pub fn verify_signature(
} else {
keccak(message.0)
};
let v: u64 = v.into();
let v = v.as_u64();
let is_valid_for_current_chain = match (chain_id, v) {
(None, v) if v == 0 || v == 1 => true,
(Some(chain_id), v) if v >= 35 => (v - 35) / 2 == chain_id,
Expand All @@ -54,7 +55,7 @@ pub fn verify_signature(
mod tests {
use super::*;
use ethkey::Generator;
use v1::types::H160;
use ethereum_types::{H160, U64};

pub fn add_chain_replay_protection(v: u64, chain_id: Option<u64>) -> u64 {
v + if let Some(n) = chain_id { 35 + n * 2 } else { 0 }
Expand Down
5 changes: 3 additions & 2 deletions rpc/src/v1/helpers/subscribers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
use std::{ops, str};
use std::collections::HashMap;
use jsonrpc_pubsub::{typed::{Subscriber, Sink}, SubscriptionId};
use ethereum_types::H64;
use rand::{Rng, StdRng};
use v1::types::H64;

#[derive(Debug, Clone, Hash, Eq, PartialEq)]
pub struct Id(H64);
Expand All @@ -36,8 +36,9 @@ impl str::FromStr for Id {
}
}
impl Id {
// TODO: replace `format!` see [#10412](https://github.com/paritytech/parity-ethereum/issues/10412)
pub fn as_string(&self) -> String {
format!("0x{:?}", self.0)
format!("{:?}", self.0)
Copy link
Copy Markdown
Collaborator Author

@niklasad1 niklasad1 Jan 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be changed to serde_json::to_string_pretty(&self.0) for performance reasons but I think it is out-of-scope of this PR because it is large enough!

}
}

Expand Down
6 changes: 1 addition & 5 deletions rpc/src/v1/helpers/work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ use std::sync::Arc;

use rlp;
use ethcore::miner::{BlockChainClient, MinerService};
use ethereum_types::{H64 as EthcoreH64, H256 as EthcoreH256};
use ethereum_types::{H64, H256};
use jsonrpc_core::Error;
use v1::types::{H64, H256};
use v1::helpers::errors;

// Submit a POW work and return the block's hash
pub fn submit_work_detail<C: BlockChainClient, M: MinerService>(client: &Arc<C>, miner: &Arc<M>, nonce: H64, pow_hash: H256, mix_hash: H256) -> Result<H256, Error> {
// TODO [ToDr] Should disallow submissions in case of PoA?
let nonce: EthcoreH64 = nonce.into();
let pow_hash: EthcoreH256 = pow_hash.into();
let mix_hash: EthcoreH256 = mix_hash.into();
trace!(target: "miner", "submit_work_detail: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash);
let seal = vec![rlp::encode(&mix_hash), rlp::encode(&nonce)];
let import = miner.submit_seal(pow_hash, seal)
Expand Down
Loading