Compare commits

...

1 Commits

Author SHA1 Message Date
auruya 5297072257 fix outgoing transfer destination addresses 2025-10-17 15:16:07 +03:00
5 changed files with 29 additions and 23 deletions
+5 -1
View File
@@ -129,10 +129,12 @@ namespace cryptonote
std::string asset_type; std::string asset_type;
bool is_subaddress; bool is_subaddress;
bool is_integrated; bool is_integrated;
bool is_carrot;
bool is_change; bool is_change;
bool is_return; bool is_return;
tx_destination_entry() : amount(0), slippage_limit(0), addr(AUTO_VAL_INIT(addr)), is_subaddress(false), is_integrated(false), is_change(false), is_return(false) { } tx_destination_entry() : amount(0), slippage_limit(0), addr(AUTO_VAL_INIT(addr)), is_subaddress(false), is_integrated(false), is_change(false), is_return(false) { }
tx_destination_entry(uint64_t a, const account_public_address &ad, bool is_subaddress, bool is_return, bool is_carrot) : amount(a), slippage_limit(0), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(false), is_carrot(is_carrot) { }
tx_destination_entry(uint64_t a, const account_public_address &ad, bool is_subaddress) : amount(a), slippage_limit(0), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(false) { } tx_destination_entry(uint64_t a, const account_public_address &ad, bool is_subaddress) : amount(a), slippage_limit(0), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(false) { }
tx_destination_entry(uint64_t a, const account_public_address &ad, bool is_subaddress, bool is_return) : amount(a), slippage_limit(0), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(is_return) { } tx_destination_entry(uint64_t a, const account_public_address &ad, bool is_subaddress, bool is_return) : amount(a), slippage_limit(0), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(is_return) { }
tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress) : original(o), amount(a), slippage_limit(0), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(false) { } tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress) : original(o), amount(a), slippage_limit(0), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(false) { }
@@ -144,7 +146,7 @@ namespace cryptonote
tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress) : original(o), amount(a), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(false) { } tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress) : original(o), amount(a), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(false) { }
tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress, bool is_return) : original(o), amount(a), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(is_return) { } tx_destination_entry(const std::string &o, uint64_t a, const account_public_address &ad, bool is_subaddress, bool is_return) : original(o), amount(a), addr(ad), is_subaddress(is_subaddress), is_integrated(false), is_change(false), is_return(is_return) { }
*/ */
std::string address(network_type nettype, const crypto::hash &payment_id) const std::string address(network_type nettype, const crypto::hash &payment_id)
{ {
if (!original.empty()) if (!original.empty())
{ {
@@ -156,6 +158,7 @@ namespace cryptonote
return get_account_integrated_address_as_str(nettype, addr, reinterpret_cast<const crypto::hash8 &>(payment_id)); return get_account_integrated_address_as_str(nettype, addr, reinterpret_cast<const crypto::hash8 &>(payment_id));
} }
addr.m_is_carrot = is_carrot;
return get_account_address_as_str(nettype, is_subaddress, addr); return get_account_address_as_str(nettype, is_subaddress, addr);
} }
@@ -168,6 +171,7 @@ namespace cryptonote
FIELD(is_integrated) FIELD(is_integrated)
FIELD(is_change) FIELD(is_change)
FIELD(is_return) FIELD(is_return)
FIELD(is_carrot)
END_SERIALIZE() END_SERIALIZE()
}; };
+10 -9
View File
@@ -7248,6 +7248,7 @@ bool simple_wallet::transfer_main(
de.asset_type = dest_asset; de.asset_type = dest_asset;
de.is_subaddress = info.is_subaddress; de.is_subaddress = info.is_subaddress;
de.is_integrated = info.has_payment_id; de.is_integrated = info.has_payment_id;
de.is_carrot = info.is_carrot;
if (info.has_payment_id || !payment_id_uri.empty()) if (info.has_payment_id || !payment_id_uri.empty())
{ {
@@ -9958,14 +9959,14 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
if (out || burnt || staked) { if (out || burnt || staked) {
std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments; std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments;
m_wallet->get_payments_out(payments, min_height, max_height, m_current_subaddress_account, subaddr_indices); m_wallet->get_payments_out(payments, min_height, max_height, m_current_subaddress_account, subaddr_indices);
for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::const_iterator i = payments.begin(); i != payments.end(); ++i) { for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::iterator i = payments.begin(); i != payments.end(); ++i) {
const tools::wallet2::confirmed_transfer_details &pd = i->second; tools::wallet2::confirmed_transfer_details &pd = i->second;
if (!out && !staked && pd.m_tx.type != cryptonote::transaction_type::BURN) continue; if (!out && !staked && pd.m_tx.type != cryptonote::transaction_type::BURN) continue;
if (!out && !burnt && pd.m_tx.type != cryptonote::transaction_type::STAKE) continue; if (!out && !burnt && pd.m_tx.type != cryptonote::transaction_type::STAKE) continue;
uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known
uint64_t fee = pd.m_amount_in - pd.m_amount_out; uint64_t fee = pd.m_amount_in - pd.m_amount_out;
std::vector<std::pair<std::string, uint64_t>> destinations; std::vector<std::pair<std::string, uint64_t>> destinations;
for (const auto &d: pd.m_dests) { for (auto &d: pd.m_dests) {
destinations.push_back({d.address(m_wallet->nettype(), pd.m_payment_id), d.amount}); destinations.push_back({d.address(m_wallet->nettype(), pd.m_payment_id), d.amount});
} }
std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id); std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id);
@@ -10046,12 +10047,12 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
if (pending || failed) { if (pending || failed) {
std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>> upayments; std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>> upayments;
m_wallet->get_unconfirmed_payments_out(upayments, m_current_subaddress_account, subaddr_indices); m_wallet->get_unconfirmed_payments_out(upayments, m_current_subaddress_account, subaddr_indices);
for (std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>>::const_iterator i = upayments.begin(); i != upayments.end(); ++i) { for (std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>>::iterator i = upayments.begin(); i != upayments.end(); ++i) {
const tools::wallet2::unconfirmed_transfer_details &pd = i->second; tools::wallet2::unconfirmed_transfer_details &pd = i->second;
uint64_t amount = pd.m_amount_in; uint64_t amount = pd.m_amount_in;
uint64_t fee = amount - pd.m_amount_out; uint64_t fee = amount - pd.m_amount_out;
std::vector<std::pair<std::string, uint64_t>> destinations; std::vector<std::pair<std::string, uint64_t>> destinations;
for (const auto &d: pd.m_dests) { for (auto &d: pd.m_dests) {
destinations.push_back({d.address(m_wallet->nettype(), pd.m_payment_id), d.amount}); destinations.push_back({d.address(m_wallet->nettype(), pd.m_payment_id), d.amount});
} }
std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id); std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id);
@@ -11806,14 +11807,14 @@ bool simple_wallet::show_transfer(const std::vector<std::string> &args)
std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments_out; std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments_out;
m_wallet->get_payments_out(payments_out, 0, (uint64_t)-1, m_current_subaddress_account); m_wallet->get_payments_out(payments_out, 0, (uint64_t)-1, m_current_subaddress_account);
for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::const_iterator i = payments_out.begin(); i != payments_out.end(); ++i) { for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::iterator i = payments_out.begin(); i != payments_out.end(); ++i) {
if (i->first == txid) if (i->first == txid)
{ {
const tools::wallet2::confirmed_transfer_details &pd = i->second; tools::wallet2::confirmed_transfer_details &pd = i->second;
uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known
uint64_t fee = pd.m_amount_in - pd.m_amount_out; uint64_t fee = pd.m_amount_in - pd.m_amount_out;
std::string dests; std::string dests;
for (const auto &d: pd.m_dests) { for (auto &d: pd.m_dests) {
if (!dests.empty()) if (!dests.empty())
dests += ", "; dests += ", ";
dests += d.address(m_wallet->nettype(), pd.m_payment_id) + ": " + print_money(d.amount); dests += d.address(m_wallet->nettype(), pd.m_payment_id) + ": " + print_money(d.amount);
+2 -2
View File
@@ -149,7 +149,7 @@ static cryptonote::tx_destination_entry make_tx_destination_entry(
{ {
cryptonote::tx_destination_entry dest = cryptonote::tx_destination_entry(payment_proposal.amount, cryptonote::tx_destination_entry dest = cryptonote::tx_destination_entry(payment_proposal.amount,
{payment_proposal.destination.address_spend_pubkey, payment_proposal.destination.address_view_pubkey, /*m_is_carrot*/true}, {payment_proposal.destination.address_spend_pubkey, payment_proposal.destination.address_view_pubkey, /*m_is_carrot*/true},
payment_proposal.destination.is_subaddress); payment_proposal.destination.is_subaddress, false, true);
dest.is_integrated = payment_proposal.destination.payment_id != carrot::null_payment_id; dest.is_integrated = payment_proposal.destination.payment_id != carrot::null_payment_id;
return dest; return dest;
} }
@@ -167,7 +167,7 @@ static cryptonote::tx_destination_entry make_tx_destination_entry(
return cryptonote::tx_destination_entry(payment_proposal.proposal.amount, return cryptonote::tx_destination_entry(payment_proposal.proposal.amount,
{payment_proposal.proposal.destination_address_spend_pubkey, address_view_pubkey, /*m_is_carrot*/true}, {payment_proposal.proposal.destination_address_spend_pubkey, address_view_pubkey, /*m_is_carrot*/true},
payment_proposal.subaddr_index.index.is_subaddress()); payment_proposal.subaddr_index.index.is_subaddress(), false, true);
} }
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
+10 -9
View File
@@ -444,7 +444,7 @@ namespace tools
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time); set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time);
} }
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd) void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, tools::wallet2::confirmed_transfer_details &pd)
{ {
entry.txid = string_tools::pod_to_hex(txid); entry.txid = string_tools::pod_to_hex(txid);
entry.payment_id = string_tools::pod_to_hex(pd.m_payment_id); entry.payment_id = string_tools::pod_to_hex(pd.m_payment_id);
@@ -459,7 +459,7 @@ namespace tools
entry.amount = pd.m_amount_in - change - entry.fee; entry.amount = pd.m_amount_in - change - entry.fee;
entry.note = m_wallet->get_tx_note(txid); entry.note = m_wallet->get_tx_note(txid);
for (const auto &d: pd.m_dests) { for (auto &d: pd.m_dests) {
entry.destinations.push_back(wallet_rpc::transfer_destination()); entry.destinations.push_back(wallet_rpc::transfer_destination());
wallet_rpc::transfer_destination &td = entry.destinations.back(); wallet_rpc::transfer_destination &td = entry.destinations.back();
td.amount = d.amount; td.amount = d.amount;
@@ -478,7 +478,7 @@ namespace tools
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time); set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time);
} }
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd) void wallet_rpc_server::fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, tools::wallet2::unconfirmed_transfer_details &pd)
{ {
bool is_failed = pd.m_state == tools::wallet2::unconfirmed_transfer_details::failed; bool is_failed = pd.m_state == tools::wallet2::unconfirmed_transfer_details::failed;
entry.txid = string_tools::pod_to_hex(txid); entry.txid = string_tools::pod_to_hex(txid);
@@ -494,7 +494,7 @@ namespace tools
entry.locked = true; entry.locked = true;
entry.note = m_wallet->get_tx_note(txid); entry.note = m_wallet->get_tx_note(txid);
for (const auto &d: pd.m_dests) { for (auto &d: pd.m_dests) {
entry.destinations.push_back(wallet_rpc::transfer_destination()); entry.destinations.push_back(wallet_rpc::transfer_destination());
wallet_rpc::transfer_destination &td = entry.destinations.back(); wallet_rpc::transfer_destination &td = entry.destinations.back();
td.amount = d.amount; td.amount = d.amount;
@@ -1033,6 +1033,7 @@ namespace tools
de.original = it->address; de.original = it->address;
de.addr = info.address; de.addr = info.address;
de.is_subaddress = info.is_subaddress; de.is_subaddress = info.is_subaddress;
de.is_carrot = info.is_carrot;
de.amount = it->amount; de.amount = it->amount;
de.is_integrated = info.has_payment_id; de.is_integrated = info.has_payment_id;
de.asset_type = it->asset_type; de.asset_type = it->asset_type;
@@ -2969,7 +2970,7 @@ namespace tools
{ {
std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments; std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments;
m_wallet->get_payments_out(payments, min_height, max_height, account_index, subaddr_indices); m_wallet->get_payments_out(payments, min_height, max_height, account_index, subaddr_indices);
for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::const_iterator i = payments.begin(); i != payments.end(); ++i) { for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::iterator i = payments.begin(); i != payments.end(); ++i) {
res.out.push_back(wallet_rpc::transfer_entry()); res.out.push_back(wallet_rpc::transfer_entry());
fill_transfer_entry(res.out.back(), i->first, i->second); fill_transfer_entry(res.out.back(), i->first, i->second);
} }
@@ -2978,8 +2979,8 @@ namespace tools
if (req.pending || req.failed) { if (req.pending || req.failed) {
std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>> upayments; std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>> upayments;
m_wallet->get_unconfirmed_payments_out(upayments, account_index, subaddr_indices); m_wallet->get_unconfirmed_payments_out(upayments, account_index, subaddr_indices);
for (std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>>::const_iterator i = upayments.begin(); i != upayments.end(); ++i) { for (std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>>::iterator i = upayments.begin(); i != upayments.end(); ++i) {
const tools::wallet2::unconfirmed_transfer_details &pd = i->second; tools::wallet2::unconfirmed_transfer_details &pd = i->second;
bool is_failed = pd.m_state == tools::wallet2::unconfirmed_transfer_details::failed; bool is_failed = pd.m_state == tools::wallet2::unconfirmed_transfer_details::failed;
if (!((req.failed && is_failed) || (!is_failed && req.pending))) if (!((req.failed && is_failed) || (!is_failed && req.pending)))
continue; continue;
@@ -3056,7 +3057,7 @@ namespace tools
std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments_out; std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>> payments_out;
m_wallet->get_payments_out(payments_out, 0, (uint64_t)-1, req.account_index); m_wallet->get_payments_out(payments_out, 0, (uint64_t)-1, req.account_index);
for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::const_iterator i = payments_out.begin(); i != payments_out.end(); ++i) { for (std::list<std::pair<crypto::hash, tools::wallet2::confirmed_transfer_details>>::iterator i = payments_out.begin(); i != payments_out.end(); ++i) {
if (i->first == txid) if (i->first == txid)
{ {
res.transfers.resize(res.transfers.size() + 1); res.transfers.resize(res.transfers.size() + 1);
@@ -3066,7 +3067,7 @@ namespace tools
std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>> upayments; std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>> upayments;
m_wallet->get_unconfirmed_payments_out(upayments, req.account_index); m_wallet->get_unconfirmed_payments_out(upayments, req.account_index);
for (std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>>::const_iterator i = upayments.begin(); i != upayments.end(); ++i) { for (std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>>::iterator i = upayments.begin(); i != upayments.end(); ++i) {
if (i->first == txid) if (i->first == txid)
{ {
res.transfers.resize(res.transfers.size() + 1); res.transfers.resize(res.transfers.size() + 1);
+2 -2
View File
@@ -269,8 +269,8 @@ namespace tools
// helpers // helpers
void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd); void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd);
void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd); void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, tools::wallet2::confirmed_transfer_details &pd);
void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd); void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, tools::wallet2::unconfirmed_transfer_details &pd);
void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &payment_id, const tools::wallet2::pool_payment_details &pd); void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &payment_id, const tools::wallet2::pool_payment_details &pd);
bool not_open(epee::json_rpc::error& er); bool not_open(epee::json_rpc::error& er);
void handle_rpc_exception(const std::exception_ptr& e, epee::json_rpc::error& er, int default_error_code); void handle_rpc_exception(const std::exception_ptr& e, epee::json_rpc::error& er, int default_error_code);