wallet_api: return all unsigned tx recipients
What changed, and why it matters
This commit fixes a bug in Monero's wallet API where the recipientAddress() function only returned the first recipient of an unsigned transaction, even when the transaction had multiple recipients. Now it returns all recipients. This is primarily a correctness/functional bug fix. A possible minor security angle is that downstream code relying on recipientAddress() to verify all payment destinations could have been misled into thinking only one recipient existed, but the commit itself does not describe any security impact and no exploit path is evident from the diff.
Treat as a routine bug fix. Review any downstream consumers of UnsignedTransaction::recipientAddress() to ensure they now handle the full list correctly. No urgent security response is indicated by the available evidence.
Security signals we found
API correctness fix: previously incomplete data returned to callers
Potential downstream trust issue: callers verifying recipients of multi-output transactions would receive only the first destination
No explicit security claim, advisory, CVE, or exploit mechanism present in commit or supplied references
Evidence from the diff
UnsignedTransactionImpl::recipientAddress() previously pushed only utx.dests[0] into the result vector. The change iterates over all entries in utx.dests, returning one address per destination. A header comment is added clarifying the ordering relative to amount(). A test is updated to create a multi-destination unsigned transaction, load it, and assert that recipientAddress() matches the expected list of recipient addresses in the same order as amount().
Changed components
src/wallet/api/unsigned_transaction.cppsrc/wallet/api/wallet2_api.htests/libwallet_api_tests/main.cppInspect captured patch +18 / −3
diff --git a/src/wallet/api/unsigned_transaction.cpp b/src/wallet/api/unsigned_transaction.cpp
index c549539..4487260 100644
--- a/src/wallet/api/unsigned_transaction.cpp
+++ b/src/wallet/api/unsigned_transaction.cpp
@@ -297,7 +297,9 @@ std::vector<std::string> UnsignedTransactionImpl::recipientAddress() const
MERROR("empty destinations, skipped");
continue;
}
- result.push_back(cryptonote::get_account_address_as_str(m_wallet.m_wallet->nettype(), utx.dests[0].is_subaddress, utx.dests[0].addr));
+ for (const auto &unsigned_dest : utx.dests) {
+ result.push_back(cryptonote::get_account_address_as_str(m_wallet.m_wallet->nettype(), unsigned_dest.is_subaddress, unsigned_dest.addr));
+ }
}
return result;
}
diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h
index 73438e0..a8c1e8d 100644
--- a/src/wallet/api/wallet2_api.h
+++ b/src/wallet/api/wallet2_api.h
@@ -140,6 +140,7 @@ struct UnsignedTransaction
// returns a string with information about all transactions.
virtual std::string confirmationMessage() const = 0;
virtual std::vector<std::string> paymentId() const = 0;
+ // returns one address per destination, in the same order as amount().
virtual std::vector<std::string> recipientAddress() const = 0;
virtual uint64_t minMixinCount() const = 0;
/*!
diff --git a/tests/libwallet_api_tests/main.cpp b/tests/libwallet_api_tests/main.cpp
index f256ea5..15780b0 100644
--- a/tests/libwallet_api_tests/main.cpp
+++ b/tests/libwallet_api_tests/main.cpp
@@ -747,8 +747,6 @@ TEST_F(WalletTest1, WalletTransaction)
ASSERT_TRUE(wmgr->closeWallet(wallet1));
}
-
-
TEST_F(WalletTest1, WalletTransactionWithMixin)
{
@@ -957,12 +955,16 @@ TEST_F(WalletTest1, WalletTransactionMultDestWithPaymentId)
ASSERT_TRUE(payment_id.length() == 16);
Monero::Wallet * wallet_dst = wmgr->openWallet(CURRENT_DST_WALLET, TESTNET_WALLET_PASS, WALLET_NETWORK_TYPE);
ASSERT_TRUE(wallet_dst != nullptr);
+ const std::string destination_address = wallet_dst->mainAddress();
std::string integrated_address = wallet_dst->integratedAddress(payment_id);
ASSERT_FALSE(integrated_address.empty());
ASSERT_TRUE(wmgr->closeWallet(wallet_dst));
const std::vector<std::string> destinations{integrated_address, wallet_src->mainAddress()};
+ const std::vector<std::string> recipient_addresses{destination_address, wallet_src->mainAddress()};
const std::vector<uint64_t> amounts{AMOUNT_1XMR, AMOUNT_1XMR};
+ const std::string unsigned_tx_filename = "unsigned-multi-destination-with-payment-id";
+ boost::filesystem::remove(unsigned_tx_filename);
Monero::PendingTransaction * tx = wallet_src->createTransactionMultDest(
destinations, PAYMENT_ID_EMPTY, amounts, 1,
Monero::PendingTransaction::Priority_Medium, 0, std::set<uint32_t>{});
@@ -971,6 +973,16 @@ TEST_F(WalletTest1, WalletTransactionMultDestWithPaymentId)
std::cerr << "Transaction fee: " << Monero::Wallet::displayAmount(tx->fee()) << std::endl;
std::cerr << "Transaction error: " << tx->errorString() << std::endl;
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
+ ASSERT_TRUE(tx->commit(unsigned_tx_filename)) << tx->errorString();
+
+ Monero::UnsignedTransaction * unsigned_transaction = wallet_src->loadUnsignedTx(unsigned_tx_filename);
+ ASSERT_EQ(Monero::UnsignedTransaction::Status_Ok, unsigned_transaction->status()) << unsigned_transaction->errorString();
+ ASSERT_EQ(1, unsigned_transaction->txCount());
+ EXPECT_EQ(amounts, unsigned_transaction->amount());
+ EXPECT_EQ(recipient_addresses, unsigned_transaction->recipientAddress());
+
+ delete unsigned_transaction;
+ boost::filesystem::remove(unsigned_tx_filename);
ASSERT_TRUE(tx->commit());
history->refresh();
ASSERT_TRUE(count != history->count());
Why this scored 19/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.