@@ -1011,7 +1011,7 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
10111011 * pblock is optional, but should be provided if the transaction is known to be in a block.
10121012 * If fUpdate is true, existing transactions will be updated.
10131013 */
1014- bool CWallet::AddToWalletIfInvolvingMe (const CTransaction& tx, const CBlockIndex* pIndex , int posInBlock, bool fUpdate )
1014+ bool CWallet::AddToWalletIfInvolvingMe (const CTransaction& tx, const uint256& blockHash , int posInBlock, bool fUpdate )
10151015{
10161016 {
10171017 AssertLockHeld (cs_wallet);
@@ -1021,8 +1021,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex
10211021 std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range (txin.prevout );
10221022 while (range.first != range.second ) {
10231023 if (range.first ->second != tx.GetHash ()) {
1024- LogPrintf (" Transaction %s (in block %s) conflicts with wallet transaction %s (both spend %s:%i)\n " , tx.GetHash ().ToString (), pIndex-> GetBlockHash () .ToString (), range.first ->second .ToString (), range.first ->first .hash .ToString (), range.first ->first .n );
1025- MarkConflicted (pIndex-> GetBlockHash () , range.first ->second );
1024+ LogPrintf (" Transaction %s (in block %s) conflicts with wallet transaction %s (both spend %s:%i)\n " , tx.GetHash ().ToString (), blockHash .ToString (), range.first ->second .ToString (), range.first ->first .hash .ToString (), range.first ->first .n );
1025+ MarkConflicted (blockHash , range.first ->second );
10261026 }
10271027 range.first ++;
10281028 }
@@ -1067,7 +1067,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlockIndex
10671067
10681068 // Get merkle branch if transaction was found in a block
10691069 if (posInBlock != -1 )
1070- wtx.SetMerkleBranch (pIndex-> GetBlockHash () , posInBlock);
1070+ wtx.SetMerkleBranch (blockHash , posInBlock);
10711071
10721072 return AddToWallet (wtx, false );
10731073 }
@@ -1195,7 +1195,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
11951195void CWallet::SyncTransaction (const CTransaction& tx, const CBlockIndex *pindex, int posInBlock)
11961196{
11971197 LOCK (cs_wallet);
1198- if (!AddToWalletIfInvolvingMe (tx, pindex, posInBlock, true ))
1198+ if (!AddToWalletIfInvolvingMe (tx, ( pindex) ? pindex-> GetBlockHash () : uint256 () , posInBlock, true ))
11991199 return ; // Not one of ours
12001200
12011201 MarkAffectedTransactionsDirty (tx);
@@ -1641,7 +1641,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate, b
16411641 int posInBlock;
16421642 for (posInBlock = 0 ; posInBlock < (int )block.vtx .size (); posInBlock++) {
16431643 const auto & tx = block.vtx [posInBlock];
1644- if (AddToWalletIfInvolvingMe (*tx, pindex, posInBlock, fUpdate )) {
1644+ if (AddToWalletIfInvolvingMe (*tx, pindex-> GetBlockHash () , posInBlock, fUpdate )) {
16451645 myTxHashes.push_back (tx->GetHash ());
16461646 ret++;
16471647 }
0 commit comments