Merge pull request #785 from ethcore/author0x

Allow 0x prefix for --author.
This commit is contained in:
Marek Kotewicz 2016-03-20 10:19:58 +01:00
commit 865847f71d
2 changed files with 4 additions and 3 deletions

View File

@ -46,6 +46,7 @@ use env_logger::LogBuilder;
use ctrlc::CtrlC;
use util::*;
use util::panics::{MayPanic, ForwardPanic, PanicHandler};
use util::keys::store::*;
use ethcore::spec::*;
use ethcore::client::*;
use ethcore::service::{ClientService, NetSyncMessage};
@ -55,7 +56,6 @@ use ethminer::{Miner, MinerService};
use docopt::Docopt;
use daemonize::Daemonize;
use number_prefix::{binary_prefix, Standalone, Prefixed};
use util::keys::store::*;
fn die_with_message(msg: &str) -> ! {
println!("ERROR: {}", msg);
@ -315,7 +315,7 @@ impl Configuration {
fn author(&self) -> Address {
let d = self.args.flag_etherbase.as_ref().unwrap_or(&self.args.flag_author);
Address::from_str(d).unwrap_or_else(|_| {
Address::from_str(clean_0x(d)).unwrap_or_else(|_| {
die!("{}: Invalid address for --author. Must be 40 hex characters, without the 0x at the beginning.", d)
})
}

View File

@ -63,7 +63,8 @@ pub trait FixedHash: Sized + BytesConvertable + Populatable + FromStr + Default
fn low_u64(&self) -> u64;
}
fn clean_0x(s: &str) -> &str {
/// Return `s` without the `0x` at the beginning of it, if any.
pub fn clean_0x(s: &str) -> &str {
if s.len() >= 2 && &s[0..2] == "0x" {
&s[2..]
} else {