From 2a334b73ecadf5353127ea699b17f82705b9d589 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Tue, 9 Apr 2019 13:06:09 -0400 Subject: [PATCH] Slightly smarter change key vector padding --- src/interfaces/wallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp index 312ca27803..9766fc5f9e 100644 --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -237,8 +237,11 @@ public: auto pending = MakeUnique(m_wallet); // Pad change keys to cover total possible number of assets // One already exists(for policyAsset), so one for each destination - for (size_t i = 0; i < recipients.size(); ++i) { - pending->m_keys.emplace_back(new CReserveKey(&m_wallet)); + std::set assets_seen; + for (const auto& rec : recipients) { + if (assets_seen.insert(rec.asset).second) { + pending->m_keys.emplace_back(new CReserveKey(&m_wallet)); + } } if (!m_wallet.CreateTransaction(recipients, pending->m_tx, pending->m_keys, fee, change_pos, fail_reason, coin_control, sign)) {