Merge pull request #4005
b85acb4c
Fix RPC crashes that didn't check for an open wallet (Howard Chu)
This commit is contained in:
commit
e451c76181
|
@ -519,6 +519,7 @@ namespace tools
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
bool wallet_rpc_server::on_get_account_tags(const wallet_rpc::COMMAND_RPC_GET_ACCOUNT_TAGS::request& req, wallet_rpc::COMMAND_RPC_GET_ACCOUNT_TAGS::response& res, epee::json_rpc::error& er)
|
bool wallet_rpc_server::on_get_account_tags(const wallet_rpc::COMMAND_RPC_GET_ACCOUNT_TAGS::request& req, wallet_rpc::COMMAND_RPC_GET_ACCOUNT_TAGS::response& res, epee::json_rpc::error& er)
|
||||||
{
|
{
|
||||||
|
if (!m_wallet) return not_open(er);
|
||||||
const std::pair<std::map<std::string, std::string>, std::vector<std::string>> account_tags = m_wallet->get_account_tags();
|
const std::pair<std::map<std::string, std::string>, std::vector<std::string>> account_tags = m_wallet->get_account_tags();
|
||||||
for (const std::pair<std::string, std::string>& p : account_tags.first)
|
for (const std::pair<std::string, std::string>& p : account_tags.first)
|
||||||
{
|
{
|
||||||
|
@ -537,6 +538,7 @@ namespace tools
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
bool wallet_rpc_server::on_tag_accounts(const wallet_rpc::COMMAND_RPC_TAG_ACCOUNTS::request& req, wallet_rpc::COMMAND_RPC_TAG_ACCOUNTS::response& res, epee::json_rpc::error& er)
|
bool wallet_rpc_server::on_tag_accounts(const wallet_rpc::COMMAND_RPC_TAG_ACCOUNTS::request& req, wallet_rpc::COMMAND_RPC_TAG_ACCOUNTS::response& res, epee::json_rpc::error& er)
|
||||||
{
|
{
|
||||||
|
if (!m_wallet) return not_open(er);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_wallet->set_account_tag(req.accounts, req.tag);
|
m_wallet->set_account_tag(req.accounts, req.tag);
|
||||||
|
@ -551,6 +553,7 @@ namespace tools
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
bool wallet_rpc_server::on_untag_accounts(const wallet_rpc::COMMAND_RPC_UNTAG_ACCOUNTS::request& req, wallet_rpc::COMMAND_RPC_UNTAG_ACCOUNTS::response& res, epee::json_rpc::error& er)
|
bool wallet_rpc_server::on_untag_accounts(const wallet_rpc::COMMAND_RPC_UNTAG_ACCOUNTS::request& req, wallet_rpc::COMMAND_RPC_UNTAG_ACCOUNTS::response& res, epee::json_rpc::error& er)
|
||||||
{
|
{
|
||||||
|
if (!m_wallet) return not_open(er);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_wallet->set_account_tag(req.accounts, "");
|
m_wallet->set_account_tag(req.accounts, "");
|
||||||
|
@ -565,6 +568,7 @@ namespace tools
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
bool wallet_rpc_server::on_set_account_tag_description(const wallet_rpc::COMMAND_RPC_SET_ACCOUNT_TAG_DESCRIPTION::request& req, wallet_rpc::COMMAND_RPC_SET_ACCOUNT_TAG_DESCRIPTION::response& res, epee::json_rpc::error& er)
|
bool wallet_rpc_server::on_set_account_tag_description(const wallet_rpc::COMMAND_RPC_SET_ACCOUNT_TAG_DESCRIPTION::request& req, wallet_rpc::COMMAND_RPC_SET_ACCOUNT_TAG_DESCRIPTION::response& res, epee::json_rpc::error& er)
|
||||||
{
|
{
|
||||||
|
if (!m_wallet) return not_open(er);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_wallet->set_account_tag_description(req.tag, req.description);
|
m_wallet->set_account_tag_description(req.tag, req.description);
|
||||||
|
@ -2283,6 +2287,7 @@ namespace tools
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
bool wallet_rpc_server::on_make_uri(const wallet_rpc::COMMAND_RPC_MAKE_URI::request& req, wallet_rpc::COMMAND_RPC_MAKE_URI::response& res, epee::json_rpc::error& er)
|
bool wallet_rpc_server::on_make_uri(const wallet_rpc::COMMAND_RPC_MAKE_URI::request& req, wallet_rpc::COMMAND_RPC_MAKE_URI::response& res, epee::json_rpc::error& er)
|
||||||
{
|
{
|
||||||
|
if (!m_wallet) return not_open(er);
|
||||||
std::string error;
|
std::string error;
|
||||||
std::string uri = m_wallet->make_uri(req.address, req.payment_id, req.amount, req.tx_description, req.recipient_name, error);
|
std::string uri = m_wallet->make_uri(req.address, req.payment_id, req.amount, req.tx_description, req.recipient_name, error);
|
||||||
if (uri.empty())
|
if (uri.empty())
|
||||||
|
@ -2496,6 +2501,7 @@ namespace tools
|
||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
bool wallet_rpc_server::on_stop_mining(const wallet_rpc::COMMAND_RPC_STOP_MINING::request& req, wallet_rpc::COMMAND_RPC_STOP_MINING::response& res, epee::json_rpc::error& er)
|
bool wallet_rpc_server::on_stop_mining(const wallet_rpc::COMMAND_RPC_STOP_MINING::request& req, wallet_rpc::COMMAND_RPC_STOP_MINING::response& res, epee::json_rpc::error& er)
|
||||||
{
|
{
|
||||||
|
if (!m_wallet) return not_open(er);
|
||||||
cryptonote::COMMAND_RPC_STOP_MINING::request daemon_req;
|
cryptonote::COMMAND_RPC_STOP_MINING::request daemon_req;
|
||||||
cryptonote::COMMAND_RPC_STOP_MINING::response daemon_res;
|
cryptonote::COMMAND_RPC_STOP_MINING::response daemon_res;
|
||||||
bool r = m_wallet->invoke_http_json("/stop_mining", daemon_req, daemon_res);
|
bool r = m_wallet->invoke_http_json("/stop_mining", daemon_req, daemon_res);
|
||||||
|
|
Loading…
Reference in New Issue