From 029fa3de9973fc611874ab1cf91f796ff0f89ccb Mon Sep 17 00:00:00 2001 From: jpk68 Date: Sun, 26 Jul 2026 12:08:03 -0400 Subject: [PATCH] simplewallet: fix restore-date parameter when using generate-from-device --- src/simplewallet/simplewallet.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 69c66d099..5674656ee 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -4288,8 +4288,8 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) CHECK_AND_ASSERT_MES(r, false, tr("account creation failed")); password = *r; welcome = true; - // if no block_height is specified, assume its a new account and start it "now" - if (command_line::is_arg_defaulted(vm, arg_restore_height)) { + // if no block_height or date is specified, assume it's a new account and start it "now" + if (command_line::is_arg_defaulted(vm, arg_restore_height) && command_line::is_arg_defaulted(vm, arg_restore_date)) { { tools::scoped_message_writer wrt = tools::msg_writer(); wrt << tr("No restore height is specified.") << " "; @@ -4304,6 +4304,23 @@ bool simple_wallet::init(const boost::program_options::variables_map& vm) m_wallet->explicit_refresh_from_block_height(true); m_restore_height = m_wallet->get_refresh_from_block_height(); } + else if (command_line::is_arg_defaulted(vm, arg_restore_height) && !command_line::is_arg_defaulted(vm, arg_restore_date)) + { + uint16_t year; + uint8_t month, day; + if (!datestr_to_int(m_restore_date, year, month, day)) return false; + try + { + m_restore_height = m_wallet->get_blockchain_height_by_date(year, month, day); + success_msg_writer() << tr("Restore height is: ") << m_restore_height; + } + catch (const std::runtime_error& e) + { + fail_msg_writer() << e.what(); + return false; + } + m_wallet->explicit_refresh_from_block_height(true); + } } else {