From fdf4084af9391d3fa53c9a35ec82682044b31136 Mon Sep 17 00:00:00 2001 From: lateminer <9951982+lateminer@users.noreply.github.com> Date: Tue, 23 Jan 2024 18:36:49 +0100 Subject: [PATCH] refactor: Store `CTransactionRef` in vwtxPrev vector --- src/wallet/staking.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/wallet/staking.cpp b/src/wallet/staking.cpp index 2c86cfee66..7432ae9e75 100644 --- a/src/wallet/staking.cpp +++ b/src/wallet/staking.cpp @@ -272,7 +272,7 @@ bool CreateCoinStake(CWallet& wallet, unsigned int nBits, int64_t nSearchInterva return false; std::set > setCoins; - std::vector > vwtxPrev; + std::vector vwtxPrev; CAmount nValueIn = 0; CAmount nAllowedBalance = nBalance - wallet.m_reserve_balance; @@ -382,7 +382,7 @@ bool CreateCoinStake(CWallet& wallet, unsigned int nBits, int64_t nSearchInterva txNew.nTime -= n; txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); nCredit += pcoin.first->tx->vout[pcoin.second].nValue; - vwtxPrev.push_back(pcoin); + vwtxPrev.push_back(tx); if (bMinterKey) { // extra output for minter key @@ -431,7 +431,7 @@ bool CreateCoinStake(CWallet& wallet, unsigned int nBits, int64_t nSearchInterva txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); nCredit += pcoin.first->tx->vout[pcoin.second].nValue; - vwtxPrev.push_back(pcoin); + vwtxPrev.push_back(tx); } } @@ -481,9 +481,8 @@ bool CreateCoinStake(CWallet& wallet, unsigned int nBits, int64_t nSearchInterva SignatureData empty; if (wallet.IsLegacy()) { - for (const std::pair &pcoin : vwtxPrev) - { - if (!SignSignature(*wallet.GetLegacyScriptPubKeyMan(), *pcoin.first->tx, txNew, nIn++, SIGHASH_ALL, empty)) + for (const auto &pcoin : vwtxPrev) { + if (!SignSignature(*wallet.GetLegacyScriptPubKeyMan(), *pcoin, txNew, nIn++, SIGHASH_ALL, empty)) return error("CreateCoinStake : failed to sign coinstake"); } }