|
|
@ -3111,6 +3111,18 @@ namespace tools
|
|
|
|
er.message = "Invalid filename";
|
|
|
|
er.message = "Invalid filename";
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_wallet && req.autosave_current)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_wallet->store();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const std::exception& e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
std::string wallet_file = m_wallet_dir + "/" + req.filename;
|
|
|
|
std::string wallet_file = m_wallet_dir + "/" + req.filename;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
po::options_description desc("dummy");
|
|
|
|
po::options_description desc("dummy");
|
|
|
@ -3141,18 +3153,7 @@ namespace tools
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_wallet)
|
|
|
|
if (m_wallet)
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_wallet->store();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const std::exception& e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m_wallet;
|
|
|
|
delete m_wallet;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_wallet = wal.release();
|
|
|
|
m_wallet = wal.release();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3161,6 +3162,8 @@ namespace tools
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!m_wallet) return not_open(er);
|
|
|
|
if (!m_wallet) return not_open(er);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (req.autosave_current)
|
|
|
|
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_wallet->store();
|
|
|
|
m_wallet->store();
|
|
|
@ -3170,6 +3173,7 @@ namespace tools
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
delete m_wallet;
|
|
|
|
delete m_wallet;
|
|
|
|
m_wallet = NULL;
|
|
|
|
m_wallet = NULL;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -3385,6 +3389,20 @@ namespace tools
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_wallet && req.autosave_current)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!wallet_file.empty())
|
|
|
|
|
|
|
|
m_wallet->store();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const std::exception &e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!req.spendkey.empty())
|
|
|
|
if (!req.spendkey.empty())
|
|
|
@ -3433,19 +3451,7 @@ namespace tools
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_wallet)
|
|
|
|
if (m_wallet)
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!wallet_file.empty())
|
|
|
|
|
|
|
|
m_wallet->store();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const std::exception &e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m_wallet;
|
|
|
|
delete m_wallet;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_wallet = wal.release();
|
|
|
|
m_wallet = wal.release();
|
|
|
|
res.address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
|
|
|
|
res.address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -3511,6 +3517,18 @@ namespace tools
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_wallet && req.autosave_current)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_wallet->store();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const std::exception &e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// process seed_offset if given
|
|
|
|
// process seed_offset if given
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -3621,18 +3639,7 @@ namespace tools
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_wallet)
|
|
|
|
if (m_wallet)
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_wallet->store();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const std::exception &e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m_wallet;
|
|
|
|
delete m_wallet;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_wallet = wal.release();
|
|
|
|
m_wallet = wal.release();
|
|
|
|
res.address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
|
|
|
|
res.address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
|
|
|
|
res.info = "Wallet has been restored successfully.";
|
|
|
|
res.info = "Wallet has been restored successfully.";
|
|
|
|