From ec14e4b8cd5b78c8d3251bb205294810b29f880e Mon Sep 17 00:00:00 2001 From: xiphon Date: Mon, 12 Oct 2020 21:13:58 +0000 Subject: wallet2: skip reorgs exceeding max-reorg-depth wallet setting --- src/simplewallet/simplewallet.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/simplewallet/simplewallet.cpp') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 7b26d21fb..a90bd3a39 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2705,6 +2705,24 @@ bool simple_wallet::set_unit(const std::vector &args/* = std::vecto return true; } +bool simple_wallet::set_max_reorg_depth(const std::vector &args/* = std::vector()*/) +{ + uint64_t depth; + if (!epee::string_tools::get_xtype_from_string(depth, args[1])) + { + fail_msg_writer() << tr("invalid value"); + return true; + } + + const auto pwd_container = get_and_verify_password(); + if (pwd_container) + { + m_wallet->max_reorg_depth(depth); + m_wallet->rewrite(m_wallet_file, pwd_container->password()); + } + return true; +} + bool simple_wallet::set_min_output_count(const std::vector &args/* = std::vector()*/) { uint32_t count; @@ -3783,6 +3801,7 @@ bool simple_wallet::set_variable(const std::vector &args) success_msg_writer() << "priority = " << priority<< " (" << priority_string << ")"; success_msg_writer() << "ask-password = " << m_wallet->ask_password() << " (" << ask_password_string << ")"; success_msg_writer() << "unit = " << cryptonote::get_unit(cryptonote::get_default_decimal_point()); + success_msg_writer() << "max-reorg-depth = " << m_wallet->max_reorg_depth(); success_msg_writer() << "min-outputs-count = " << m_wallet->get_min_output_count(); success_msg_writer() << "min-outputs-value = " << cryptonote::print_money(m_wallet->get_min_output_value()); success_msg_writer() << "merge-destinations = " << m_wallet->merge_destinations(); @@ -3853,6 +3872,7 @@ bool simple_wallet::set_variable(const std::vector &args) CHECK_SIMPLE_VARIABLE("priority", set_default_priority, tr("0, 1, 2, 3, or 4, or one of ") << join_priority_strings(", ")); CHECK_SIMPLE_VARIABLE("ask-password", set_ask_password, tr("0|1|2 (or never|action|decrypt)")); CHECK_SIMPLE_VARIABLE("unit", set_unit, tr("monero, millinero, micronero, nanonero, piconero")); + CHECK_SIMPLE_VARIABLE("max-reorg-depth", set_max_reorg_depth, tr("unsigned integer")); CHECK_SIMPLE_VARIABLE("min-outputs-count", set_min_output_count, tr("unsigned integer")); CHECK_SIMPLE_VARIABLE("min-outputs-value", set_min_output_value, tr("amount")); CHECK_SIMPLE_VARIABLE("merge-destinations", set_merge_destinations, tr("0 or 1")); -- cgit v1.2.3