mirror of
https://github.com/monero-project/monero.git
synced 2025-08-08 20:32:19 -04:00
wallet: do not split integrated addresses in address book api
This commit is contained in:
parent
59e7d5686b
commit
dd8c6b1703
8 changed files with 78 additions and 223 deletions
|
@ -2745,7 +2745,14 @@ namespace tools
|
|||
{
|
||||
uint64_t idx = 0;
|
||||
for (const auto &entry: ab)
|
||||
res.entries.push_back(wallet_rpc::COMMAND_RPC_GET_ADDRESS_BOOK_ENTRY::entry{idx++, get_account_address_as_str(m_wallet->nettype(), entry.m_is_subaddress, entry.m_address), epee::string_tools::pod_to_hex(entry.m_payment_id), entry.m_description});
|
||||
{
|
||||
std::string address;
|
||||
if (entry.m_has_payment_id)
|
||||
address = cryptonote::get_account_integrated_address_as_str(m_wallet->nettype(), entry.m_address, entry.m_payment_id);
|
||||
else
|
||||
address = get_account_address_as_str(m_wallet->nettype(), entry.m_is_subaddress, entry.m_address);
|
||||
res.entries.push_back(wallet_rpc::COMMAND_RPC_GET_ADDRESS_BOOK_ENTRY::entry{idx++, address, entry.m_description});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2758,7 +2765,12 @@ namespace tools
|
|||
return false;
|
||||
}
|
||||
const auto &entry = ab[idx];
|
||||
res.entries.push_back(wallet_rpc::COMMAND_RPC_GET_ADDRESS_BOOK_ENTRY::entry{idx, get_account_address_as_str(m_wallet->nettype(), entry.m_is_subaddress, entry.m_address), epee::string_tools::pod_to_hex(entry.m_payment_id), entry.m_description});
|
||||
std::string address;
|
||||
if (entry.m_has_payment_id)
|
||||
address = cryptonote::get_account_integrated_address_as_str(m_wallet->nettype(), entry.m_address, entry.m_payment_id);
|
||||
else
|
||||
address = get_account_address_as_str(m_wallet->nettype(), entry.m_is_subaddress, entry.m_address);
|
||||
res.entries.push_back(wallet_rpc::COMMAND_RPC_GET_ADDRESS_BOOK_ENTRY::entry{idx, address, entry.m_description});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -2775,7 +2787,6 @@ namespace tools
|
|||
}
|
||||
|
||||
cryptonote::address_parse_info info;
|
||||
crypto::hash payment_id = crypto::null_hash;
|
||||
er.message = "";
|
||||
if(!get_account_address_from_str_or_url(info, m_wallet->nettype(), req.address,
|
||||
[&er](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
|
||||
|
@ -2797,39 +2808,7 @@ namespace tools
|
|||
er.message = std::string("WALLET_RPC_ERROR_CODE_WRONG_ADDRESS: ") + req.address;
|
||||
return false;
|
||||
}
|
||||
if (info.has_payment_id)
|
||||
{
|
||||
memcpy(payment_id.data, info.payment_id.data, 8);
|
||||
memset(payment_id.data + 8, 0, 24);
|
||||
}
|
||||
if (!req.payment_id.empty())
|
||||
{
|
||||
if (info.has_payment_id)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
er.message = "Separate payment ID given with integrated address";
|
||||
return false;
|
||||
}
|
||||
|
||||
crypto::hash long_payment_id;
|
||||
|
||||
if (!wallet2::parse_long_payment_id(req.payment_id, payment_id))
|
||||
{
|
||||
if (!wallet2::parse_short_payment_id(req.payment_id, info.payment_id))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
er.message = "Payment id has invalid format: \"" + req.payment_id + "\", expected 64 character string";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
er.message = "Payment id has invalid format: standalone short payment IDs are forbidden, they must be part of an integrated address";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!m_wallet->add_address_book_row(info.address, payment_id, req.description, info.is_subaddress))
|
||||
if (!m_wallet->add_address_book_row(info.address, info.has_payment_id ? &info.payment_id : NULL, req.description, info.is_subaddress))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "Failed to add address book entry";
|
||||
|
@ -2860,7 +2839,6 @@ namespace tools
|
|||
tools::wallet2::address_book_row entry = ab[req.index];
|
||||
|
||||
cryptonote::address_parse_info info;
|
||||
crypto::hash payment_id = crypto::null_hash;
|
||||
if (req.set_address)
|
||||
{
|
||||
er.message = "";
|
||||
|
@ -2887,52 +2865,13 @@ namespace tools
|
|||
entry.m_address = info.address;
|
||||
entry.m_is_subaddress = info.is_subaddress;
|
||||
if (info.has_payment_id)
|
||||
{
|
||||
memcpy(entry.m_payment_id.data, info.payment_id.data, 8);
|
||||
memset(entry.m_payment_id.data + 8, 0, 24);
|
||||
}
|
||||
}
|
||||
|
||||
if (req.set_payment_id)
|
||||
{
|
||||
if (req.payment_id.empty())
|
||||
{
|
||||
payment_id = crypto::null_hash;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (req.set_address && info.has_payment_id)
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
er.message = "Separate payment ID given with integrated address";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!wallet2::parse_long_payment_id(req.payment_id, payment_id))
|
||||
{
|
||||
crypto::hash8 spid;
|
||||
if (!wallet2::parse_short_payment_id(req.payment_id, spid))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
er.message = "Payment id has invalid format: \"" + req.payment_id + "\", expected 64 character string";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID;
|
||||
er.message = "Payment id has invalid format: standalone short payment IDs are forbidden, they must be part of an integrated address";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entry.m_payment_id = payment_id;
|
||||
entry.m_payment_id = info.payment_id;
|
||||
}
|
||||
|
||||
if (req.set_description)
|
||||
entry.m_description = req.description;
|
||||
|
||||
if (!m_wallet->set_address_book_row(req.index, entry.m_address, entry.m_payment_id, entry.m_description, entry.m_is_subaddress))
|
||||
if (!m_wallet->set_address_book_row(req.index, entry.m_address, req.set_address && entry.m_has_payment_id ? &entry.m_payment_id : NULL, entry.m_description, entry.m_is_subaddress))
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
|
||||
er.message = "Failed to edit address book entry";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue