|
|
@ -378,27 +378,23 @@ namespace tools
|
|
|
|
bool wallet_rpc_server::on_create_address(const wallet_rpc::COMMAND_RPC_CREATE_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_CREATE_ADDRESS::response& res, epee::json_rpc::error& er)
|
|
|
|
bool wallet_rpc_server::on_create_address(const wallet_rpc::COMMAND_RPC_CREATE_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_CREATE_ADDRESS::response& res, epee::json_rpc::error& er)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!m_wallet) return not_open(er);
|
|
|
|
if (!m_wallet) return not_open(er);
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
m_wallet->add_subaddress(req.account_index, req.label);
|
|
|
|
m_wallet->add_subaddress(req.account_index, req.label);
|
|
|
|
res.address_index = m_wallet->get_num_subaddresses(req.account_index) - 1;
|
|
|
|
res.address_index = m_wallet->get_num_subaddresses(req.account_index) - 1;
|
|
|
|
res.address = m_wallet->get_subaddress_as_str({req.account_index, res.address_index});
|
|
|
|
res.address = m_wallet->get_subaddress_as_str({req.account_index, res.address_index});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const std::exception& e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
handle_rpc_exception(std::current_exception(), er, WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool wallet_rpc_server::on_label_address(const wallet_rpc::COMMAND_RPC_LABEL_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_LABEL_ADDRESS::response& res, epee::json_rpc::error& er)
|
|
|
|
bool wallet_rpc_server::on_label_address(const wallet_rpc::COMMAND_RPC_LABEL_ADDRESS::request& req, wallet_rpc::COMMAND_RPC_LABEL_ADDRESS::response& res, epee::json_rpc::error& er)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!m_wallet) return not_open(er);
|
|
|
|
if (!m_wallet) return not_open(er);
|
|
|
|
if (req.index.major >= m_wallet->get_num_subaddress_accounts())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
er.code = WALLET_RPC_ERROR_CODE_ACCOUNT_INDEX_OUTOFBOUND;
|
|
|
|
|
|
|
|
er.message = "Account index is out of bound";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req.index.minor >= m_wallet->get_num_subaddresses(req.index.major))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
er.code = WALLET_RPC_ERROR_CODE_ADDRESS_INDEX_OUTOFBOUND;
|
|
|
|
|
|
|
|
er.message = "Address index is out of bound";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_wallet->set_subaddress_label(req.index, req.label);
|
|
|
|
m_wallet->set_subaddress_label(req.index, req.label);
|
|
|
@ -460,12 +456,6 @@ namespace tools
|
|
|
|
bool wallet_rpc_server::on_label_account(const wallet_rpc::COMMAND_RPC_LABEL_ACCOUNT::request& req, wallet_rpc::COMMAND_RPC_LABEL_ACCOUNT::response& res, epee::json_rpc::error& er)
|
|
|
|
bool wallet_rpc_server::on_label_account(const wallet_rpc::COMMAND_RPC_LABEL_ACCOUNT::request& req, wallet_rpc::COMMAND_RPC_LABEL_ACCOUNT::response& res, epee::json_rpc::error& er)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!m_wallet) return not_open(er);
|
|
|
|
if (!m_wallet) return not_open(er);
|
|
|
|
if (req.account_index >= m_wallet->get_num_subaddress_accounts())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
er.code = WALLET_RPC_ERROR_CODE_ACCOUNT_INDEX_OUTOFBOUND;
|
|
|
|
|
|
|
|
er.message = "Account index is out of bound";
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_wallet->set_subaddress_label({req.account_index, 0}, req.label);
|
|
|
|
m_wallet->set_subaddress_label({req.account_index, 0}, req.label);
|
|
|
@ -2325,6 +2315,16 @@ namespace tools
|
|
|
|
er.code = WALLET_RPC_ERROR_CODE_INVALID_PASSWORD;
|
|
|
|
er.code = WALLET_RPC_ERROR_CODE_INVALID_PASSWORD;
|
|
|
|
er.message = "Invalid password.";
|
|
|
|
er.message = "Invalid password.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const error::account_index_outofbound& e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
er.code = WALLET_RPC_ERROR_CODE_ACCOUNT_INDEX_OUTOFBOUND;
|
|
|
|
|
|
|
|
er.message = e.what();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const error::address_index_outofbound& e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
er.code = WALLET_RPC_ERROR_CODE_ADDRESS_INDEX_OUTOFBOUND;
|
|
|
|
|
|
|
|
er.message = e.what();
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (const std::exception& e)
|
|
|
|
catch (const std::exception& e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
er.code = default_error_code;
|
|
|
|
er.code = default_error_code;
|
|
|
|