diff --git a/src/wallet/api/unsigned_transaction.cpp b/src/wallet/api/unsigned_transaction.cpp index a8d8bbf59..11301595d 100644 --- a/src/wallet/api/unsigned_transaction.cpp +++ b/src/wallet/api/unsigned_transaction.cpp @@ -304,7 +304,9 @@ std::vector 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 73438e089..a8c1e8d9c 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 paymentId() const = 0; + // returns one address per destination, in the same order as amount(). virtual std::vector 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 f256ea5b2..15780b00f 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 destinations{integrated_address, wallet_src->mainAddress()}; + const std::vector recipient_addresses{destination_address, wallet_src->mainAddress()}; const std::vector 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{}); @@ -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());