@@ -64,8 +64,6 @@ void CInstantSendDb::Upgrade()
64
64
if (!db->Read (DB_VERSION, v) || v < CInstantSendDb::CURRENT_VERSION) {
65
65
CDBBatch batch (*db);
66
66
CInstantSendLock islock;
67
- CTransactionRef tx;
68
- uint256 hashBlock;
69
67
70
68
auto it = std::unique_ptr<CDBIterator>(db->NewIterator ());
71
69
auto firstKey = std::make_tuple (DB_ISLOCK_BY_HASH, uint256 ());
@@ -76,7 +74,9 @@ void CInstantSendDb::Upgrade()
76
74
if (!it->GetKey (curKey) || std::get<0 >(curKey) != DB_ISLOCK_BY_HASH) {
77
75
break ;
78
76
}
79
- if (it->GetValue (islock) && !GetTransaction (islock.txid , tx, Params ().GetConsensus (), hashBlock)) {
77
+ uint256 hashBlock;
78
+ CTransactionRef tx = GetTransaction (/* block_index */ nullptr , /* mempool */ nullptr , islock.txid , Params ().GetConsensus (), hashBlock);
79
+ if (it->GetValue (islock) && !tx) {
80
80
// Drop locks for unknown txes
81
81
batch.Erase (std::make_tuple (DB_HASH_BY_TXID, islock.txid ));
82
82
for (auto & in : islock.inputs ) {
@@ -603,10 +603,10 @@ bool CInstantSendManager::CheckCanLock(const COutPoint& outpoint, bool printDebu
603
603
return false ;
604
604
}
605
605
606
- CTransactionRef tx;
607
606
uint256 hashBlock;
607
+ CTransactionRef tx = GetTransaction (/* block_index */ nullptr , &mempool, outpoint.hash , params, hashBlock);
608
608
// this relies on enabled txindex and won't work if we ever try to remove the requirement for txindex for masternodes
609
- if (!GetTransaction (outpoint. hash , tx, params, hashBlock) ) {
609
+ if (!tx ) {
610
610
if (printDebug) {
611
611
LogPrint (BCLog::INSTANTSEND, " CInstantSendManager::%s -- txid=%s: failed to find parent TX %s\n " , __func__,
612
612
txHash.ToString (), outpoint.hash .ToString ());
@@ -661,9 +661,9 @@ void CInstantSendManager::HandleNewInputLockRecoveredSig(const CRecoveredSig& re
661
661
g_txindex->BlockUntilSyncedToCurrentChain ();
662
662
}
663
663
664
- CTransactionRef tx;
665
664
uint256 hashBlock;
666
- if (!GetTransaction (txid, tx, Params ().GetConsensus (), hashBlock)) {
665
+ CTransactionRef tx = GetTransaction (/* block_index */ nullptr , &mempool, txid, Params ().GetConsensus (), hashBlock);
666
+ if (!tx) {
667
667
return ;
668
668
}
669
669
@@ -1048,11 +1048,11 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, const uint256& has
1048
1048
return ;
1049
1049
}
1050
1050
1051
- CTransactionRef tx;
1052
1051
uint256 hashBlock;
1052
+ CTransactionRef tx = GetTransaction (/* block_index */ nullptr , &mempool, islock->txid , Params ().GetConsensus (), hashBlock);
1053
1053
const CBlockIndex* pindexMined{nullptr };
1054
1054
// we ignore failure here as we must be able to propagate the lock even if we don't have the TX locally
1055
- if (GetTransaction (islock-> txid , tx, Params (). GetConsensus (), hashBlock) && !hashBlock.IsNull ()) {
1055
+ if (tx && !hashBlock.IsNull ()) {
1056
1056
pindexMined = WITH_LOCK (cs_main, return LookupBlockIndex (hashBlock));
1057
1057
1058
1058
// Let's see if the TX that was locked by this islock is already mined in a ChainLocked block. If yes,
0 commit comments