mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 08:17:37 +00:00
Wallet2: Don't throw when subaddress label doesn't exist
This commit is contained in:
parent
086b7db2c7
commit
a46c1eed8c
2 changed files with 11 additions and 11 deletions
|
@ -692,19 +692,19 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
std::string wallet2::get_subaddress_label(const cryptonote::subaddress_index& index) const
|
std::string wallet2::get_subaddress_label(const cryptonote::subaddress_index& index) const
|
||||||
{
|
{
|
||||||
if (index.major >= m_subaddress_labels.size())
|
if (index.major >= m_subaddress_labels.size() || index.minor >= m_subaddress_labels[index.major].size())
|
||||||
throw std::runtime_error("index.major is out of bound");
|
{
|
||||||
if (index.minor >= m_subaddress_labels[index.major].size())
|
MERROR("Subaddress label doesn't exist");
|
||||||
throw std::runtime_error("index.minor is out of bound");
|
return "";
|
||||||
|
}
|
||||||
return m_subaddress_labels[index.major][index.minor];
|
return m_subaddress_labels[index.major][index.minor];
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
void wallet2::set_subaddress_label(const cryptonote::subaddress_index& index, const std::string &label)
|
void wallet2::set_subaddress_label(const cryptonote::subaddress_index& index, const std::string &label)
|
||||||
{
|
{
|
||||||
if (index.major >= m_subaddress_labels.size())
|
if (index.major >= m_subaddress_labels.size() || index.minor >= m_subaddress_labels[index.major].size())
|
||||||
throw std::runtime_error("index.major is out of bound");
|
MERROR("Subaddress index is out of bounds. Failed to set subaddress label.");
|
||||||
if (index.minor >= m_subaddress_labels[index.major].size())
|
else
|
||||||
throw std::runtime_error("index.minor is out of bound");
|
|
||||||
m_subaddress_labels[index.major][index.minor] = label;
|
m_subaddress_labels[index.major][index.minor] = label;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -467,8 +467,8 @@ namespace tools
|
||||||
size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; }
|
size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; }
|
||||||
void add_subaddress(uint32_t index_major, const std::string& label); // throws when index is out of bound
|
void add_subaddress(uint32_t index_major, const std::string& label); // throws when index is out of bound
|
||||||
void expand_subaddresses(const cryptonote::subaddress_index& index);
|
void expand_subaddresses(const cryptonote::subaddress_index& index);
|
||||||
std::string get_subaddress_label(const cryptonote::subaddress_index& index) const; // throws when index is out of bound
|
std::string get_subaddress_label(const cryptonote::subaddress_index& index) const;
|
||||||
void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label); // throws when index is out of bound
|
void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label);
|
||||||
/*!
|
/*!
|
||||||
* \brief Tells if the wallet file is deprecated.
|
* \brief Tells if the wallet file is deprecated.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue