|
|
@ -741,28 +741,10 @@ void CWallet::MarkDirty() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb) |
|
|
|
bool CWallet::AddToWallet(const CWalletTx& wtxIn, CWalletDB* pwalletdb) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint256 hash = wtxIn.GetHash(); |
|
|
|
uint256 hash = wtxIn.GetHash(); |
|
|
|
|
|
|
|
|
|
|
|
if (fFromLoadWallet) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mapWallet[hash] = wtxIn; |
|
|
|
|
|
|
|
CWalletTx& wtx = mapWallet[hash]; |
|
|
|
|
|
|
|
wtx.BindWallet(this); |
|
|
|
|
|
|
|
wtxOrdered.insert(make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); |
|
|
|
|
|
|
|
AddToSpends(hash); |
|
|
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, wtx.vin) { |
|
|
|
|
|
|
|
if (mapWallet.count(txin.prevout.hash)) { |
|
|
|
|
|
|
|
CWalletTx& prevtx = mapWallet[txin.prevout.hash]; |
|
|
|
|
|
|
|
if (prevtx.nIndex == -1 && !prevtx.hashUnset()) { |
|
|
|
|
|
|
|
MarkConflicted(prevtx.hashBlock, wtx.GetHash()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
|
// Inserts only if not already there, returns tx inserted or tx found
|
|
|
|
// Inserts only if not already there, returns tx inserted or tx found
|
|
|
|
pair<map<uint256, CWalletTx>::iterator, bool> ret = mapWallet.insert(make_pair(hash, wtxIn)); |
|
|
|
pair<map<uint256, CWalletTx>::iterator, bool> ret = mapWallet.insert(make_pair(hash, wtxIn)); |
|
|
@ -872,7 +854,27 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD |
|
|
|
boost::thread t(runCommand, strCmd); // thread runs free
|
|
|
|
boost::thread t(runCommand, strCmd); // thread runs free
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CWallet::LoadToWallet(const CWalletTx& wtxIn) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
uint256 hash = wtxIn.GetHash(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mapWallet[hash] = wtxIn; |
|
|
|
|
|
|
|
CWalletTx& wtx = mapWallet[hash]; |
|
|
|
|
|
|
|
wtx.BindWallet(this); |
|
|
|
|
|
|
|
wtxOrdered.insert(make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); |
|
|
|
|
|
|
|
AddToSpends(hash); |
|
|
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, wtx.vin) { |
|
|
|
|
|
|
|
if (mapWallet.count(txin.prevout.hash)) { |
|
|
|
|
|
|
|
CWalletTx& prevtx = mapWallet[txin.prevout.hash]; |
|
|
|
|
|
|
|
if (prevtx.nIndex == -1 && !prevtx.hashUnset()) { |
|
|
|
|
|
|
|
MarkConflicted(prevtx.hashBlock, wtx.GetHash()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -913,7 +915,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl |
|
|
|
// this is safe, as in case of a crash, we rescan the necessary blocks on startup through our SetBestChain-mechanism
|
|
|
|
// this is safe, as in case of a crash, we rescan the necessary blocks on startup through our SetBestChain-mechanism
|
|
|
|
CWalletDB walletdb(strWalletFile, "r+", false); |
|
|
|
CWalletDB walletdb(strWalletFile, "r+", false); |
|
|
|
|
|
|
|
|
|
|
|
return AddToWallet(wtx, false, &walletdb); |
|
|
|
return AddToWallet(wtx, &walletdb); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -2456,7 +2458,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) |
|
|
|
|
|
|
|
|
|
|
|
// Add tx to wallet, because if it has change it's also ours,
|
|
|
|
// Add tx to wallet, because if it has change it's also ours,
|
|
|
|
// otherwise just for transaction history.
|
|
|
|
// otherwise just for transaction history.
|
|
|
|
AddToWallet(wtxNew, false, pwalletdb); |
|
|
|
AddToWallet(wtxNew, pwalletdb); |
|
|
|
|
|
|
|
|
|
|
|
// Notify that old coins are spent
|
|
|
|
// Notify that old coins are spent
|
|
|
|
set<CWalletTx*> setCoins; |
|
|
|
set<CWalletTx*> setCoins; |
|
|
|