simplewallet: fix restore-date parameter when using generate-from-device

This commit is contained in:
jpk68
2026-07-26 12:08:03 -04:00
parent d85cfa04d8
commit 029fa3de99
+19 -2
View File
@@ -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
{