@@ -663,16 +663,13 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid, Walle
663
663
}
664
664
665
665
666
- void CWallet::AddToSpends (const uint256& wtxid , WalletBatch* batch)
666
+ void CWallet::AddToSpends (const CWalletTx& wtx , WalletBatch* batch)
667
667
{
668
- auto it = mapWallet.find (wtxid);
669
- assert (it != mapWallet.end ());
670
- const CWalletTx& thisTx = it->second ;
671
- if (thisTx.IsCoinBase ()) // Coinbases don't spend anything!
668
+ if (wtx.IsCoinBase ()) // Coinbases don't spend anything!
672
669
return ;
673
670
674
- for (const CTxIn& txin : thisTx .tx ->vin )
675
- AddToSpends (txin.prevout , wtxid , batch);
671
+ for (const CTxIn& txin : wtx .tx ->vin )
672
+ AddToSpends (txin.prevout , wtx. GetHash () , batch);
676
673
}
677
674
678
675
bool CWallet::EncryptWallet (const SecureString& strWalletPassphrase)
@@ -967,7 +964,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const
967
964
wtx.nOrderPos = IncOrderPosNext (&batch);
968
965
wtx.m_it_wtxOrdered = wtxOrdered.insert (std::make_pair (wtx.nOrderPos , &wtx));
969
966
wtx.nTimeSmart = ComputeTimeSmart (wtx, rescanning_old_block);
970
- AddToSpends (hash , &batch);
967
+ AddToSpends (wtx , &batch);
971
968
}
972
969
973
970
if (!fInsertedNew )
@@ -1066,7 +1063,7 @@ bool CWallet::LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx
1066
1063
if (/* insertion took place */ ins.second ) {
1067
1064
wtx.m_it_wtxOrdered = wtxOrdered.insert (std::make_pair (wtx.nOrderPos , &wtx));
1068
1065
}
1069
- AddToSpends (hash );
1066
+ AddToSpends (wtx );
1070
1067
for (const CTxIn& txin : wtx.tx ->vin ) {
1071
1068
auto it = mapWallet.find (txin.prevout .hash );
1072
1069
if (it != mapWallet.end ()) {
0 commit comments