Merge pull request #2769 from TheBlueMatt/master

Remove broken option to skip input checking for wallet txn.
This commit is contained in:
Pieter Wuille 2013-06-15 07:39:13 -07:00
commit 9e3a5deaa3
5 changed files with 15 additions and 16 deletions

View file

@ -694,7 +694,7 @@ void CTxMemPool::pruneSpent(const uint256 &hashTx, CCoins &coins)
} }
} }
bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fCheckInputs, bool fLimitFree, bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fLimitFree,
bool* pfMissingInputs) bool* pfMissingInputs)
{ {
if (pfMissingInputs) if (pfMissingInputs)
@ -751,7 +751,6 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fCheckIn
} }
} }
if (fCheckInputs)
{ {
CCoinsView dummy; CCoinsView dummy;
CCoinsViewCache view(dummy); CCoinsViewCache view(dummy);
@ -968,15 +967,15 @@ int CMerkleTx::GetBlocksToMaturity() const
} }
bool CMerkleTx::AcceptToMemoryPool(bool fCheckInputs, bool fLimitFree) bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree)
{ {
CValidationState state; CValidationState state;
return mempool.accept(state, *this, fCheckInputs, fLimitFree, NULL); return mempool.accept(state, *this, fLimitFree, NULL);
} }
bool CWalletTx::AcceptWalletTransaction(bool fCheckInputs) bool CWalletTx::AcceptWalletTransaction()
{ {
{ {
LOCK(mempool.cs); LOCK(mempool.cs);
@ -987,10 +986,10 @@ bool CWalletTx::AcceptWalletTransaction(bool fCheckInputs)
{ {
uint256 hash = tx.GetHash(); uint256 hash = tx.GetHash();
if (!mempool.exists(hash) && pcoinsTip->HaveCoins(hash)) if (!mempool.exists(hash) && pcoinsTip->HaveCoins(hash))
tx.AcceptToMemoryPool(fCheckInputs, false); tx.AcceptToMemoryPool(false);
} }
} }
return AcceptToMemoryPool(fCheckInputs, false); return AcceptToMemoryPool(false);
} }
return false; return false;
} }
@ -1865,7 +1864,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
BOOST_FOREACH(CTransaction& tx, vResurrect) { BOOST_FOREACH(CTransaction& tx, vResurrect) {
// ignore validation errors in resurrected transactions // ignore validation errors in resurrected transactions
CValidationState stateDummy; CValidationState stateDummy;
mempool.accept(stateDummy, tx, true, false, NULL); mempool.accept(stateDummy, tx, false, NULL);
} }
// Delete redundant memory transactions that are in the connected branch // Delete redundant memory transactions that are in the connected branch
@ -3507,7 +3506,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
bool fMissingInputs = false; bool fMissingInputs = false;
CValidationState state; CValidationState state;
if (mempool.accept(state, tx, true, true, &fMissingInputs)) if (mempool.accept(state, tx, true, &fMissingInputs))
{ {
RelayTransaction(tx, inv.hash, vMsg); RelayTransaction(tx, inv.hash, vMsg);
mapAlreadyAskedFor.erase(inv); mapAlreadyAskedFor.erase(inv);
@ -3530,7 +3529,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// Use a dummy CValidationState so someone can't setup nodes to counter-DoS based on orphan resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get anyone relaying LegitTxX banned) // Use a dummy CValidationState so someone can't setup nodes to counter-DoS based on orphan resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get anyone relaying LegitTxX banned)
CValidationState stateDummy; CValidationState stateDummy;
if (mempool.accept(stateDummy, tx, true, true, &fMissingInputs2)) if (mempool.accept(stateDummy, tx, true, &fMissingInputs2))
{ {
printf(" accepted orphan tx %s\n", inv.hash.ToString().c_str()); printf(" accepted orphan tx %s\n", inv.hash.ToString().c_str());
RelayTransaction(tx, inv.hash, vMsg); RelayTransaction(tx, inv.hash, vMsg);

View file

@ -478,7 +478,7 @@ public:
int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); } int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
bool IsInMainChain() const { return GetDepthInMainChain() > 0; } bool IsInMainChain() const { return GetDepthInMainChain() > 0; }
int GetBlocksToMaturity() const; int GetBlocksToMaturity() const;
bool AcceptToMemoryPool(bool fCheckInputs=true, bool fLimitFree=true); bool AcceptToMemoryPool(bool fLimitFree=true);
}; };
@ -1334,7 +1334,7 @@ public:
std::map<uint256, CTransaction> mapTx; std::map<uint256, CTransaction> mapTx;
std::map<COutPoint, CInPoint> mapNextTx; std::map<COutPoint, CInPoint> mapNextTx;
bool accept(CValidationState &state, CTransaction &tx, bool fCheckInputs, bool fLimitFree, bool* pfMissingInputs); bool accept(CValidationState &state, CTransaction &tx, bool fLimitFree, bool* pfMissingInputs);
bool addUnchecked(const uint256& hash, CTransaction &tx); bool addUnchecked(const uint256& hash, CTransaction &tx);
bool remove(const CTransaction &tx, bool fRecursive = false); bool remove(const CTransaction &tx, bool fRecursive = false);
bool removeConflicts(const CTransaction &tx); bool removeConflicts(const CTransaction &tx);

View file

@ -555,7 +555,7 @@ Value sendrawtransaction(const Array& params, bool fHelp)
if (!fHave) { if (!fHave) {
// push to local node // push to local node
CValidationState state; CValidationState state;
if (!mempool.accept(state, tx, true, false, NULL)) if (!mempool.accept(state, tx, false, NULL))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX rejected"); // TODO: report validation state throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX rejected"); // TODO: report validation state
} }
} }

View file

@ -852,7 +852,7 @@ void CWallet::ReacceptWalletTransactions()
{ {
// Re-accept any txes of ours that aren't already in a block // Re-accept any txes of ours that aren't already in a block
if (!wtx.IsCoinBase()) if (!wtx.IsCoinBase())
wtx.AcceptWalletTransaction(false); wtx.AcceptWalletTransaction();
} }
} }
if (fMissing) if (fMissing)
@ -1365,7 +1365,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
mapRequestCount[wtxNew.GetHash()] = 0; mapRequestCount[wtxNew.GetHash()] = 0;
// Broadcast // Broadcast
if (!wtxNew.AcceptToMemoryPool(true, false)) if (!wtxNew.AcceptToMemoryPool(false))
{ {
// This must not fail. The transaction has already been signed and recorded. // This must not fail. The transaction has already been signed and recorded.
printf("CommitTransaction() : Error: Transaction not valid"); printf("CommitTransaction() : Error: Transaction not valid");

View file

@ -689,7 +689,7 @@ public:
int GetRequestCount() const; int GetRequestCount() const;
void AddSupportingTransactions(); void AddSupportingTransactions();
bool AcceptWalletTransaction(bool fCheckInputs=true); bool AcceptWalletTransaction();
void RelayWalletTransaction(); void RelayWalletTransaction();
}; };