1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#[macro_use]
extern crate clap;
#[macro_use]
extern crate log;
use crate::core::global;
use crate::util::init_logger;
use clap::App;
use epic_wallet_config as config;
use epic_wallet_impls::HTTPNodeClient;
use epic_wallet_util::epic_core as core;
use epic_wallet_util::epic_util as util;
use std::env;
use epic_wallet::cmd;
pub mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
pub fn info_strings() -> (String, String) {
(
format!(
"This is Epic Wallet version {}{}, built for {} by {}.",
built_info::PKG_VERSION,
built_info::GIT_VERSION.map_or_else(|| "".to_owned(), |v| format!(" (git {})", v)),
built_info::TARGET,
built_info::RUSTC_VERSION,
)
.to_string(),
format!(
"Built with profile \"{}\", features \"{}\".",
built_info::PROFILE,
built_info::FEATURES_STR,
)
.to_string(),
)
}
fn log_build_info() {
let (basic_info, detailed_info) = info_strings();
info!("{}", basic_info);
debug!("{}", detailed_info);
}
fn main() {
let exit_code = real_main();
std::process::exit(exit_code);
}
fn real_main() -> i32 {
let yml = load_yaml!("epic-wallet.yml");
let args = App::from_yaml(yml)
.version(built_info::PKG_VERSION)
.get_matches();
let chain_type = if args.is_present("floonet") {
global::ChainTypes::Floonet
} else if args.is_present("usernet") {
global::ChainTypes::UserTesting
} else {
global::ChainTypes::Mainnet
};
let mut current_dir = None;
match args.subcommand() {
("init", Some(init_args)) => {
if init_args.is_present("here") {
current_dir = Some(env::current_dir().unwrap_or_else(|e| {
panic!("Error creating config file: {}", e);
}));
}
}
_ => {}
}
let mut config = config::initial_setup_wallet(&chain_type, current_dir).unwrap_or_else(|e| {
panic!("Error loading wallet configuration: {}", e);
});
let l = config.members.as_mut().unwrap().logging.clone().unwrap();
init_logger(Some(l), None);
info!(
"Using wallet configuration file at {}",
config.config_file_path.as_ref().unwrap().to_str().unwrap()
);
log_build_info();
global::set_mining_mode(
config
.members
.as_ref()
.unwrap()
.wallet
.chain_type
.as_ref()
.unwrap()
.clone(),
);
let wallet_config = config.clone().members.unwrap().wallet;
let node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None);
cmd::wallet_command(&args, config, node_client)
}