mirror of
https://github.com/monero-project/monero.git
synced 2025-08-15 20:00:22 -04:00
wallet: background sync with just the view key
- When background syncing, the wallet wipes the spend key from memory and processes all new transactions. The wallet saves all receives, spends, and "plausible" spends of receives the wallet does not know key images for. - When background sync disabled, the wallet processes all background synced txs and then clears the background sync cache. - Adding "plausible" spends to the background sync cache ensures that the wallet does not need to query the daemon to see if any received outputs were spent while background sync was enabled. This would harm privacy especially for users of 3rd party daemons. - To enable the feature in the CLI wallet, the user can set background-sync to reuse-wallet-password or custom-background-password and the wallet automatically syncs in the background when the wallet locks, then processes all background synced txs when the wallet is unlocked. - The custom-background-password option enables the user to open a distinct background wallet that only has a view key saved and can be opened/closed/synced separately from the main wallet. When the main wallet opens, it processes the background wallet's cache. - To enable the feature in the RPC wallet, there is a new `/setup_background_sync` endpoint. - HW, multsig and view-only wallets cannot background sync.
This commit is contained in:
parent
24ccaba6ef
commit
e44e8b1640
20 changed files with 2342 additions and 135 deletions
|
@ -155,6 +155,17 @@ typedef cryptonote::simple_wallet sw;
|
|||
} \
|
||||
} while(0)
|
||||
|
||||
#define CHECK_IF_BACKGROUND_SYNCING(msg) \
|
||||
do \
|
||||
{ \
|
||||
if (m_wallet->is_background_wallet() || m_wallet->is_background_syncing()) \
|
||||
{ \
|
||||
std::string type = m_wallet->is_background_wallet() ? "background wallet" : "background syncing wallet"; \
|
||||
fail_msg_writer() << boost::format(tr("%s %s")) % type % msg; \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static std::string get_human_readable_timespan(std::chrono::seconds seconds);
|
||||
static std::string get_human_readable_timespan(uint64_t seconds);
|
||||
|
||||
|
@ -325,7 +336,7 @@ namespace
|
|||
auto pwd_container = tools::password_container::prompt(verify, prompt);
|
||||
if (!pwd_container)
|
||||
{
|
||||
tools::fail_msg_writer() << sw::tr("failed to read wallet password");
|
||||
tools::fail_msg_writer() << sw::tr("failed to read password");
|
||||
}
|
||||
return pwd_container;
|
||||
}
|
||||
|
@ -335,6 +346,11 @@ namespace
|
|||
return password_prompter(verify ? sw::tr("Enter a new password for the wallet") : sw::tr("Wallet password"), verify);
|
||||
}
|
||||
|
||||
boost::optional<tools::password_container> background_sync_cache_password_prompter(bool verify)
|
||||
{
|
||||
return password_prompter(verify ? sw::tr("Enter a custom password for the background sync cache") : sw::tr("Background sync cache password"), verify);
|
||||
}
|
||||
|
||||
inline std::string interpret_rpc_response(bool ok, const std::string& status)
|
||||
{
|
||||
std::string err;
|
||||
|
@ -452,6 +468,41 @@ namespace
|
|||
return "invalid";
|
||||
}
|
||||
|
||||
const struct
|
||||
{
|
||||
const char *name;
|
||||
tools::wallet2::BackgroundSyncType background_sync_type;
|
||||
} background_sync_type_names[] =
|
||||
{
|
||||
{ "off", tools::wallet2::BackgroundSyncOff },
|
||||
{ "reuse-wallet-password", tools::wallet2::BackgroundSyncReusePassword },
|
||||
{ "custom-background-password", tools::wallet2::BackgroundSyncCustomPassword },
|
||||
};
|
||||
|
||||
bool parse_background_sync_type(const std::string &s, tools::wallet2::BackgroundSyncType &background_sync_type)
|
||||
{
|
||||
for (size_t n = 0; n < sizeof(background_sync_type_names) / sizeof(background_sync_type_names[0]); ++n)
|
||||
{
|
||||
if (s == background_sync_type_names[n].name)
|
||||
{
|
||||
background_sync_type = background_sync_type_names[n].background_sync_type;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
fail_msg_writer() << cryptonote::simple_wallet::tr("failed to parse background sync type");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string get_background_sync_type_name(tools::wallet2::BackgroundSyncType type)
|
||||
{
|
||||
for (size_t n = 0; n < sizeof(background_sync_type_names) / sizeof(background_sync_type_names[0]); ++n)
|
||||
{
|
||||
if (type == background_sync_type_names[n].background_sync_type)
|
||||
return background_sync_type_names[n].name;
|
||||
}
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
std::string get_version_string(uint32_t version)
|
||||
{
|
||||
return boost::lexical_cast<std::string>(version >> 16) + "." + boost::lexical_cast<std::string>(version & 0xffff);
|
||||
|
@ -805,6 +856,7 @@ bool simple_wallet::spendkey(const std::vector<std::string> &args/* = std::vecto
|
|||
fail_msg_writer() << tr("wallet is watch-only and has no spend key");
|
||||
return true;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("has no spend key");
|
||||
// don't log
|
||||
PAUSE_READLINE();
|
||||
if (m_wallet->key_on_device()) {
|
||||
|
@ -836,6 +888,7 @@ bool simple_wallet::print_seed(bool encrypted)
|
|||
fail_msg_writer() << tr("wallet is watch-only and has no seed");
|
||||
return true;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("has no seed");
|
||||
|
||||
multisig = m_wallet->multisig(&ready);
|
||||
if (multisig)
|
||||
|
@ -913,6 +966,7 @@ bool simple_wallet::seed_set_language(const std::vector<std::string> &args/* = s
|
|||
fail_msg_writer() << tr("wallet is watch-only and has no seed");
|
||||
return true;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("has no seed");
|
||||
|
||||
epee::wipeable_string password;
|
||||
{
|
||||
|
@ -1059,6 +1113,7 @@ bool simple_wallet::prepare_multisig_main(const std::vector<std::string> &args,
|
|||
fail_msg_writer() << tr("wallet is watch-only and cannot be made multisig");
|
||||
return false;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot be made multisig");
|
||||
|
||||
if(m_wallet->get_num_transfer_details())
|
||||
{
|
||||
|
@ -2195,6 +2250,7 @@ bool simple_wallet::save_known_rings(const std::vector<std::string> &args)
|
|||
|
||||
bool simple_wallet::freeze_thaw(const std::vector<std::string> &args, bool freeze)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot freeze/thaw");
|
||||
if (args.empty())
|
||||
{
|
||||
fail_msg_writer() << boost::format(tr("usage: %s <key_image>|<pubkey>")) % (freeze ? "freeze" : "thaw");
|
||||
|
@ -2234,6 +2290,7 @@ bool simple_wallet::thaw(const std::vector<std::string> &args)
|
|||
|
||||
bool simple_wallet::frozen(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot see frozen key images");
|
||||
if (args.empty())
|
||||
{
|
||||
size_t ntd = m_wallet->get_num_transfer_details();
|
||||
|
@ -3005,6 +3062,57 @@ bool simple_wallet::set_track_uses(const std::vector<std::string> &args/* = std:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool simple_wallet::setup_background_sync(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||
{
|
||||
if (m_wallet->multisig())
|
||||
{
|
||||
fail_msg_writer() << tr("background sync not implemented for multisig wallet");
|
||||
return true;
|
||||
}
|
||||
if (m_wallet->watch_only())
|
||||
{
|
||||
fail_msg_writer() << tr("background sync not implemented for watch only wallet");
|
||||
return true;
|
||||
}
|
||||
if (m_wallet->key_on_device())
|
||||
{
|
||||
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||
return true;
|
||||
}
|
||||
|
||||
tools::wallet2::BackgroundSyncType background_sync_type;
|
||||
if (!parse_background_sync_type(args[1], background_sync_type))
|
||||
{
|
||||
fail_msg_writer() << tr("invalid option");
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto pwd_container = get_and_verify_password();
|
||||
if (!pwd_container)
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
boost::optional<epee::wipeable_string> background_cache_password = boost::none;
|
||||
if (background_sync_type == tools::wallet2::BackgroundSyncCustomPassword)
|
||||
{
|
||||
const auto background_pwd_container = background_sync_cache_password_prompter(true);
|
||||
if (!background_pwd_container)
|
||||
return true;
|
||||
background_cache_password = background_pwd_container->password();
|
||||
}
|
||||
|
||||
LOCK_IDLE_SCOPE();
|
||||
m_wallet->setup_background_sync(background_sync_type, pwd_container->password(), background_cache_password);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
fail_msg_writer() << tr("Error setting background sync type: ") << e.what();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool simple_wallet::set_show_wallet_name_when_locked(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||
{
|
||||
const auto pwd_container = get_and_verify_password();
|
||||
|
@ -3237,6 +3345,7 @@ bool simple_wallet::apropos(const std::vector<std::string> &args)
|
|||
|
||||
bool simple_wallet::scan_tx(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot scan tx");
|
||||
if (args.empty())
|
||||
{
|
||||
PRINT_USAGE(USAGE_SCAN_TX);
|
||||
|
@ -3458,6 +3567,8 @@ simple_wallet::simple_wallet()
|
|||
" Ignore outputs of amount below this threshold when spending.\n "
|
||||
"track-uses <1|0>\n "
|
||||
" Whether to keep track of owned outputs uses.\n "
|
||||
"background-sync <off|reuse-wallet-password|custom-background-password>\n "
|
||||
" Set this to enable scanning in the background with just the view key while the wallet is locked.\n "
|
||||
"setup-background-mining <1|0>\n "
|
||||
" Whether to enable background mining. Set this to support the network and to get a chance to receive new monero.\n "
|
||||
"device-name <device_name[:device_spec]>\n "
|
||||
|
@ -3876,6 +3987,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
|
|||
success_msg_writer() << "ignore-outputs-above = " << cryptonote::print_money(m_wallet->ignore_outputs_above());
|
||||
success_msg_writer() << "ignore-outputs-below = " << cryptonote::print_money(m_wallet->ignore_outputs_below());
|
||||
success_msg_writer() << "track-uses = " << m_wallet->track_uses();
|
||||
success_msg_writer() << "background-sync = " << get_background_sync_type_name(m_wallet->background_sync_type());
|
||||
success_msg_writer() << "setup-background-mining = " << setup_background_mining_string;
|
||||
success_msg_writer() << "device-name = " << m_wallet->device_name();
|
||||
success_msg_writer() << "export-format = " << (m_wallet->export_format() == tools::wallet2::ExportFormat::Ascii ? "ascii" : "binary");
|
||||
|
@ -3894,6 +4006,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
|
|||
}
|
||||
else
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot change wallet settings");
|
||||
|
||||
#define CHECK_SIMPLE_VARIABLE(name, f, help) do \
|
||||
if (args[0] == name) { \
|
||||
|
@ -3947,6 +4060,7 @@ bool simple_wallet::set_variable(const std::vector<std::string> &args)
|
|||
CHECK_SIMPLE_VARIABLE("ignore-outputs-above", set_ignore_outputs_above, tr("amount"));
|
||||
CHECK_SIMPLE_VARIABLE("ignore-outputs-below", set_ignore_outputs_below, tr("amount"));
|
||||
CHECK_SIMPLE_VARIABLE("track-uses", set_track_uses, tr("0 or 1"));
|
||||
CHECK_SIMPLE_VARIABLE("background-sync", setup_background_sync, tr("off (default); reuse-wallet-password (reuse the wallet password to encrypt the background cache); custom-background-password (use a custom background password to encrypt the background cache)"));
|
||||
CHECK_SIMPLE_VARIABLE("show-wallet-name-when-locked", set_show_wallet_name_when_locked, tr("1 or 0"));
|
||||
CHECK_SIMPLE_VARIABLE("inactivity-lock-timeout", set_inactivity_lock_timeout, tr("unsigned integer (seconds, 0 to disable)"));
|
||||
CHECK_SIMPLE_VARIABLE("setup-background-mining", set_setup_background_mining, tr("1/yes or 0/no"));
|
||||
|
@ -4900,7 +5014,10 @@ std::string simple_wallet::get_mnemonic_language()
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
boost::optional<tools::password_container> simple_wallet::get_and_verify_password() const
|
||||
{
|
||||
auto pwd_container = default_password_prompter(m_wallet_file.empty());
|
||||
const bool verify = m_wallet_file.empty();
|
||||
auto pwd_container = (m_wallet->is_background_wallet() && m_wallet->background_sync_type() == tools::wallet2::BackgroundSyncCustomPassword)
|
||||
? background_sync_cache_password_prompter(verify)
|
||||
: default_password_prompter(verify);
|
||||
if (!pwd_container)
|
||||
return boost::none;
|
||||
|
||||
|
@ -5203,6 +5320,8 @@ boost::optional<epee::wipeable_string> simple_wallet::open_wallet(const boost::p
|
|||
prefix = tr("Opened watch-only wallet");
|
||||
else if (m_wallet->multisig(&ready, &threshold, &total))
|
||||
prefix = (boost::format(tr("Opened %u/%u multisig wallet%s")) % threshold % total % (ready ? "" : " (not yet finalized)")).str();
|
||||
else if (m_wallet->is_background_wallet())
|
||||
prefix = tr("Opened background wallet");
|
||||
else
|
||||
prefix = tr("Opened wallet");
|
||||
message_writer(console_color_white, true) <<
|
||||
|
@ -5411,6 +5530,10 @@ void simple_wallet::stop_background_mining()
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
void simple_wallet::check_background_mining(const epee::wipeable_string &password)
|
||||
{
|
||||
// Background mining can be toggled from the main wallet
|
||||
if (m_wallet->is_background_wallet() || m_wallet->is_background_syncing())
|
||||
return;
|
||||
|
||||
tools::wallet2::BackgroundMiningSetupType setup = m_wallet->setup_background_mining();
|
||||
if (setup == tools::wallet2::BackgroundMiningNo)
|
||||
{
|
||||
|
@ -6275,6 +6398,7 @@ bool simple_wallet::show_blockchain_height(const std::vector<std::string>& args)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::rescan_spent(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot rescan spent");
|
||||
if (!m_wallet->is_trusted_daemon())
|
||||
{
|
||||
fail_msg_writer() << tr("this command requires a trusted daemon. Enable with --trusted-daemon");
|
||||
|
@ -6532,10 +6656,27 @@ void simple_wallet::check_for_inactivity_lock(bool user)
|
|||
" || ||" << std::endl <<
|
||||
"" << std::endl;
|
||||
}
|
||||
|
||||
bool started_background_sync = false;
|
||||
if (!m_wallet->is_background_wallet() &&
|
||||
m_wallet->background_sync_type() != tools::wallet2::BackgroundSyncOff)
|
||||
{
|
||||
LOCK_IDLE_SCOPE();
|
||||
m_wallet->start_background_sync();
|
||||
started_background_sync = true;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
const char *inactivity_msg = user ? "" : tr("Locked due to inactivity.");
|
||||
tools::msg_writer() << inactivity_msg << (inactivity_msg[0] ? " " : "") << tr("The wallet password is required to unlock the console.");
|
||||
tools::msg_writer() << inactivity_msg << (inactivity_msg[0] ? " " : "") << (
|
||||
(m_wallet->is_background_wallet() && m_wallet->background_sync_type() == tools::wallet2::BackgroundSyncCustomPassword)
|
||||
? tr("The background password is required to unlock the console.")
|
||||
: tr("The wallet password is required to unlock the console.")
|
||||
);
|
||||
|
||||
if (m_wallet->is_background_syncing())
|
||||
tools::msg_writer() << tr("\nSyncing in the background while locked...") << std::endl;
|
||||
|
||||
const bool show_wallet_name = m_wallet->show_wallet_name_when_locked();
|
||||
if (show_wallet_name)
|
||||
|
@ -6548,8 +6689,16 @@ void simple_wallet::check_for_inactivity_lock(bool user)
|
|||
}
|
||||
try
|
||||
{
|
||||
if (get_and_verify_password())
|
||||
const auto pwd_container = get_and_verify_password();
|
||||
if (pwd_container)
|
||||
{
|
||||
if (started_background_sync)
|
||||
{
|
||||
LOCK_IDLE_SCOPE();
|
||||
m_wallet->stop_background_sync(pwd_container->password());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (...) { /* do nothing, just let the loop loop */ }
|
||||
}
|
||||
|
@ -6576,6 +6725,7 @@ bool simple_wallet::on_command(bool (simple_wallet::*cmd)(const std::vector<std:
|
|||
bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool called_by_mms)
|
||||
{
|
||||
// "transfer [index=<N1>[,<N2>,...]] [<priority>] [<ring_size>] <address> <amount> [<payment_id>]"
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot transfer");
|
||||
if (!try_connect_to_daemon())
|
||||
return false;
|
||||
|
||||
|
@ -7004,6 +7154,7 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::transfer(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot transfer");
|
||||
if (args_.size() < 1)
|
||||
{
|
||||
PRINT_USAGE(USAGE_TRANSFER);
|
||||
|
@ -7016,6 +7167,7 @@ bool simple_wallet::transfer(const std::vector<std::string> &args_)
|
|||
|
||||
bool simple_wallet::sweep_unmixable(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot sweep");
|
||||
if (!try_connect_to_daemon())
|
||||
return true;
|
||||
|
||||
|
@ -7123,6 +7275,7 @@ bool simple_wallet::sweep_unmixable(const std::vector<std::string> &args_)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot sweep");
|
||||
auto print_usage = [this, account, below]()
|
||||
{
|
||||
if (below)
|
||||
|
@ -7404,6 +7557,7 @@ bool simple_wallet::sweep_main(uint32_t account, uint64_t below, const std::vect
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot sweep");
|
||||
if (!try_connect_to_daemon())
|
||||
return true;
|
||||
|
||||
|
@ -7642,12 +7796,14 @@ bool simple_wallet::sweep_single(const std::vector<std::string> &args_)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_all(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot sweep");
|
||||
sweep_main(m_current_subaddress_account, 0, args_);
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_account(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot sweep");
|
||||
auto local_args = args_;
|
||||
if (local_args.empty())
|
||||
{
|
||||
|
@ -7668,6 +7824,7 @@ bool simple_wallet::sweep_account(const std::vector<std::string> &args_)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_below(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot sweep");
|
||||
uint64_t below = 0;
|
||||
if (args_.size() < 1)
|
||||
{
|
||||
|
@ -7686,6 +7843,7 @@ bool simple_wallet::sweep_below(const std::vector<std::string> &args_)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::donate(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot donate");
|
||||
std::vector<std::string> local_args = args_;
|
||||
if(local_args.empty() || local_args.size() > 5)
|
||||
{
|
||||
|
@ -7747,6 +7905,7 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes, const std::function<const tools::wallet2::tx_construction_data&(size_t)> &get_tx, const std::string &extra_message)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot load tx");
|
||||
// gather info to ask the user
|
||||
uint64_t amount = 0, amount_to_dests = 0, change = 0;
|
||||
size_t min_ring_size = ~0;
|
||||
|
@ -7927,6 +8086,7 @@ bool simple_wallet::sign_transfer(const std::vector<std::string> &args_)
|
|||
fail_msg_writer() << tr("This is a watch only wallet");
|
||||
return true;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot sign transfer");
|
||||
|
||||
bool export_raw = false;
|
||||
std::string unsigned_filename = "unsigned_monero_tx";
|
||||
|
@ -8034,6 +8194,8 @@ std::string get_tx_key_stream(crypto::secret_key tx_key, std::vector<crypto::sec
|
|||
|
||||
bool simple_wallet::get_tx_key(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot get tx key");
|
||||
|
||||
std::vector<std::string> local_args = args_;
|
||||
|
||||
if (m_wallet->key_on_device() && m_wallet->get_account().get_device().get_type() != hw::device::TREZOR)
|
||||
|
@ -8074,6 +8236,8 @@ bool simple_wallet::get_tx_key(const std::vector<std::string> &args_)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::set_tx_key(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot set tx key");
|
||||
|
||||
std::vector<std::string> local_args = args_;
|
||||
|
||||
if(local_args.size() != 2 && local_args.size() != 3) {
|
||||
|
@ -8150,6 +8314,8 @@ bool simple_wallet::set_tx_key(const std::vector<std::string> &args_)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::get_tx_proof(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot get tx proof");
|
||||
|
||||
if (args.size() != 2 && args.size() != 3)
|
||||
{
|
||||
PRINT_USAGE(USAGE_GET_TX_PROOF);
|
||||
|
@ -8356,6 +8522,7 @@ bool simple_wallet::check_tx_proof(const std::vector<std::string> &args)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::get_spend_proof(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot get spend proof");
|
||||
if (m_wallet->key_on_device())
|
||||
{
|
||||
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||
|
@ -8440,6 +8607,7 @@ bool simple_wallet::check_spend_proof(const std::vector<std::string> &args)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::get_reserve_proof(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot get reserve proof");
|
||||
if (m_wallet->key_on_device())
|
||||
{
|
||||
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||
|
@ -9126,6 +9294,8 @@ bool simple_wallet::unspent_outputs(const std::vector<std::string> &args_)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::rescan_blockchain(const std::vector<std::string> &args_)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot rescan");
|
||||
|
||||
uint64_t start_height = 0;
|
||||
ResetType reset_type = ResetSoft;
|
||||
|
||||
|
@ -9423,6 +9593,7 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
|
|||
if (command == "new")
|
||||
{
|
||||
// create a new account and switch to it
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot create new account");
|
||||
std::string label = boost::join(local_args, " ");
|
||||
if (label.empty())
|
||||
label = tr("(Untitled account)");
|
||||
|
@ -9453,6 +9624,7 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
|
|||
else if (command == "label" && local_args.size() >= 1)
|
||||
{
|
||||
// set label of the specified account
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot modify account");
|
||||
uint32_t index_major;
|
||||
if (!epee::string_tools::get_xtype_from_string(index_major, local_args[0]))
|
||||
{
|
||||
|
@ -9474,6 +9646,7 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
|
|||
}
|
||||
else if (command == "tag" && local_args.size() >= 2)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot modify account");
|
||||
const std::string tag = local_args[0];
|
||||
std::set<uint32_t> account_indices;
|
||||
for (size_t i = 1; i < local_args.size(); ++i)
|
||||
|
@ -9498,6 +9671,7 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
|
|||
}
|
||||
else if (command == "untag" && local_args.size() >= 1)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot modify account");
|
||||
std::set<uint32_t> account_indices;
|
||||
for (size_t i = 0; i < local_args.size(); ++i)
|
||||
{
|
||||
|
@ -9521,6 +9695,7 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
|
|||
}
|
||||
else if (command == "tag_description" && local_args.size() >= 1)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot modify account");
|
||||
const std::string tag = local_args[0];
|
||||
std::string description;
|
||||
if (local_args.size() > 1)
|
||||
|
@ -9638,6 +9813,7 @@ bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::
|
|||
}
|
||||
else if (local_args[0] == "new")
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot add address");
|
||||
local_args.erase(local_args.begin());
|
||||
std::string label;
|
||||
if (local_args.size() > 0)
|
||||
|
@ -9650,6 +9826,7 @@ bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::
|
|||
}
|
||||
else if (local_args[0] == "mnew")
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot add addresses");
|
||||
local_args.erase(local_args.begin());
|
||||
if (local_args.size() != 1)
|
||||
{
|
||||
|
@ -9675,6 +9852,7 @@ bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::
|
|||
}
|
||||
else if (local_args[0] == "one-off")
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot add address");
|
||||
local_args.erase(local_args.begin());
|
||||
std::string label;
|
||||
if (local_args.size() != 2)
|
||||
|
@ -9693,6 +9871,7 @@ bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::
|
|||
}
|
||||
else if (local_args.size() >= 2 && local_args[0] == "label")
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot modify address");
|
||||
if (!epee::string_tools::get_xtype_from_string(index, local_args[1]))
|
||||
{
|
||||
fail_msg_writer() << tr("failed to parse index: ") << local_args[1];
|
||||
|
@ -9839,6 +10018,8 @@ bool simple_wallet::print_integrated_address(const std::vector<std::string> &arg
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::address_book(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot get address book");
|
||||
|
||||
if (args.size() == 0)
|
||||
{
|
||||
}
|
||||
|
@ -9899,6 +10080,8 @@ bool simple_wallet::address_book(const std::vector<std::string> &args/* = std::v
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::set_tx_note(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot set tx note");
|
||||
|
||||
if (args.size() == 0)
|
||||
{
|
||||
PRINT_USAGE(USAGE_SET_TX_NOTE);
|
||||
|
@ -9927,6 +10110,8 @@ bool simple_wallet::set_tx_note(const std::vector<std::string> &args)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::get_tx_note(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot get tx note");
|
||||
|
||||
if (args.size() != 1)
|
||||
{
|
||||
PRINT_USAGE(USAGE_GET_TX_NOTE);
|
||||
|
@ -9952,6 +10137,8 @@ bool simple_wallet::get_tx_note(const std::vector<std::string> &args)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::set_description(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot set description");
|
||||
|
||||
// 0 arguments allowed, for setting the description to empty string
|
||||
|
||||
std::string description = "";
|
||||
|
@ -9968,6 +10155,8 @@ bool simple_wallet::set_description(const std::vector<std::string> &args)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::get_description(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot get description");
|
||||
|
||||
if (args.size() != 0)
|
||||
{
|
||||
PRINT_USAGE(USAGE_GET_DESCRIPTION);
|
||||
|
@ -10026,6 +10215,8 @@ bool simple_wallet::wallet_info(const std::vector<std::string> &args)
|
|||
type = tr("Watch only");
|
||||
else if (m_wallet->multisig(&ready, &threshold, &total))
|
||||
type = (boost::format(tr("%u/%u multisig%s")) % threshold % total % (ready ? "" : " (not yet finalized)")).str();
|
||||
else if (m_wallet->is_background_wallet())
|
||||
type = tr("Background wallet");
|
||||
else
|
||||
type = tr("Normal");
|
||||
message_writer() << tr("Type: ") << type;
|
||||
|
@ -10037,6 +10228,7 @@ bool simple_wallet::wallet_info(const std::vector<std::string> &args)
|
|||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sign(const std::vector<std::string> &args)
|
||||
{
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot sign");
|
||||
if (m_wallet->key_on_device())
|
||||
{
|
||||
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||
|
@ -10144,6 +10336,7 @@ bool simple_wallet::export_key_images(const std::vector<std::string> &args_)
|
|||
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||
return true;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot export key images");
|
||||
auto args = args_;
|
||||
|
||||
if (m_wallet->watch_only())
|
||||
|
@ -10197,6 +10390,7 @@ bool simple_wallet::import_key_images(const std::vector<std::string> &args)
|
|||
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||
return true;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot import key images");
|
||||
if (!m_wallet->is_trusted_daemon())
|
||||
{
|
||||
fail_msg_writer() << tr("this command requires a trusted daemon. Enable with --trusted-daemon");
|
||||
|
@ -10305,6 +10499,7 @@ bool simple_wallet::export_outputs(const std::vector<std::string> &args_)
|
|||
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||
return true;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot export outputs");
|
||||
auto args = args_;
|
||||
|
||||
bool all = false;
|
||||
|
@ -10354,6 +10549,7 @@ bool simple_wallet::import_outputs(const std::vector<std::string> &args)
|
|||
fail_msg_writer() << tr("command not supported by HW wallet");
|
||||
return true;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING("cannot import outputs");
|
||||
if (args.size() != 1)
|
||||
{
|
||||
PRINT_USAGE(USAGE_IMPORT_OUTPUTS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue