wallet: fix split transaction change address display

Display the first non-zero change address after verifying that all
effective change uses the same address. Foreign change is already
rejected during signing, so this only fixes misleading display.

Reported by xmrack and the MAGIC Monero Fund.
This commit is contained in:
selsta
2026-08-06 16:59:22 +02:00
parent 83405f127d
commit f98077b7ad
3 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -7592,7 +7592,8 @@ bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes,
std::string change_string;
if (change > 0)
{
std::string address = get_account_address_as_str(m_wallet->nettype(), get_tx(0).subaddr_account > 0, get_tx(0).change_dts.addr);
const tools::wallet2::tx_construction_data &cd = get_tx(first_known_non_zero_change_index);
std::string address = get_account_address_as_str(m_wallet->nettype(), cd.subaddr_account > 0, cd.change_dts.addr);
change_string += (boost::format(tr("%s change to %s")) % print_money(change) % address).str();
}
else
+2 -1
View File
@@ -212,7 +212,8 @@ bool UnsignedTransactionImpl::checkLoadedTx(const std::function<size_t()> get_nu
std::string change_string;
if (change > 0)
{
std::string address = get_account_address_as_str(m_wallet.m_wallet->nettype(), get_tx(0).subaddr_account > 0, get_tx(0).change_dts.addr);
const tools::wallet2::tx_construction_data &cd = get_tx(first_known_non_zero_change_index);
std::string address = get_account_address_as_str(m_wallet.m_wallet->nettype(), cd.subaddr_account > 0, cd.change_dts.addr);
change_string += (boost::format(tr("%s change to %s")) % cryptonote::print_money(change) % address).str();
}
else
+1 -2
View File
@@ -1638,8 +1638,7 @@ namespace tools
if (desc.change_amount > 0)
{
const tools::wallet2::tx_construction_data &cd0 = tx_constructions[0];
desc.change_address = get_account_address_as_str(m_wallet->nettype(), cd0.subaddr_account > 0, cd0.change_dts.addr);
desc.change_address = get_account_address_as_str(m_wallet->nettype(), cd.subaddr_account > 0, cd.change_dts.addr);
res.summary.change_address = desc.change_address;
}