|
|
@ -288,7 +288,7 @@ bool CTransaction::AreInputsStandard(const MapPrevTx& mapInputs) const |
|
|
|
if (IsCoinBase()) |
|
|
|
if (IsCoinBase()) |
|
|
|
return true; // Coinbases don't use vin normally
|
|
|
|
return true; // Coinbases don't use vin normally
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CTxOut& prev = GetOutputFor(vin[i], mapInputs); |
|
|
|
const CTxOut& prev = GetOutputFor(vin[i], mapInputs); |
|
|
|
|
|
|
|
|
|
|
@ -484,7 +484,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi |
|
|
|
|
|
|
|
|
|
|
|
// Check for conflicts with in-memory transactions
|
|
|
|
// Check for conflicts with in-memory transactions
|
|
|
|
CTransaction* ptxOld = NULL; |
|
|
|
CTransaction* ptxOld = NULL; |
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
COutPoint outpoint = vin[i].prevout; |
|
|
|
COutPoint outpoint = vin[i].prevout; |
|
|
|
if (mapNextTx.count(outpoint)) |
|
|
|
if (mapNextTx.count(outpoint)) |
|
|
@ -500,7 +500,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (!IsNewerThan(*ptxOld)) |
|
|
|
if (!IsNewerThan(*ptxOld)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
COutPoint outpoint = vin[i].prevout; |
|
|
|
COutPoint outpoint = vin[i].prevout; |
|
|
|
if (!mapNextTx.count(outpoint) || mapNextTx[outpoint].ptx != ptxOld) |
|
|
|
if (!mapNextTx.count(outpoint) || mapNextTx[outpoint].ptx != ptxOld) |
|
|
@ -603,7 +603,7 @@ bool CTransaction::AddToMemoryPoolUnchecked() |
|
|
|
LOCK(cs_mapTransactions); |
|
|
|
LOCK(cs_mapTransactions); |
|
|
|
uint256 hash = GetHash(); |
|
|
|
uint256 hash = GetHash(); |
|
|
|
mapTransactions[hash] = *this; |
|
|
|
mapTransactions[hash] = *this; |
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
mapNextTx[vin[i].prevout] = CInPoint(&mapTransactions[hash], i); |
|
|
|
mapNextTx[vin[i].prevout] = CInPoint(&mapTransactions[hash], i); |
|
|
|
nTransactionsUpdated++; |
|
|
|
nTransactionsUpdated++; |
|
|
|
++nPooledTx; |
|
|
|
++nPooledTx; |
|
|
@ -989,7 +989,7 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTes |
|
|
|
if (IsCoinBase()) |
|
|
|
if (IsCoinBase()) |
|
|
|
return true; // Coinbase transactions have no inputs to fetch.
|
|
|
|
return true; // Coinbase transactions have no inputs to fetch.
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
COutPoint prevout = vin[i].prevout; |
|
|
|
COutPoint prevout = vin[i].prevout; |
|
|
|
if (inputsRet.count(prevout.hash)) |
|
|
|
if (inputsRet.count(prevout.hash)) |
|
|
@ -1034,7 +1034,7 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTes |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Make sure all prevout.n's are valid:
|
|
|
|
// Make sure all prevout.n's are valid:
|
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const COutPoint prevout = vin[i].prevout; |
|
|
|
const COutPoint prevout = vin[i].prevout; |
|
|
|
assert(inputsRet.count(prevout.hash) != 0); |
|
|
|
assert(inputsRet.count(prevout.hash) != 0); |
|
|
@ -1071,7 +1071,7 @@ int64 CTransaction::GetValueIn(const MapPrevTx& inputs) const |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
int64 nResult = 0; |
|
|
|
int64 nResult = 0; |
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nResult += GetOutputFor(vin[i], inputs).nValue; |
|
|
|
nResult += GetOutputFor(vin[i], inputs).nValue; |
|
|
|
} |
|
|
|
} |
|
|
@ -1085,7 +1085,7 @@ int CTransaction::GetP2SHSigOpCount(const MapPrevTx& inputs) const |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
int nSigOps = 0; |
|
|
|
int nSigOps = 0; |
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CTxOut& prevout = GetOutputFor(vin[i], inputs); |
|
|
|
const CTxOut& prevout = GetOutputFor(vin[i], inputs); |
|
|
|
if (prevout.scriptPubKey.IsPayToScriptHash()) |
|
|
|
if (prevout.scriptPubKey.IsPayToScriptHash()) |
|
|
@ -1106,7 +1106,7 @@ bool CTransaction::ConnectInputs(MapPrevTx inputs, |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64 nValueIn = 0; |
|
|
|
int64 nValueIn = 0; |
|
|
|
int64 nFees = 0; |
|
|
|
int64 nFees = 0; |
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
COutPoint prevout = vin[i].prevout; |
|
|
|
COutPoint prevout = vin[i].prevout; |
|
|
|
assert(inputs.count(prevout.hash) > 0); |
|
|
|
assert(inputs.count(prevout.hash) > 0); |
|
|
@ -1185,7 +1185,7 @@ bool CTransaction::ClientConnectInputs() |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_mapTransactions); |
|
|
|
LOCK(cs_mapTransactions); |
|
|
|
int64 nValueIn = 0; |
|
|
|
int64 nValueIn = 0; |
|
|
|
for (int i = 0; i < vin.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vin.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Get prev tx from single transactions in memory
|
|
|
|
// Get prev tx from single transactions in memory
|
|
|
|
COutPoint prevout = vin[i].prevout; |
|
|
|
COutPoint prevout = vin[i].prevout; |
|
|
@ -1396,7 +1396,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) |
|
|
|
|
|
|
|
|
|
|
|
// Connect longer branch
|
|
|
|
// Connect longer branch
|
|
|
|
vector<CTransaction> vDelete; |
|
|
|
vector<CTransaction> vDelete; |
|
|
|
for (int i = 0; i < vConnect.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vConnect.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CBlockIndex* pindex = vConnect[i]; |
|
|
|
CBlockIndex* pindex = vConnect[i]; |
|
|
|
CBlock block; |
|
|
|
CBlock block; |
|
|
@ -1635,7 +1635,7 @@ bool CBlock::CheckBlock() const |
|
|
|
// First transaction must be coinbase, the rest must not be
|
|
|
|
// First transaction must be coinbase, the rest must not be
|
|
|
|
if (vtx.empty() || !vtx[0].IsCoinBase()) |
|
|
|
if (vtx.empty() || !vtx[0].IsCoinBase()) |
|
|
|
return DoS(100, error("CheckBlock() : first tx is not coinbase")); |
|
|
|
return DoS(100, error("CheckBlock() : first tx is not coinbase")); |
|
|
|
for (int i = 1; i < vtx.size(); i++) |
|
|
|
for (unsigned int i = 1; i < vtx.size(); i++) |
|
|
|
if (vtx[i].IsCoinBase()) |
|
|
|
if (vtx[i].IsCoinBase()) |
|
|
|
return DoS(100, error("CheckBlock() : more than one coinbase")); |
|
|
|
return DoS(100, error("CheckBlock() : more than one coinbase")); |
|
|
|
|
|
|
|
|
|
|
@ -1771,7 +1771,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) |
|
|
|
// Recursively process any orphan blocks that depended on this one
|
|
|
|
// Recursively process any orphan blocks that depended on this one
|
|
|
|
vector<uint256> vWorkQueue; |
|
|
|
vector<uint256> vWorkQueue; |
|
|
|
vWorkQueue.push_back(hash); |
|
|
|
vWorkQueue.push_back(hash); |
|
|
|
for (int i = 0; i < vWorkQueue.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vWorkQueue.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint256 hashPrev = vWorkQueue[i]; |
|
|
|
uint256 hashPrev = vWorkQueue[i]; |
|
|
|
for (multimap<uint256, CBlock*>::iterator mi = mapOrphanBlocksByPrev.lower_bound(hashPrev); |
|
|
|
for (multimap<uint256, CBlock*>::iterator mi = mapOrphanBlocksByPrev.lower_bound(hashPrev); |
|
|
@ -1995,7 +1995,7 @@ void PrintBlockTree() |
|
|
|
|
|
|
|
|
|
|
|
// put the main timechain first
|
|
|
|
// put the main timechain first
|
|
|
|
vector<CBlockIndex*>& vNext = mapNext[pindex]; |
|
|
|
vector<CBlockIndex*>& vNext = mapNext[pindex]; |
|
|
|
for (int i = 0; i < vNext.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vNext.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (vNext[i]->pnext) |
|
|
|
if (vNext[i]->pnext) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2005,7 +2005,7 @@ void PrintBlockTree() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// iterate children
|
|
|
|
// iterate children
|
|
|
|
for (int i = 0; i < vNext.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vNext.size(); i++) |
|
|
|
vStack.push_back(make_pair(nCol+i, vNext[i])); |
|
|
|
vStack.push_back(make_pair(nCol+i, vNext[i])); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2374,7 +2374,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CTxDB txdb("r"); |
|
|
|
CTxDB txdb("r"); |
|
|
|
for (int nInv = 0; nInv < vInv.size(); nInv++) |
|
|
|
for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CInv &inv = vInv[nInv]; |
|
|
|
const CInv &inv = vInv[nInv]; |
|
|
|
|
|
|
|
|
|
|
@ -2550,7 +2550,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) |
|
|
|
vWorkQueue.push_back(inv.hash); |
|
|
|
vWorkQueue.push_back(inv.hash); |
|
|
|
|
|
|
|
|
|
|
|
// Recursively process any orphan transactions that depended on this one
|
|
|
|
// Recursively process any orphan transactions that depended on this one
|
|
|
|
for (int i = 0; i < vWorkQueue.size(); i++) |
|
|
|
for (unsigned int i = 0; i < vWorkQueue.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint256 hashPrev = vWorkQueue[i]; |
|
|
|
uint256 hashPrev = vWorkQueue[i]; |
|
|
|
for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(hashPrev); |
|
|
|
for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(hashPrev); |
|
|
@ -3330,7 +3330,7 @@ void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash |
|
|
|
FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1)); |
|
|
|
FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1)); |
|
|
|
|
|
|
|
|
|
|
|
// Byte swap all the input buffer
|
|
|
|
// Byte swap all the input buffer
|
|
|
|
for (int i = 0; i < sizeof(tmp)/4; i++) |
|
|
|
for (unsigned int i = 0; i < sizeof(tmp)/4; i++) |
|
|
|
((unsigned int*)&tmp)[i] = ByteReverse(((unsigned int*)&tmp)[i]); |
|
|
|
((unsigned int*)&tmp)[i] = ByteReverse(((unsigned int*)&tmp)[i]); |
|
|
|
|
|
|
|
|
|
|
|
// Precalc the first half of the first hash, which stays constant
|
|
|
|
// Precalc the first half of the first hash, which stays constant
|
|
|
@ -3455,7 +3455,7 @@ void static BitcoinMiner(CWallet *pwallet) |
|
|
|
// Check if something found
|
|
|
|
// Check if something found
|
|
|
|
if (nNonceFound != -1) |
|
|
|
if (nNonceFound != -1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int i = 0; i < sizeof(hash)/4; i++) |
|
|
|
for (unsigned int i = 0; i < sizeof(hash)/4; i++) |
|
|
|
((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]); |
|
|
|
((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]); |
|
|
|
|
|
|
|
|
|
|
|
if (hash <= hashTarget) |
|
|
|
if (hash <= hashTarget) |
|
|
|