wallet: fix split transaction change address display
What changed, and why it matters
This commit fixes a display-only bug in Monero wallets. When a transaction is split into multiple parts, the wallet was showing the change address from the first transaction piece, even if that piece had no change. The fix makes it show the first piece that actually has change. The commit message says misleading display is the only effect because foreign change addresses are already rejected during signing, so no money could be sent to an attacker's address.
Treat as a low-severity display bug. Users relying on displayed change addresses for split transactions should update. No urgent security response is indicated by the commit itself, but reviewers may want to independently confirm the signing-time foreign-change rejection claim.
Security signals we found
UI/display-only address mismatch in split transactions
Use of first construction index instead of first non-zero change index
Commit message asserts signing already rejects foreign change addresses
No cryptographic or transaction validation logic changed
Evidence from the diff
Three wallet display code paths (simplewallet, wallet API unsigned transaction, wallet RPC server) previously used tx_constructions[0] / get_tx(0) to derive the change address string. For split transactions, the first construction may have zero change, causing the displayed change address to be taken from an irrelevant or zero-change output. The patch uses first_known_non_zero_change_index (already computed elsewhere in the same functions) to select the construction data that actually carries change. The commit message explicitly states foreign change is rejected during signing, so this is a display fix only.
Changed components
src/simplewallet/simplewallet.cppsrc/wallet/api/unsigned_transaction.cppsrc/wallet/wallet_rpc_server.cppInspect captured patch +5 / −4
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index a78c233..fb400a8 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -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
diff --git a/src/wallet/api/unsigned_transaction.cpp b/src/wallet/api/unsigned_transaction.cpp
index 1130159..931b914 100644
--- a/src/wallet/api/unsigned_transaction.cpp
+++ b/src/wallet/api/unsigned_transaction.cpp
@@ -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
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index e64df58..f8ce246 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -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;
}
Why this scored 24/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.