41 #include <boost/optional/optional.hpp> 42 #include <boost/program_options/variables_map.hpp> 53 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY 54 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "wallet.simplewallet" 56 constexpr
const char ETN_DONATION_ADDR[] =
"etnjwQwwEY65dhSMfKto64GgY7j7q2RUSZP1r8rXZ615J4egUC596R4crvZ5woWWTWBUztnKMUudzQ22E37LHiV48XWeJDFkkY";
70 static const char *
tr(
const char *str) {
return i18n_translate(str,
"cryptonote::simple_wallet"); }
76 bool init(
const boost::program_options::variables_map& vm);
88 enum ResetType { ResetNone, ResetSoft, ResetHard, ResetSoftKeepKI };
90 bool handle_command_line(
const boost::program_options::variables_map& vm);
92 bool run_console_handler();
94 void wallet_idle_thread();
97 boost::optional<tools::password_container> get_and_verify_password()
const;
99 boost::optional<epee::wipeable_string> new_wallet(
const boost::program_options::variables_map& vm,
const crypto::secret_key& recovery_key,
100 bool recover,
bool two_random,
const std::string &old_language);
102 const boost::optional<crypto::secret_key>& spendkey,
const crypto::secret_key& viewkey);
103 boost::optional<epee::wipeable_string> new_wallet(
const boost::program_options::variables_map& vm,
105 boost::optional<epee::wipeable_string> new_wallet(
const boost::program_options::variables_map& vm);
106 boost::optional<epee::wipeable_string> open_wallet(
const boost::program_options::variables_map& vm);
109 bool viewkey(
const std::vector<std::string> &args = std::vector<std::string>());
110 bool spendkey(
const std::vector<std::string> &args = std::vector<std::string>());
111 bool seed(
const std::vector<std::string> &args = std::vector<std::string>());
112 bool encrypted_seed(
const std::vector<std::string> &args = std::vector<std::string>());
123 bool seed_set_language(
const std::vector<std::string> &args = std::vector<std::string>());
124 bool set_always_confirm_transfers(
const std::vector<std::string> &args = std::vector<std::string>());
125 bool set_print_ring_members(
const std::vector<std::string> &args = std::vector<std::string>());
126 bool set_store_tx_info(
const std::vector<std::string> &args = std::vector<std::string>());
127 bool set_auto_refresh(
const std::vector<std::string> &args = std::vector<std::string>());
128 bool set_refresh_type(
const std::vector<std::string> &args = std::vector<std::string>());
129 bool set_confirm_missing_payment_id(
const std::vector<std::string> &args = std::vector<std::string>());
130 bool set_ask_password(
const std::vector<std::string> &args = std::vector<std::string>());
131 bool set_unit(
const std::vector<std::string> &args = std::vector<std::string>());
132 bool set_min_output_count(
const std::vector<std::string> &args = std::vector<std::string>());
133 bool set_min_output_value(
const std::vector<std::string> &args = std::vector<std::string>());
134 bool set_merge_destinations(
const std::vector<std::string> &args = std::vector<std::string>());
135 bool set_confirm_backlog(
const std::vector<std::string> &args = std::vector<std::string>());
136 bool set_confirm_backlog_threshold(
const std::vector<std::string> &args = std::vector<std::string>());
137 bool set_confirm_export_overwrite(
const std::vector<std::string> &args = std::vector<std::string>());
138 bool set_refresh_from_block_height(
const std::vector<std::string> &args = std::vector<std::string>());
139 bool set_auto_low_priority(
const std::vector<std::string> &args = std::vector<std::string>());
140 bool set_segregate_pre_fork_outputs(
const std::vector<std::string> &args = std::vector<std::string>());
141 bool set_key_reuse_mitigation2(
const std::vector<std::string> &args = std::vector<std::string>());
142 bool set_subaddress_lookahead(
const std::vector<std::string> &args = std::vector<std::string>());
143 bool set_segregation_height(
const std::vector<std::string> &args = std::vector<std::string>());
144 bool set_ignore_fractional_outputs(
const std::vector<std::string> &args = std::vector<std::string>());
145 bool set_track_uses(
const std::vector<std::string> &args = std::vector<std::string>());
146 bool set_setup_background_mining(
const std::vector<std::string> &args = std::vector<std::string>());
147 bool set_device_name(
const std::vector<std::string> &args = std::vector<std::string>());
148 bool help(
const std::vector<std::string> &args = std::vector<std::string>());
149 bool start_mining(
const std::vector<std::string> &args);
150 bool stop_mining(
const std::vector<std::string> &args);
151 bool set_daemon(
const std::vector<std::string> &args);
152 bool save_bc(
const std::vector<std::string> &args);
153 bool refresh(
const std::vector<std::string> &args);
154 bool show_balance_unlocked(
bool detailed =
false);
155 bool show_balance(
const std::vector<std::string> &args = std::vector<std::string>());
156 bool show_incoming_transfers(
const std::vector<std::string> &args);
157 bool show_payments(
const std::vector<std::string> &args);
158 bool show_blockchain_height(
const std::vector<std::string> &args);
159 bool transfer_main(
int transfer_type,
const std::vector<std::string> &args,
bool called_by_mms);
160 bool transfer(
const std::vector<std::string> &args);
161 bool locked_transfer(
const std::vector<std::string> &args);
162 bool locked_sweep_all(
const std::vector<std::string> &args);
163 bool sweep_main(
uint64_t below,
bool locked,
const std::vector<std::string> &args);
164 bool sweep_all(
const std::vector<std::string> &args);
165 bool sweep_below(
const std::vector<std::string> &args);
166 bool sweep_single(
const std::vector<std::string> &args);
167 bool sweep_unmixable(
const std::vector<std::string> &args);
168 bool donate(
const std::vector<std::string> &args);
169 bool sign_transfer(
const std::vector<std::string> &args);
170 bool submit_transfer(
const std::vector<std::string> &args);
171 std::vector<std::vector<cryptonote::tx_destination_entry>> split_amounts(
172 std::vector<cryptonote::tx_destination_entry> dsts,
size_t num_splits
174 bool account(
const std::vector<std::string> &args = std::vector<std::string>());
175 void print_accounts();
177 bool print_address(
const std::vector<std::string> &args = std::vector<std::string>());
178 bool print_integrated_address(
const std::vector<std::string> &args = std::vector<std::string>());
179 bool address_book(
const std::vector<std::string> &args = std::vector<std::string>());
180 bool save(
const std::vector<std::string> &args);
181 bool save_watch_only(
const std::vector<std::string> &args);
182 bool set_variable(
const std::vector<std::string> &args);
183 bool rescan_spent(
const std::vector<std::string> &args);
184 bool set_log(
const std::vector<std::string> &args);
185 bool get_tx_key(
const std::vector<std::string> &args);
186 bool set_tx_key(
const std::vector<std::string> &args);
187 bool check_tx_key(
const std::vector<std::string> &args);
188 bool get_tx_proof(
const std::vector<std::string> &args);
189 bool check_tx_proof(
const std::vector<std::string> &args);
190 bool get_spend_proof(
const std::vector<std::string> &args);
191 bool check_spend_proof(
const std::vector<std::string> &args);
192 bool get_reserve_proof(
const std::vector<std::string> &args);
193 bool check_reserve_proof(
const std::vector<std::string> &args);
194 bool show_transfers(
const std::vector<std::string> &args);
195 bool export_transfers(
const std::vector<std::string> &args);
196 bool unspent_outputs(
const std::vector<std::string> &args);
197 bool rescan_blockchain(
const std::vector<std::string> &args);
198 bool refresh_main(
uint64_t start_height, ResetType reset,
bool is_init =
false);
199 bool set_tx_note(
const std::vector<std::string> &args);
200 bool get_tx_note(
const std::vector<std::string> &args);
201 bool set_description(
const std::vector<std::string> &args);
202 bool get_description(
const std::vector<std::string> &args);
203 bool status(
const std::vector<std::string> &args);
204 bool wallet_info(
const std::vector<std::string> &args);
205 bool set_default_ring_size(
const std::vector<std::string> &args);
206 bool set_default_priority(
const std::vector<std::string> &args);
207 bool sign(
const std::vector<std::string> &args);
208 bool verify(
const std::vector<std::string> &args);
209 bool export_key_images(
const std::vector<std::string> &args);
210 bool import_key_images(
const std::vector<std::string> &args);
211 bool hw_key_images_sync(
const std::vector<std::string> &args);
212 bool hw_reconnect(
const std::vector<std::string> &args);
213 bool export_outputs(
const std::vector<std::string> &args);
214 bool import_outputs(
const std::vector<std::string> &args);
215 bool show_transfer(
const std::vector<std::string> &args);
216 bool change_password(
const std::vector<std::string>& args);
217 bool payment_id(
const std::vector<std::string> &args);
218 bool print_fee_info(
const std::vector<std::string> &args);
219 bool prepare_multisig(
const std::vector<std::string>& args);
220 bool prepare_multisig_main(
const std::vector<std::string>& args,
bool called_by_mms);
221 bool make_multisig(
const std::vector<std::string>& args);
222 bool make_multisig_main(
const std::vector<std::string>& args,
bool called_by_mms);
223 bool finalize_multisig(
const std::vector<std::string> &args);
224 bool exchange_multisig_keys(
const std::vector<std::string> &args);
225 bool exchange_multisig_keys_main(
const std::vector<std::string> &args,
bool called_by_mms);
226 bool export_multisig(
const std::vector<std::string>& args);
227 bool export_multisig_main(
const std::vector<std::string>& args,
bool called_by_mms);
228 bool import_multisig(
const std::vector<std::string>& args);
229 bool import_multisig_main(
const std::vector<std::string>& args,
bool called_by_mms);
231 bool sign_multisig(
const std::vector<std::string>& args);
232 bool sign_multisig_main(
const std::vector<std::string>& args,
bool called_by_mms);
233 bool submit_multisig(
const std::vector<std::string>& args);
234 bool submit_multisig_main(
const std::vector<std::string>& args,
bool called_by_mms);
235 bool export_raw_multisig(
const std::vector<std::string>& args);
236 bool mms(
const std::vector<std::string>& args);
237 bool print_ring(
const std::vector<std::string>& args);
238 bool set_ring(
const std::vector<std::string>& args);
239 bool unset_ring(
const std::vector<std::string>& args);
240 bool save_known_rings(
const std::vector<std::string>& args);
241 bool blackball(
const std::vector<std::string>& args);
242 bool unblackball(
const std::vector<std::string>& args);
243 bool blackballed(
const std::vector<std::string>& args);
244 bool freeze(
const std::vector<std::string>& args);
245 bool thaw(
const std::vector<std::string>& args);
246 bool frozen(
const std::vector<std::string>& args);
247 bool net_stats(
const std::vector<std::string>& args);
248 bool welcome(
const std::vector<std::string>& args);
249 bool version(
const std::vector<std::string>& args);
251 bool set_account_major_offset(
const std::vector<std::string> &args = std::vector<std::string>());
255 bool try_connect_to_daemon(
bool silent =
false,
uint32_t* version =
nullptr);
256 bool ask_wallet_create_if_needed();
260 bool print_ring_members(
const std::vector<tools::wallet2::pending_tx>& ptx_vector, std::ostream& ostr);
262 bool print_seed(
bool encrypted);
263 void key_images_sync_intern();
264 void on_refresh_finished(
uint64_t start_height,
uint64_t fetched_blocks,
bool is_init,
bool received_etn);
265 std::pair<std::string, std::string> show_outputs_line(
const std::vector<uint64_t> &heights,
uint64_t blockchain_height,
uint64_t highlight_height = std::numeric_limits<uint64_t>::max())
const;
266 bool freeze_thaw(
const std::vector<std::string>& args,
bool freeze);
271 boost::variant<uint64_t, std::string>
block;
279 std::vector<std::pair<std::string, uint64_t>> outputs;
280 std::set<uint32_t> index;
284 bool get_transfers(std::vector<std::string>& args_, std::vector<transfer_view>& transfers);
305 void commit_or_save(std::vector<tools::wallet2::pending_tx>& ptx_vector,
bool do_not_relay);
311 void start_background_mining();
312 void stop_background_mining();
320 virtual boost::optional<epee::wipeable_string> on_get_password(
const char *reason);
321 virtual void on_device_button_request(
uint64_t code);
322 virtual boost::optional<epee::wipeable_string> on_device_pin_request();
323 virtual boost::optional<epee::wipeable_string> on_device_passphrase_request(
bool on_device);
333 , m_blockchain_height(0)
334 , m_blockchain_height_update_time()
341 auto current_time = std::chrono::system_clock::now();
343 if (node_update_threshold < current_time - m_blockchain_height_update_time || m_blockchain_height <=
height)
345 update_blockchain_height();
346 m_blockchain_height = (std::max)(m_blockchain_height,
height);
349 if (std::chrono::milliseconds(20) < current_time - m_print_time || force)
351 std::cout <<
QT_TRANSLATE_NOOP(
"cryptonote::simple_wallet",
"Height ") <<
height <<
" / " << m_blockchain_height <<
'\r' << std::flush;
352 m_print_time = current_time;
357 void update_blockchain_height()
360 uint64_t blockchain_height = m_simple_wallet.get_daemon_blockchain_height(err);
363 m_blockchain_height = blockchain_height;
364 m_blockchain_height_update_time = std::chrono::system_clock::now();
368 LOG_ERROR(
"Failed to get current blockchain height: " << err);
375 std::chrono::system_clock::time_point m_blockchain_height_update_time;
376 std::chrono::system_clock::time_point m_print_time;
396 bool m_restore_deterministic_wallet;
397 bool m_restore_multisig_wallet;
398 bool m_non_deterministic;
399 bool m_allow_mismatched_daemon_version;
403 bool m_use_english_language_names;
408 std::unique_ptr<tools::wallet2> m_wallet;
411 std::atomic<bool> m_idle_run;
412 boost::thread m_idle_thread;
413 boost::mutex m_idle_mutex;
414 boost::condition_variable m_idle_cond;
416 std::atomic<bool> m_auto_refresh_enabled;
417 bool m_auto_refresh_refreshing;
418 std::atomic<bool> m_in_manual_refresh;
419 uint32_t m_current_subaddress_account;
421 bool m_long_payment_id_support;
426 bool mms_active()
const {
return get_message_store().
get_active(); };
427 bool choose_mms_processing(
const std::vector<mms::processing_data> &data_list,
uint32_t &
choice);
428 void list_mms_messages(
const std::vector<mms::message> &messages);
429 void list_signers(
const std::vector<mms::authorized_signer> &signers);
430 void add_signer_config_messages();
432 void ask_send_all_ready_messages();
433 void check_for_messages();
438 void mms_init(
const std::vector<std::string> &args);
439 void mms_info(
const std::vector<std::string> &args);
440 void mms_signer(
const std::vector<std::string> &args);
441 void mms_list(
const std::vector<std::string> &args);
442 void mms_next(
const std::vector<std::string> &args);
443 void mms_sync(
const std::vector<std::string> &args);
444 void mms_transfer(
const std::vector<std::string> &args);
445 void mms_delete(
const std::vector<std::string> &args);
446 void mms_send(
const std::vector<std::string> &args);
447 void mms_receive(
const std::vector<std::string> &args);
448 void mms_export(
const std::vector<std::string> &args);
449 void mms_note(
const std::vector<std::string> &args);
450 void mms_show(
const std::vector<std::string> &args);
451 void mms_set(
const std::vector<std::string> &args);
452 void mms_help(
const std::vector<std::string> &args);
453 void mms_send_signer_config(
const std::vector<std::string> &args);
454 void mms_start_auto_config(
const std::vector<std::string> &args);
455 void mms_stop_auto_config(
const std::vector<std::string> &args);
456 void mms_auto_config(
const std::vector<std::string> &args);
static const char * tr(const char *str)
#define QT_TRANSLATE_NOOP(context, str)
std::string get_command_usage(const std::vector< std::string > &args)
bool process_command(const std::vector< std::string > &args)
const char * i18n_translate(const char *s, const std::string &context)
Holds cryptonote related classes and helpers.
Manages wallet operations. This is the most abstracted wallet class.
friend class refresh_progress_reporter_t
unsigned __int64 uint64_t
bool init(const boost::program_options::variables_map &vm)
std::string get_commands_str()
#define DIFFICULTY_TARGET
std::vector< std::string > command_type
constexpr const char ETN_DONATION_ADDR[]