mirror of
https://github.com/monero-project/monero.git
synced 2024-11-19 02:21:02 +00:00
wallet: distinguish between empty and absent attributes
This commit is contained in:
parent
581994b61c
commit
bc94ba4d14
4 changed files with 16 additions and 6 deletions
|
@ -11365,12 +11365,13 @@ void wallet2::set_attribute(const std::string &key, const std::string &value)
|
||||||
m_attributes[key] = value;
|
m_attributes[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string wallet2::get_attribute(const std::string &key) const
|
bool wallet2::get_attribute(const std::string &key, std::string &value) const
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, std::string>::const_iterator i = m_attributes.find(key);
|
std::unordered_map<std::string, std::string>::const_iterator i = m_attributes.find(key);
|
||||||
if (i == m_attributes.end())
|
if (i == m_attributes.end())
|
||||||
return std::string();
|
return false;
|
||||||
return i->second;
|
value = i->second;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wallet2::set_description(const std::string &description)
|
void wallet2::set_description(const std::string &description)
|
||||||
|
@ -11380,7 +11381,10 @@ void wallet2::set_description(const std::string &description)
|
||||||
|
|
||||||
std::string wallet2::get_description() const
|
std::string wallet2::get_description() const
|
||||||
{
|
{
|
||||||
return get_attribute(ATTRIBUTE_DESCRIPTION);
|
std::string s;
|
||||||
|
if (get_attribute(ATTRIBUTE_DESCRIPTION, s))
|
||||||
|
return s;
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::pair<std::map<std::string, std::string>, std::vector<std::string>>& wallet2::get_account_tags()
|
const std::pair<std::map<std::string, std::string>, std::vector<std::string>>& wallet2::get_account_tags()
|
||||||
|
|
|
@ -1247,7 +1247,7 @@ private:
|
||||||
*/
|
*/
|
||||||
const char* const ATTRIBUTE_DESCRIPTION = "wallet2.description";
|
const char* const ATTRIBUTE_DESCRIPTION = "wallet2.description";
|
||||||
void set_attribute(const std::string &key, const std::string &value);
|
void set_attribute(const std::string &key, const std::string &value);
|
||||||
std::string get_attribute(const std::string &key) const;
|
bool get_attribute(const std::string &key, std::string &value) const;
|
||||||
|
|
||||||
crypto::public_key get_multisig_signer_public_key(const crypto::secret_key &spend_skey) const;
|
crypto::public_key get_multisig_signer_public_key(const crypto::secret_key &spend_skey) const;
|
||||||
crypto::public_key get_multisig_signer_public_key() const;
|
crypto::public_key get_multisig_signer_public_key() const;
|
||||||
|
|
|
@ -2126,7 +2126,12 @@ namespace tools
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.value = m_wallet->get_attribute(req.key);
|
if (!m_wallet->get_attribute(req.key, res.value))
|
||||||
|
{
|
||||||
|
er.code = WALLET_RPC_ERROR_CODE_ATTRIBUTE_NOT_FOUND;
|
||||||
|
er.message = "Attribute not found.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool wallet_rpc_server::on_get_tx_key(const wallet_rpc::COMMAND_RPC_GET_TX_KEY::request& req, wallet_rpc::COMMAND_RPC_GET_TX_KEY::response& res, epee::json_rpc::error& er, const connection_context *ctx)
|
bool wallet_rpc_server::on_get_tx_key(const wallet_rpc::COMMAND_RPC_GET_TX_KEY::request& req, wallet_rpc::COMMAND_RPC_GET_TX_KEY::response& res, epee::json_rpc::error& er, const connection_context *ctx)
|
||||||
|
|
|
@ -75,3 +75,4 @@
|
||||||
#define WALLET_RPC_ERROR_CODE_SIGN_UNSIGNED -42
|
#define WALLET_RPC_ERROR_CODE_SIGN_UNSIGNED -42
|
||||||
#define WALLET_RPC_ERROR_CODE_NON_DETERMINISTIC -43
|
#define WALLET_RPC_ERROR_CODE_NON_DETERMINISTIC -43
|
||||||
#define WALLET_RPC_ERROR_CODE_INVALID_LOG_LEVEL -44
|
#define WALLET_RPC_ERROR_CODE_INVALID_LOG_LEVEL -44
|
||||||
|
#define WALLET_RPC_ERROR_CODE_ATTRIBUTE_NOT_FOUND -45
|
||||||
|
|
Loading…
Reference in a new issue