diff --git a/src/bench/ccoins_caching.cpp b/src/bench/ccoins_caching.cpp --- a/src/bench/ccoins_caching.cpp +++ b/src/bench/ccoins_caching.cpp @@ -65,14 +65,14 @@ CMutableTransaction t1; t1.vin.resize(3); - t1.vin[0].prevout.hash = dummyTransactions[0].GetId(); + t1.vin[0].prevout.hash = dummyTransactions[0].GetHash(); t1.vin[0].prevout.n = 1; t1.vin[0].scriptSig << std::vector(65, 0); - t1.vin[1].prevout.hash = dummyTransactions[1].GetId(); + t1.vin[1].prevout.hash = dummyTransactions[1].GetHash(); t1.vin[1].prevout.n = 0; t1.vin[1].scriptSig << std::vector(65, 0) << std::vector(33, 4); - t1.vin[2].prevout.hash = dummyTransactions[1].GetId(); + t1.vin[2].prevout.hash = dummyTransactions[1].GetHash(); t1.vin[2].prevout.n = 1; t1.vin[2].scriptSig << std::vector(65, 0) << std::vector(33, 4); diff --git a/src/bench/mempool_eviction.cpp b/src/bench/mempool_eviction.cpp --- a/src/bench/mempool_eviction.cpp +++ b/src/bench/mempool_eviction.cpp @@ -17,7 +17,7 @@ bool spendsCoinbase = false; unsigned int sigOpCost = 4; LockPoints lp; - pool.addUnchecked(tx.GetId(), + pool.addUnchecked(tx.GetHash(), CTxMemPoolEntry(MakeTransactionRef(tx), nFee, nTime, dPriority, nHeight, tx.GetValueOut().GetSatoshis(), @@ -44,7 +44,7 @@ CMutableTransaction tx3 = CMutableTransaction(); tx3.vin.resize(1); - tx3.vin[0].prevout = COutPoint(tx2.GetId(), 0); + tx3.vin[0].prevout = COutPoint(tx2.GetHash(), 0); tx3.vin[0].scriptSig = CScript() << OP_2; tx3.vout.resize(1); tx3.vout[0].scriptPubKey = CScript() << OP_3 << OP_EQUAL; @@ -64,7 +64,7 @@ CMutableTransaction tx5 = CMutableTransaction(); tx5.vin.resize(2); - tx5.vin[0].prevout = COutPoint(tx4.GetId(), 0); + tx5.vin[0].prevout = COutPoint(tx4.GetHash(), 0); tx5.vin[0].scriptSig = CScript() << OP_4; tx5.vin[1].prevout.SetNull(); tx5.vin[1].scriptSig = CScript() << OP_5; @@ -76,7 +76,7 @@ CMutableTransaction tx6 = CMutableTransaction(); tx6.vin.resize(2); - tx6.vin[0].prevout = COutPoint(tx4.GetId(), 1); + tx6.vin[0].prevout = COutPoint(tx4.GetHash(), 1); tx6.vin[0].scriptSig = CScript() << OP_4; tx6.vin[1].prevout.SetNull(); tx6.vin[1].scriptSig = CScript() << OP_6; @@ -88,9 +88,9 @@ CMutableTransaction tx7 = CMutableTransaction(); tx7.vin.resize(2); - tx7.vin[0].prevout = COutPoint(tx5.GetId(), 0); + tx7.vin[0].prevout = COutPoint(tx5.GetHash(), 0); tx7.vin[0].scriptSig = CScript() << OP_5; - tx7.vin[1].prevout = COutPoint(tx6.GetId(), 0); + tx7.vin[1].prevout = COutPoint(tx6.GetHash(), 0); tx7.vin[1].scriptSig = CScript() << OP_6; tx7.vout.resize(2); tx7.vout[0].scriptPubKey = CScript() << OP_7 << OP_EQUAL; diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -763,7 +763,7 @@ static void OutputTxHash(const CTransaction &tx) { // the hex-encoded transaction id. - std::string strHexHash = tx.GetId().GetHex(); + std::string strHexHash = tx.GetHash().GetHex(); fprintf(stdout, "%s\n", strHexHash.c_str()); } diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -237,7 +237,7 @@ if (vtx_missing.size() < 5) { for (const auto &tx : vtx_missing) LogPrint("cmpctblock", "Reconstructed block %s required tx %s\n", - hash.ToString(), tx->GetId().ToString()); + hash.ToString(), tx->GetHash().ToString()); } return READ_STATUS_OK; diff --git a/src/bloom.cpp b/src/bloom.cpp --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -124,7 +124,7 @@ // appear in a block if (isFull) return true; if (isEmpty) return false; - const uint256 &txid = tx.GetId(); + const uint256 &txid = tx.GetHash(); if (contains(txid)) fFound = true; for (unsigned int i = 0; i < tx.vout.size(); i++) { diff --git a/src/consensus/merkle.cpp b/src/consensus/merkle.cpp --- a/src/consensus/merkle.cpp +++ b/src/consensus/merkle.cpp @@ -176,7 +176,7 @@ std::vector leaves; leaves.resize(block.vtx.size()); for (size_t s = 0; s < block.vtx.size(); s++) { - leaves[s] = block.vtx[s]->GetId(); + leaves[s] = block.vtx[s]->GetHash(); } return ComputeMerkleRoot(leaves, mutated); } @@ -185,7 +185,7 @@ std::vector leaves; leaves.resize(block.vtx.size()); for (size_t s = 0; s < block.vtx.size(); s++) { - leaves[s] = block.vtx[s]->GetId(); + leaves[s] = block.vtx[s]->GetHash(); } return ComputeMerkleBranch(leaves, position); } diff --git a/src/core_write.cpp b/src/core_write.cpp --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -183,7 +183,7 @@ void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry) { - entry.pushKV("txid", tx.GetId().GetHex()); + entry.pushKV("txid", tx.GetHash().GetHex()); entry.pushKV("hash", tx.GetHash().GetHex()); entry.pushKV("version", tx.nVersion); entry.pushKV("locktime", (int64_t)tx.nLockTime); diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp --- a/src/merkleblock.cpp +++ b/src/merkleblock.cpp @@ -19,7 +19,7 @@ vHashes.reserve(block.vtx.size()); for (unsigned int i = 0; i < block.vtx.size(); i++) { - const uint256 &txid = block.vtx[i]->GetId(); + const uint256 &txid = block.vtx[i]->GetHash(); if (filter.IsRelevantAndUpdate(*block.vtx[i])) { vMatch.push_back(true); vMatchedTxn.push_back(std::make_pair(i, txid)); @@ -42,7 +42,7 @@ vHashes.reserve(block.vtx.size()); for (unsigned int i = 0; i < block.vtx.size(); i++) { - const uint256 &txid = block.vtx[i]->GetId(); + const uint256 &txid = block.vtx[i]->GetHash(); if (txids.count(txid)) vMatch.push_back(true); else diff --git a/src/miner.cpp b/src/miner.cpp --- a/src/miner.cpp +++ b/src/miner.cpp @@ -349,11 +349,11 @@ if (fPrintPriority) { double dPriority = iter->GetPriority(nHeight); Amount dummy; - mempool.ApplyDeltas(iter->GetTx().GetId(), dPriority, dummy); + mempool.ApplyDeltas(iter->GetTx().GetHash(), dPriority, dummy); LogPrintf( "priority %.1f fee %s txid %s\n", dPriority, CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(), - iter->GetTx().GetId().ToString()); + iter->GetTx().GetHash().ToString()); } } @@ -582,7 +582,7 @@ mi != mempool.mapTx.end(); ++mi) { double dPriority = mi->GetPriority(nHeight); Amount dummy; - mempool.ApplyDeltas(mi->GetTx().GetId(), dPriority, dummy); + mempool.ApplyDeltas(mi->GetTx().GetHash(), dPriority, dummy); vecPriority.push_back(TxCoinAgePriority(dPriority, mi)); } std::make_heap(vecPriority.begin(), vecPriority.end(), pricomparer); diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -726,7 +726,7 @@ bool AddOrphanTx(const CTransactionRef &tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { - const uint256 &txid = tx->GetId(); + const uint256 &txid = tx->GetHash(); if (mapOrphanTransactions.count(txid)) { return false; } @@ -786,7 +786,7 @@ // Increment to avoid iterator becoming invalid. std::map::iterator maybeErase = iter++; if (maybeErase->second.fromPeer == peer) { - nErased += EraseOrphanTx(maybeErase->second.tx->GetId()); + nErased += EraseOrphanTx(maybeErase->second.tx->GetHash()); } } if (nErased > 0) { @@ -810,7 +810,7 @@ while (iter != mapOrphanTransactions.end()) { std::map::iterator maybeErase = iter++; if (maybeErase->second.nTimeExpire <= nNow) { - nErased += EraseOrphanTx(maybeErase->second.tx->GetId()); + nErased += EraseOrphanTx(maybeErase->second.tx->GetHash()); } else { nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime); @@ -900,7 +900,7 @@ for (auto mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { const CTransaction &orphanTx = *(*mi)->second.tx; - const uint256 &orphanId = orphanTx.GetId(); + const uint256 &orphanId = orphanTx.GetHash(); vOrphanErase.push_back(orphanId); } } @@ -1085,7 +1085,7 @@ } static void RelayTransaction(const CTransaction &tx, CConnman &connman) { - CInv inv(MSG_TX, tx.GetId()); + CInv inv(MSG_TX, tx.GetHash()); connman.ForEachNode([&inv](CNode *pnode) { pnode->PushInventory(inv); }); } @@ -2069,7 +2069,7 @@ vRecv >> ptx; const CTransaction &tx = *ptx; - CInv inv(MSG_TX, tx.GetId()); + CInv inv(MSG_TX, tx.GetHash()); pfrom->AddInventoryKnown(inv); LOCK(cs_main); @@ -2095,7 +2095,7 @@ LogPrint("mempool", "AcceptToMemoryPool: peer=%d: accepted %s " "(poolsz %u txn, %u kB)\n", - pfrom->id, tx.GetId().ToString(), mempool.size(), + pfrom->id, tx.GetHash().ToString(), mempool.size(), mempool.DynamicMemoryUsage() / 1000); // Recursively process any orphan transactions that depended on this @@ -2112,7 +2112,7 @@ mi != itByPrev->second.end(); ++mi) { const CTransactionRef &porphanTx = (*mi)->second.tx; const CTransaction &orphanTx = *porphanTx; - const uint256 &orphanId = orphanTx.GetId(); + const uint256 &orphanId = orphanTx.GetHash(); NodeId fromPeer = (*mi)->second.fromPeer; bool fMissingInputs2 = false; // Use a dummy CValidationState so someone can't setup nodes @@ -2200,10 +2200,10 @@ } else { LogPrint("mempool", "not keeping orphan with rejected parents %s\n", - tx.GetId().ToString()); + tx.GetHash().ToString()); // We will continue to reject this tx since it has rejected // parents so avoid re-requesting it from other peers. - recentRejects->insert(tx.GetId()); + recentRejects->insert(tx.GetHash()); } } else { if (!state.CorruptionPossible()) { @@ -2212,7 +2212,7 @@ // malleated. See https://github.com/bitcoin/bitcoin/issues/8279 // for details. assert(recentRejects); - recentRejects->insert(tx.GetId()); + recentRejects->insert(tx.GetHash()); if (RecursiveDynamicUsage(*ptx) < 100000) { AddToCompactExtraTransactions(ptx); } @@ -2232,12 +2232,12 @@ int nDoS = 0; if (!state.IsInvalid(nDoS) || nDoS == 0) { LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", - tx.GetId().ToString(), pfrom->id); + tx.GetHash().ToString(), pfrom->id); RelayTransaction(tx, connman); } else { LogPrintf("Not relaying invalid transaction %s from " "whitelisted peer=%d (%s)\n", - tx.GetId().ToString(), pfrom->id, + tx.GetHash().ToString(), pfrom->id, FormatStateMessage(state)); } } @@ -2250,7 +2250,7 @@ int nDoS = 0; if (state.IsInvalid(nDoS)) { LogPrint("mempoolrej", "%s from peer=%d was not accepted: %s\n", - tx.GetId().ToString(), pfrom->id, + tx.GetHash().ToString(), pfrom->id, FormatStateMessage(state)); // Never send AcceptToMemoryPool's internal codes over P2P. if (state.GetRejectCode() < REJECT_INTERNAL) { @@ -3587,7 +3587,7 @@ LOCK(pto->cs_filter); for (const auto &txinfo : vtxinfo) { - const uint256 &txid = txinfo.tx->GetId(); + const uint256 &txid = txinfo.tx->GetHash(); CInv inv(MSG_TX, txid); pto->setInventoryTxToSend.erase(txid); if (filterrate != 0) { diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -355,7 +355,7 @@ void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry &entry, bool validFeeEstimate) { uint32_t txHeight = entry.GetHeight(); - uint256 txid = entry.GetTx().GetId(); + uint256 txid = entry.GetTx().GetHash(); if (mapMemPoolTxs.count(txid)) { LogPrint("estimatefee", "Blockpolicy error mempool tx %s already being tracked\n", @@ -390,7 +390,7 @@ bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry *entry) { - if (!removeTx(entry->GetTx().GetId())) { + if (!removeTx(entry->GetTx().GetHash())) { // This transaction wasn't being tracked for fee estimation return false; } diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -272,10 +272,7 @@ bool IsNull() const { return vin.empty() && vout.empty(); } - const TxHash &GetId() const { return hash; } - - // Compute a hash that includes both transaction and witness data - TxHash GetHash() const; + const TxHash &GetHash() const { return hash; } // Return sum of txouts. Amount GetValueOut() const; @@ -337,11 +334,11 @@ /** Compute the hash of this CMutableTransaction. This is computed on the * fly, as opposed to GetId() in CTransaction, which uses a cached result. */ - TxHash GetId() const; + TxHash GetHash() const; friend bool operator==(const CMutableTransaction &a, const CMutableTransaction &b) { - return a.GetId() == b.GetId(); + return a.GetHash() == b.GetHash(); } }; diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -58,7 +58,7 @@ : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime) {} -TxHash CMutableTransaction::GetId() const { +TxHash CMutableTransaction::GetHash() const { return SerializeHash(*this, SER_GETHASH, 0); } @@ -66,10 +66,6 @@ return SerializeHash(*this, SER_GETHASH, 0); } -TxHash CTransaction::GetHash() const { - return GetId(); -} - /** * For backward compatibility, the hash is initialized to 0. * TODO: remove the need for this default constructor entirely. @@ -129,7 +125,7 @@ std::string str; str += strprintf("CTransaction(txid=%s, ver=%d, vin.size=%u, vout.size=%u, " "nLockTime=%u)\n", - GetId().ToString().substr(0, 10), nVersion, vin.size(), + GetHash().ToString().substr(0, 10), nVersion, vin.size(), vout.size(), nLockTime); for (unsigned int i = 0; i < vin.size(); i++) str += " " + vin[i].ToString() + "\n"; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -127,7 +127,7 @@ TxToJSON(*tx, uint256(), objTx); txs.push_back(objTx); } else - txs.push_back(tx->GetId().GetHex()); + txs.push_back(tx->GetHash().GetHex()); } result.push_back(Pair("tx", txs)); result.push_back(Pair("time", block.GetBlockTime())); @@ -441,7 +441,7 @@ LOCK(mempool.cs); UniValue o(UniValue::VOBJ); for (const CTxMemPoolEntry &e : mempool.mapTx) { - const uint256 &txid = e.GetTx().GetId(); + const uint256 &txid = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); o.push_back(Pair(txid.ToString(), info)); @@ -544,7 +544,7 @@ if (!fVerbose) { UniValue o(UniValue::VARR); for (CTxMemPool::txiter ancestorIt : setAncestors) { - o.push_back(ancestorIt->GetTx().GetId().ToString()); + o.push_back(ancestorIt->GetTx().GetHash().ToString()); } return o; @@ -552,7 +552,7 @@ UniValue o(UniValue::VOBJ); for (CTxMemPool::txiter ancestorIt : setAncestors) { const CTxMemPoolEntry &e = *ancestorIt; - const uint256 &_hash = e.GetTx().GetId(); + const uint256 &_hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); o.push_back(Pair(_hash.ToString(), info)); @@ -610,7 +610,7 @@ if (!fVerbose) { UniValue o(UniValue::VARR); for (CTxMemPool::txiter descendantIt : setDescendants) { - o.push_back(descendantIt->GetTx().GetId().ToString()); + o.push_back(descendantIt->GetTx().GetHash().ToString()); } return o; @@ -618,7 +618,7 @@ UniValue o(UniValue::VOBJ); for (CTxMemPool::txiter descendantIt : setDescendants) { const CTxMemPoolEntry &e = *descendantIt; - const uint256 &_hash = e.GetTx().GetId(); + const uint256 &_hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); entryToJSON(info, e); o.push_back(Pair(_hash.ToString(), info)); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -685,7 +685,7 @@ int i = 0; for (const auto &it : pblock->vtx) { const CTransaction &tx = *it; - uint256 txId = tx.GetId(); + uint256 txId = tx.GetHash(); setTxIndex[txId] = i++; if (tx.IsCoinBase()) { diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -62,7 +62,7 @@ void TxToJSON(const CTransaction &tx, const uint256 hashBlock, UniValue &entry) { - entry.push_back(Pair("txid", tx.GetId().GetHex())); + entry.push_back(Pair("txid", tx.GetHash().GetHex())); entry.push_back(Pair("hash", tx.GetHash().GetHex())); entry.push_back(Pair( "size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION))); @@ -344,7 +344,7 @@ unsigned int ntxFound = 0; for (const auto &tx : block.vtx) { - if (setTxids.count(tx->GetId())) { + if (setTxids.count(tx->GetHash())) { ntxFound++; } } @@ -1109,7 +1109,7 @@ } CTransactionRef tx(MakeTransactionRef(std::move(mtx))); - const uint256 &txid = tx->GetId(); + const uint256 &txid = tx->GetHash(); bool fLimitFree = false; Amount nMaxRawTxFee = maxTxFee; diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -169,7 +169,7 @@ CMutableTransaction tx; tx.vin.resize(1); tx.vin[0].prevout.n = 0; - tx.vin[0].prevout.hash = txPrev->GetId(); + tx.vin[0].prevout.hash = txPrev->GetHash(); tx.vout.resize(1); tx.vout[0].nValue = 1 * CENT.GetSatoshis(); tx.vout[0].scriptPubKey = @@ -191,7 +191,7 @@ tx.vin.resize(2777); for (unsigned int j = 0; j < tx.vin.size(); j++) { tx.vin[j].prevout.n = j; - tx.vin[j].prevout.hash = txPrev->GetId(); + tx.vin[j].prevout.hash = txPrev->GetHash(); } SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL); // Re-use same signature for other inputs diff --git a/src/test/blockencodings_tests.cpp b/src/test/blockencodings_tests.cpp --- a/src/test/blockencodings_tests.cpp +++ b/src/test/blockencodings_tests.cpp @@ -63,9 +63,9 @@ TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); - pool.addUnchecked(block.vtx[2]->GetId(), entry.FromTx(*block.vtx[2])); + pool.addUnchecked(block.vtx[2]->GetHash(), entry.FromTx(*block.vtx[2])); BOOST_CHECK_EQUAL( - pool.mapTx.find(block.vtx[2]->GetId())->GetSharedTx().use_count(), + pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); // Do a simple ShortTxIDs RT @@ -86,7 +86,7 @@ BOOST_CHECK(partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL( - pool.mapTx.find(block.vtx[2]->GetId())->GetSharedTx().use_count(), + pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); size_t poolSize = pool.size(); @@ -173,9 +173,9 @@ TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); - pool.addUnchecked(block.vtx[2]->GetId(), entry.FromTx(*block.vtx[2])); + pool.addUnchecked(block.vtx[2]->GetHash(), entry.FromTx(*block.vtx[2])); BOOST_CHECK_EQUAL( - pool.mapTx.find(block.vtx[2]->GetId())->GetSharedTx().use_count(), + pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); uint256 txhash; @@ -186,8 +186,8 @@ shortIDs.prefilledtxn.resize(1); shortIDs.prefilledtxn[0] = {1, block.vtx[1]}; shortIDs.shorttxids.resize(2); - shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetId()); - shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetId()); + shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetHash()); + shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetHash()); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; @@ -203,7 +203,7 @@ BOOST_CHECK(partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL( - pool.mapTx.find(block.vtx[2]->GetId())->GetSharedTx().use_count(), + pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); CBlock block2; @@ -236,7 +236,7 @@ BlockMerkleRoot(block3, &mutated).ToString()); BOOST_CHECK(!mutated); - txhash = block.vtx[2]->GetId(); + txhash = block.vtx[2]->GetHash(); block.vtx.clear(); block2.vtx.clear(); block3.vtx.clear(); @@ -254,9 +254,9 @@ TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); - pool.addUnchecked(block.vtx[1]->GetId(), entry.FromTx(*block.vtx[1])); + pool.addUnchecked(block.vtx[1]->GetHash(), entry.FromTx(*block.vtx[1])); BOOST_CHECK_EQUAL( - pool.mapTx.find(block.vtx[1]->GetId())->GetSharedTx().use_count(), + pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); uint256 txhash; @@ -269,7 +269,7 @@ // id == 1 as it is 1 after index 1 shortIDs.prefilledtxn[1] = {1, block.vtx[2]}; shortIDs.shorttxids.resize(1); - shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetId()); + shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash()); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; @@ -285,7 +285,7 @@ BOOST_CHECK(partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL( - pool.mapTx.find(block.vtx[1]->GetId())->GetSharedTx().use_count(), + pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); CBlock block2; @@ -298,7 +298,7 @@ BlockMerkleRoot(block2, &mutated).ToString()); BOOST_CHECK(!mutated); - txhash = block.vtx[1]->GetId(); + txhash = block.vtx[1]->GetHash(); block.vtx.clear(); block2.vtx.clear(); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -323,7 +323,7 @@ duplicate_coins.insert(utxod->first); } else { - coinbase_coins.insert(COutPoint(tx.GetId(), 0)); + coinbase_coins.insert(COutPoint(tx.GetHash(), 0)); } assert(CTransaction(tx).IsCoinBase()); } @@ -381,7 +381,7 @@ } // Update the expected result to know about the new output coins assert(tx.vout.size() == 1); - const COutPoint outpoint(tx.GetId(), 0); + const COutPoint outpoint(tx.GetHash(), 0); result[outpoint] = Coin(tx.vout[0], height, CTransaction(tx).IsCoinBase()); diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -31,7 +31,7 @@ for (int i = 0; i < 3; i++) { txChild[i].vin.resize(1); txChild[i].vin[0].scriptSig = CScript() << OP_11; - txChild[i].vin[0].prevout.hash = txParent.GetId(); + txChild[i].vin[0].prevout.hash = txParent.GetHash(); txChild[i].vin[0].prevout.n = i; txChild[i].vout.resize(1); txChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; @@ -41,7 +41,7 @@ for (int i = 0; i < 3; i++) { txGrandChild[i].vin.resize(1); txGrandChild[i].vin[0].scriptSig = CScript() << OP_11; - txGrandChild[i].vin[0].prevout.hash = txChild[i].GetId(); + txGrandChild[i].vin[0].prevout.hash = txChild[i].GetHash(); txGrandChild[i].vin[0].prevout.n = 0; txGrandChild[i].vout.resize(1); txGrandChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; @@ -56,16 +56,16 @@ BOOST_CHECK_EQUAL(testPool.size(), poolSize); // Just the parent: - testPool.addUnchecked(txParent.GetId(), entry.FromTx(txParent)); + testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent)); poolSize = testPool.size(); testPool.removeRecursive(txParent); BOOST_CHECK_EQUAL(testPool.size(), poolSize - 1); // Parent, children, grandchildren: - testPool.addUnchecked(txParent.GetId(), entry.FromTx(txParent)); + testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent)); for (int i = 0; i < 3; i++) { - testPool.addUnchecked(txChild[i].GetId(), entry.FromTx(txChild[i])); - testPool.addUnchecked(txGrandChild[i].GetId(), + testPool.addUnchecked(txChild[i].GetHash(), entry.FromTx(txChild[i])); + testPool.addUnchecked(txGrandChild[i].GetHash(), entry.FromTx(txGrandChild[i])); } // Remove Child[0], GrandChild[0] should be removed: @@ -88,8 +88,8 @@ // Add children and grandchildren, but NOT the parent (simulate the parent // being in a block) for (int i = 0; i < 3; i++) { - testPool.addUnchecked(txChild[i].GetId(), entry.FromTx(txChild[i])); - testPool.addUnchecked(txGrandChild[i].GetId(), + testPool.addUnchecked(txChild[i].GetHash(), entry.FromTx(txChild[i])); + testPool.addUnchecked(txGrandChild[i].GetHash(), entry.FromTx(txGrandChild[i])); } @@ -122,7 +122,7 @@ BOOST_CHECK_EQUAL(testPool.size(), 0); // Add the transaction - testPool.addUnchecked(txParent.GetId(), entry.FromTx(txParent)); + testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent)); BOOST_CHECK_EQUAL(testPool.size(), 1); BOOST_CHECK_EQUAL(testPool.mapTx.size(), 1); BOOST_CHECK_EQUAL(testPool.mapNextTx.size(), 1); @@ -143,7 +143,7 @@ it = pool.mapTx.get().begin(); int count = 0; for (; it != pool.mapTx.get().end(); ++it, ++count) { - BOOST_CHECK_EQUAL(it->GetTx().GetId().ToString(), sortedOrder[count]); + BOOST_CHECK_EQUAL(it->GetTx().GetHash().ToString(), sortedOrder[count]); } } @@ -156,7 +156,7 @@ tx1.vout.resize(1); tx1.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx1.vout[0].nValue = 10 * COIN.GetSatoshis(); - pool.addUnchecked(tx1.GetId(), + pool.addUnchecked(tx1.GetHash(), entry.Fee(10000LL).Priority(10.0).FromTx(tx1)); /* highest fee */ @@ -164,7 +164,7 @@ tx2.vout.resize(1); tx2.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx2.vout[0].nValue = 2 * COIN.GetSatoshis(); - pool.addUnchecked(tx2.GetId(), + pool.addUnchecked(tx2.GetHash(), entry.Fee(20000LL).Priority(9.0).FromTx(tx2)); /* lowest fee */ @@ -172,14 +172,15 @@ tx3.vout.resize(1); tx3.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx3.vout[0].nValue = 5 * COIN.GetSatoshis(); - pool.addUnchecked(tx3.GetId(), entry.Fee(0LL).Priority(100.0).FromTx(tx3)); + pool.addUnchecked(tx3.GetHash(), + entry.Fee(0LL).Priority(100.0).FromTx(tx3)); /* 2nd highest fee */ CMutableTransaction tx4 = CMutableTransaction(); tx4.vout.resize(1); tx4.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx4.vout[0].nValue = 6 * COIN.GetSatoshis(); - pool.addUnchecked(tx4.GetId(), + pool.addUnchecked(tx4.GetHash(), entry.Fee(15000LL).Priority(1.0).FromTx(tx4)); /* equal fee rate to tx1, but newer */ @@ -189,16 +190,16 @@ tx5.vout[0].nValue = 11 * COIN.GetSatoshis(); entry.nTime = 1; entry.dPriority = 10.0; - pool.addUnchecked(tx5.GetId(), entry.Fee(10000LL).FromTx(tx5)); + pool.addUnchecked(tx5.GetHash(), entry.Fee(10000LL).FromTx(tx5)); BOOST_CHECK_EQUAL(pool.size(), 5); std::vector sortedOrder; sortedOrder.resize(5); - sortedOrder[0] = tx3.GetId().ToString(); // 0 - sortedOrder[1] = tx5.GetId().ToString(); // 10000 - sortedOrder[2] = tx1.GetId().ToString(); // 10000 - sortedOrder[3] = tx4.GetId().ToString(); // 15000 - sortedOrder[4] = tx2.GetId().ToString(); // 20000 + sortedOrder[0] = tx3.GetHash().ToString(); // 0 + sortedOrder[1] = tx5.GetHash().ToString(); // 10000 + sortedOrder[2] = tx1.GetHash().ToString(); // 10000 + sortedOrder[3] = tx4.GetHash().ToString(); // 15000 + sortedOrder[4] = tx2.GetHash().ToString(); // 20000 CheckSort(pool, sortedOrder); /* low fee but with high fee child */ @@ -207,17 +208,17 @@ tx6.vout.resize(1); tx6.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx6.vout[0].nValue = 20 * COIN.GetSatoshis(); - pool.addUnchecked(tx6.GetId(), entry.Fee(0LL).FromTx(tx6)); + pool.addUnchecked(tx6.GetHash(), entry.Fee(0LL).FromTx(tx6)); BOOST_CHECK_EQUAL(pool.size(), 6); // Check that at this point, tx6 is sorted low - sortedOrder.insert(sortedOrder.begin(), tx6.GetId().ToString()); + sortedOrder.insert(sortedOrder.begin(), tx6.GetHash().ToString()); CheckSort(pool, sortedOrder); CTxMemPool::setEntries setAncestors; - setAncestors.insert(pool.mapTx.find(tx6.GetId())); + setAncestors.insert(pool.mapTx.find(tx6.GetHash())); CMutableTransaction tx7 = CMutableTransaction(); tx7.vin.resize(1); - tx7.vin[0].prevout = COutPoint(tx6.GetId(), 0); + tx7.vin[0].prevout = COutPoint(tx6.GetHash(), 0); tx7.vin[0].scriptSig = CScript() << OP_11; tx7.vout.resize(2); tx7.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; @@ -234,57 +235,57 @@ true); BOOST_CHECK(setAncestorsCalculated == setAncestors); - pool.addUnchecked(tx7.GetId(), entry.FromTx(tx7), setAncestors); + pool.addUnchecked(tx7.GetHash(), entry.FromTx(tx7), setAncestors); BOOST_CHECK_EQUAL(pool.size(), 7); // Now tx6 should be sorted higher (high fee child): tx7, tx6, tx2, ... sortedOrder.erase(sortedOrder.begin()); - sortedOrder.push_back(tx6.GetId().ToString()); - sortedOrder.push_back(tx7.GetId().ToString()); + sortedOrder.push_back(tx6.GetHash().ToString()); + sortedOrder.push_back(tx7.GetHash().ToString()); CheckSort(pool, sortedOrder); /* low fee child of tx7 */ CMutableTransaction tx8 = CMutableTransaction(); tx8.vin.resize(1); - tx8.vin[0].prevout = COutPoint(tx7.GetId(), 0); + tx8.vin[0].prevout = COutPoint(tx7.GetHash(), 0); tx8.vin[0].scriptSig = CScript() << OP_11; tx8.vout.resize(1); tx8.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx8.vout[0].nValue = 10 * COIN.GetSatoshis(); - setAncestors.insert(pool.mapTx.find(tx7.GetId())); - pool.addUnchecked(tx8.GetId(), entry.Fee(0LL).Time(2).FromTx(tx8), + setAncestors.insert(pool.mapTx.find(tx7.GetHash())); + pool.addUnchecked(tx8.GetHash(), entry.Fee(0LL).Time(2).FromTx(tx8), setAncestors); // Now tx8 should be sorted low, but tx6/tx both high - sortedOrder.insert(sortedOrder.begin(), tx8.GetId().ToString()); + sortedOrder.insert(sortedOrder.begin(), tx8.GetHash().ToString()); CheckSort(pool, sortedOrder); /* low fee child of tx7 */ CMutableTransaction tx9 = CMutableTransaction(); tx9.vin.resize(1); - tx9.vin[0].prevout = COutPoint(tx7.GetId(), 1); + tx9.vin[0].prevout = COutPoint(tx7.GetHash(), 1); tx9.vin[0].scriptSig = CScript() << OP_11; tx9.vout.resize(1); tx9.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx9.vout[0].nValue = 1 * COIN.GetSatoshis(); - pool.addUnchecked(tx9.GetId(), entry.Fee(0LL).Time(3).FromTx(tx9), + pool.addUnchecked(tx9.GetHash(), entry.Fee(0LL).Time(3).FromTx(tx9), setAncestors); // tx9 should be sorted low BOOST_CHECK_EQUAL(pool.size(), 9); - sortedOrder.insert(sortedOrder.begin(), tx9.GetId().ToString()); + sortedOrder.insert(sortedOrder.begin(), tx9.GetHash().ToString()); CheckSort(pool, sortedOrder); std::vector snapshotOrder = sortedOrder; - setAncestors.insert(pool.mapTx.find(tx8.GetId())); - setAncestors.insert(pool.mapTx.find(tx9.GetId())); + setAncestors.insert(pool.mapTx.find(tx8.GetHash())); + setAncestors.insert(pool.mapTx.find(tx9.GetHash())); /* tx10 depends on tx8 and tx9 and has a high fee*/ CMutableTransaction tx10 = CMutableTransaction(); tx10.vin.resize(2); - tx10.vin[0].prevout = COutPoint(tx8.GetId(), 0); + tx10.vin[0].prevout = COutPoint(tx8.GetHash(), 0); tx10.vin[0].scriptSig = CScript() << OP_11; - tx10.vin[1].prevout = COutPoint(tx9.GetId(), 0); + tx10.vin[1].prevout = COutPoint(tx9.GetHash(), 0); tx10.vin[1].scriptSig = CScript() << OP_11; tx10.vout.resize(1); tx10.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; @@ -298,7 +299,7 @@ true); BOOST_CHECK(setAncestorsCalculated == setAncestors); - pool.addUnchecked(tx10.GetId(), entry.FromTx(tx10), setAncestors); + pool.addUnchecked(tx10.GetHash(), entry.FromTx(tx10), setAncestors); /** * tx8 and tx9 should both now be sorted higher @@ -317,21 +318,21 @@ */ // take out tx9, tx8 from the beginning sortedOrder.erase(sortedOrder.begin(), sortedOrder.begin() + 2); - sortedOrder.insert(sortedOrder.begin() + 5, tx9.GetId().ToString()); - sortedOrder.insert(sortedOrder.begin() + 6, tx8.GetId().ToString()); + sortedOrder.insert(sortedOrder.begin() + 5, tx9.GetHash().ToString()); + sortedOrder.insert(sortedOrder.begin() + 6, tx8.GetHash().ToString()); // tx10 is just before tx6 - sortedOrder.insert(sortedOrder.begin() + 7, tx10.GetId().ToString()); + sortedOrder.insert(sortedOrder.begin() + 7, tx10.GetHash().ToString()); CheckSort(pool, sortedOrder); // there should be 10 transactions in the mempool BOOST_CHECK_EQUAL(pool.size(), 10); // Now try removing tx10 and verify the sort order returns to normal - pool.removeRecursive(pool.mapTx.find(tx10.GetId())->GetTx()); + pool.removeRecursive(pool.mapTx.find(tx10.GetHash())->GetTx()); CheckSort(pool, snapshotOrder); - pool.removeRecursive(pool.mapTx.find(tx9.GetId())->GetTx()); - pool.removeRecursive(pool.mapTx.find(tx8.GetId())->GetTx()); + pool.removeRecursive(pool.mapTx.find(tx9.GetHash())->GetTx()); + pool.removeRecursive(pool.mapTx.find(tx8.GetHash())->GetTx()); /* Now check the sort on the mining score index. * Final order should be: * @@ -343,22 +344,22 @@ * (Ties resolved by hash) */ sortedOrder.clear(); - sortedOrder.push_back(tx7.GetId().ToString()); - sortedOrder.push_back(tx2.GetId().ToString()); - sortedOrder.push_back(tx4.GetId().ToString()); - if (tx1.GetId() < tx5.GetId()) { - sortedOrder.push_back(tx5.GetId().ToString()); - sortedOrder.push_back(tx1.GetId().ToString()); + sortedOrder.push_back(tx7.GetHash().ToString()); + sortedOrder.push_back(tx2.GetHash().ToString()); + sortedOrder.push_back(tx4.GetHash().ToString()); + if (tx1.GetHash() < tx5.GetHash()) { + sortedOrder.push_back(tx5.GetHash().ToString()); + sortedOrder.push_back(tx1.GetHash().ToString()); } else { - sortedOrder.push_back(tx1.GetId().ToString()); - sortedOrder.push_back(tx5.GetId().ToString()); + sortedOrder.push_back(tx1.GetHash().ToString()); + sortedOrder.push_back(tx5.GetHash().ToString()); } - if (tx3.GetId() < tx6.GetId()) { - sortedOrder.push_back(tx6.GetId().ToString()); - sortedOrder.push_back(tx3.GetId().ToString()); + if (tx3.GetHash() < tx6.GetHash()) { + sortedOrder.push_back(tx6.GetHash().ToString()); + sortedOrder.push_back(tx3.GetHash().ToString()); } else { - sortedOrder.push_back(tx3.GetId().ToString()); - sortedOrder.push_back(tx6.GetId().ToString()); + sortedOrder.push_back(tx3.GetHash().ToString()); + sortedOrder.push_back(tx6.GetHash().ToString()); } CheckSort(pool, sortedOrder); } @@ -372,7 +373,7 @@ tx1.vout.resize(1); tx1.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx1.vout[0].nValue = 10 * COIN.GetSatoshis(); - pool.addUnchecked(tx1.GetId(), + pool.addUnchecked(tx1.GetHash(), entry.Fee(10000LL).Priority(10.0).FromTx(tx1)); /* highest fee */ @@ -380,7 +381,7 @@ tx2.vout.resize(1); tx2.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx2.vout[0].nValue = 2 * COIN.GetSatoshis(); - pool.addUnchecked(tx2.GetId(), + pool.addUnchecked(tx2.GetHash(), entry.Fee(20000LL).Priority(9.0).FromTx(tx2)); uint64_t tx2Size = GetTransactionSize(tx2); @@ -389,14 +390,15 @@ tx3.vout.resize(1); tx3.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx3.vout[0].nValue = 5 * COIN.GetSatoshis(); - pool.addUnchecked(tx3.GetId(), entry.Fee(0LL).Priority(100.0).FromTx(tx3)); + pool.addUnchecked(tx3.GetHash(), + entry.Fee(0LL).Priority(100.0).FromTx(tx3)); /* 2nd highest fee */ CMutableTransaction tx4 = CMutableTransaction(); tx4.vout.resize(1); tx4.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx4.vout[0].nValue = 6 * COIN.GetSatoshis(); - pool.addUnchecked(tx4.GetId(), + pool.addUnchecked(tx4.GetHash(), entry.Fee(15000LL).Priority(1.0).FromTx(tx4)); /* equal fee rate to tx1, but newer */ @@ -404,24 +406,24 @@ tx5.vout.resize(1); tx5.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; tx5.vout[0].nValue = 11 * COIN.GetSatoshis(); - pool.addUnchecked(tx5.GetId(), entry.Fee(10000LL).FromTx(tx5)); + pool.addUnchecked(tx5.GetHash(), entry.Fee(10000LL).FromTx(tx5)); BOOST_CHECK_EQUAL(pool.size(), 5); std::vector sortedOrder; sortedOrder.resize(5); - sortedOrder[0] = tx2.GetId().ToString(); // 20000 - sortedOrder[1] = tx4.GetId().ToString(); // 15000 + sortedOrder[0] = tx2.GetHash().ToString(); // 20000 + sortedOrder[1] = tx4.GetHash().ToString(); // 15000 // tx1 and tx5 are both 10000 // Ties are broken by hash, not timestamp, so determine which hash comes // first. - if (tx1.GetId() < tx5.GetId()) { - sortedOrder[2] = tx1.GetId().ToString(); - sortedOrder[3] = tx5.GetId().ToString(); + if (tx1.GetHash() < tx5.GetHash()) { + sortedOrder[2] = tx1.GetHash().ToString(); + sortedOrder[3] = tx5.GetHash().ToString(); } else { - sortedOrder[2] = tx5.GetId().ToString(); - sortedOrder[3] = tx1.GetId().ToString(); + sortedOrder[2] = tx5.GetHash().ToString(); + sortedOrder[3] = tx1.GetHash().ToString(); } - sortedOrder[4] = tx3.GetId().ToString(); // 0 + sortedOrder[4] = tx3.GetHash().ToString(); // 0 CheckSort(pool, sortedOrder); @@ -433,20 +435,20 @@ tx6.vout[0].nValue = 20 * COIN.GetSatoshis(); uint64_t tx6Size = GetTransactionSize(tx6); - pool.addUnchecked(tx6.GetId(), entry.Fee(0LL).FromTx(tx6)); + pool.addUnchecked(tx6.GetHash(), entry.Fee(0LL).FromTx(tx6)); BOOST_CHECK_EQUAL(pool.size(), 6); // Ties are broken by hash - if (tx3.GetId() < tx6.GetId()) { - sortedOrder.push_back(tx6.GetId().ToString()); + if (tx3.GetHash() < tx6.GetHash()) { + sortedOrder.push_back(tx6.GetHash().ToString()); } else { - sortedOrder.insert(sortedOrder.end() - 1, tx6.GetId().ToString()); + sortedOrder.insert(sortedOrder.end() - 1, tx6.GetHash().ToString()); } CheckSort(pool, sortedOrder); CMutableTransaction tx7 = CMutableTransaction(); tx7.vin.resize(1); - tx7.vin[0].prevout = COutPoint(tx6.GetId(), 0); + tx7.vin[0].prevout = COutPoint(tx6.GetHash(), 0); tx7.vin[0].scriptSig = CScript() << OP_11; tx7.vout.resize(1); tx7.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; @@ -457,9 +459,9 @@ CAmount fee = (20000 / tx2Size) * (tx7Size + tx6Size) - 1; // CTxMemPoolEntry entry7(tx7, fee, 2, 10.0, 1, true); - pool.addUnchecked(tx7.GetId(), entry.Fee(fee).FromTx(tx7)); + pool.addUnchecked(tx7.GetHash(), entry.Fee(fee).FromTx(tx7)); BOOST_CHECK_EQUAL(pool.size(), 7); - sortedOrder.insert(sortedOrder.begin() + 1, tx7.GetId().ToString()); + sortedOrder.insert(sortedOrder.begin() + 1, tx7.GetHash().ToString()); CheckSort(pool, sortedOrder); /* after tx6 is mined, tx7 should move up in the sort */ @@ -469,11 +471,11 @@ sortedOrder.erase(sortedOrder.begin() + 1); // Ties are broken by hash - if (tx3.GetId() < tx6.GetId()) + if (tx3.GetHash() < tx6.GetHash()) sortedOrder.pop_back(); else sortedOrder.erase(sortedOrder.end() - 2); - sortedOrder.insert(sortedOrder.begin(), tx7.GetId().ToString()); + sortedOrder.insert(sortedOrder.begin(), tx7.GetHash().ToString()); CheckSort(pool, sortedOrder); } @@ -488,7 +490,7 @@ tx1.vout.resize(1); tx1.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL; tx1.vout[0].nValue = 10 * COIN.GetSatoshis(); - pool.addUnchecked(tx1.GetId(), entry.Fee(10000LL).FromTx(tx1, &pool)); + pool.addUnchecked(tx1.GetHash(), entry.Fee(10000LL).FromTx(tx1, &pool)); CMutableTransaction tx2 = CMutableTransaction(); tx2.vin.resize(1); @@ -496,39 +498,39 @@ tx2.vout.resize(1); tx2.vout[0].scriptPubKey = CScript() << OP_2 << OP_EQUAL; tx2.vout[0].nValue = 10 * COIN.GetSatoshis(); - pool.addUnchecked(tx2.GetId(), entry.Fee(5000LL).FromTx(tx2, &pool)); + pool.addUnchecked(tx2.GetHash(), entry.Fee(5000LL).FromTx(tx2, &pool)); // should do nothing pool.TrimToSize(pool.DynamicMemoryUsage()); - BOOST_CHECK(pool.exists(tx1.GetId())); - BOOST_CHECK(pool.exists(tx2.GetId())); + BOOST_CHECK(pool.exists(tx1.GetHash())); + BOOST_CHECK(pool.exists(tx2.GetHash())); // should remove the lower-feerate transaction pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); - BOOST_CHECK(pool.exists(tx1.GetId())); - BOOST_CHECK(!pool.exists(tx2.GetId())); + BOOST_CHECK(pool.exists(tx1.GetHash())); + BOOST_CHECK(!pool.exists(tx2.GetHash())); - pool.addUnchecked(tx2.GetId(), entry.FromTx(tx2, &pool)); + pool.addUnchecked(tx2.GetHash(), entry.FromTx(tx2, &pool)); CMutableTransaction tx3 = CMutableTransaction(); tx3.vin.resize(1); - tx3.vin[0].prevout = COutPoint(tx2.GetId(), 0); + tx3.vin[0].prevout = COutPoint(tx2.GetHash(), 0); tx3.vin[0].scriptSig = CScript() << OP_2; tx3.vout.resize(1); tx3.vout[0].scriptPubKey = CScript() << OP_3 << OP_EQUAL; tx3.vout[0].nValue = 10 * COIN.GetSatoshis(); - pool.addUnchecked(tx3.GetId(), entry.Fee(20000LL).FromTx(tx3, &pool)); + pool.addUnchecked(tx3.GetHash(), entry.Fee(20000LL).FromTx(tx3, &pool)); // tx3 should pay for tx2 (CPFP) pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); - BOOST_CHECK(!pool.exists(tx1.GetId())); - BOOST_CHECK(pool.exists(tx2.GetId())); - BOOST_CHECK(pool.exists(tx3.GetId())); + BOOST_CHECK(!pool.exists(tx1.GetHash())); + BOOST_CHECK(pool.exists(tx2.GetHash())); + BOOST_CHECK(pool.exists(tx3.GetHash())); // mempool is limited to tx1's size in memory usage, so nothing fits pool.TrimToSize(GetTransactionSize(tx1)); - BOOST_CHECK(!pool.exists(tx1.GetId())); - BOOST_CHECK(!pool.exists(tx2.GetId())); - BOOST_CHECK(!pool.exists(tx3.GetId())); + BOOST_CHECK(!pool.exists(tx1.GetHash())); + BOOST_CHECK(!pool.exists(tx2.GetHash())); + BOOST_CHECK(!pool.exists(tx3.GetHash())); CFeeRate maxFeeRateRemoved(25000, GetTransactionSize(tx3) + GetTransactionSize(tx2)); @@ -549,7 +551,7 @@ CMutableTransaction tx5 = CMutableTransaction(); tx5.vin.resize(2); - tx5.vin[0].prevout = COutPoint(tx4.GetId(), 0); + tx5.vin[0].prevout = COutPoint(tx4.GetHash(), 0); tx5.vin[0].scriptSig = CScript() << OP_4; tx5.vin[1].prevout.SetNull(); tx5.vin[1].scriptSig = CScript() << OP_5; @@ -561,7 +563,7 @@ CMutableTransaction tx6 = CMutableTransaction(); tx6.vin.resize(2); - tx6.vin[0].prevout = COutPoint(tx4.GetId(), 1); + tx6.vin[0].prevout = COutPoint(tx4.GetHash(), 1); tx6.vin[0].scriptSig = CScript() << OP_4; tx6.vin[1].prevout.SetNull(); tx6.vin[1].scriptSig = CScript() << OP_6; @@ -573,9 +575,9 @@ CMutableTransaction tx7 = CMutableTransaction(); tx7.vin.resize(2); - tx7.vin[0].prevout = COutPoint(tx5.GetId(), 0); + tx7.vin[0].prevout = COutPoint(tx5.GetHash(), 0); tx7.vin[0].scriptSig = CScript() << OP_5; - tx7.vin[1].prevout = COutPoint(tx6.GetId(), 0); + tx7.vin[1].prevout = COutPoint(tx6.GetHash(), 0); tx7.vin[1].scriptSig = CScript() << OP_6; tx7.vout.resize(2); tx7.vout[0].scriptPubKey = CScript() << OP_7 << OP_EQUAL; @@ -583,31 +585,31 @@ tx7.vout[1].scriptPubKey = CScript() << OP_7 << OP_EQUAL; tx7.vout[1].nValue = 10 * COIN.GetSatoshis(); - pool.addUnchecked(tx4.GetId(), entry.Fee(7000LL).FromTx(tx4, &pool)); - pool.addUnchecked(tx5.GetId(), entry.Fee(1000LL).FromTx(tx5, &pool)); - pool.addUnchecked(tx6.GetId(), entry.Fee(1100LL).FromTx(tx6, &pool)); - pool.addUnchecked(tx7.GetId(), entry.Fee(9000LL).FromTx(tx7, &pool)); + pool.addUnchecked(tx4.GetHash(), entry.Fee(7000LL).FromTx(tx4, &pool)); + pool.addUnchecked(tx5.GetHash(), entry.Fee(1000LL).FromTx(tx5, &pool)); + pool.addUnchecked(tx6.GetHash(), entry.Fee(1100LL).FromTx(tx6, &pool)); + pool.addUnchecked(tx7.GetHash(), entry.Fee(9000LL).FromTx(tx7, &pool)); // we only require this remove, at max, 2 txn, because its not clear what // we're really optimizing for aside from that pool.TrimToSize(pool.DynamicMemoryUsage() - 1); - BOOST_CHECK(pool.exists(tx4.GetId())); - BOOST_CHECK(pool.exists(tx6.GetId())); - BOOST_CHECK(!pool.exists(tx7.GetId())); + BOOST_CHECK(pool.exists(tx4.GetHash())); + BOOST_CHECK(pool.exists(tx6.GetHash())); + BOOST_CHECK(!pool.exists(tx7.GetHash())); - if (!pool.exists(tx5.GetId())) - pool.addUnchecked(tx5.GetId(), entry.Fee(1000LL).FromTx(tx5, &pool)); - pool.addUnchecked(tx7.GetId(), entry.Fee(9000LL).FromTx(tx7, &pool)); + if (!pool.exists(tx5.GetHash())) + pool.addUnchecked(tx5.GetHash(), entry.Fee(1000LL).FromTx(tx5, &pool)); + pool.addUnchecked(tx7.GetHash(), entry.Fee(9000LL).FromTx(tx7, &pool)); // should maximize mempool size by only removing 5/7 pool.TrimToSize(pool.DynamicMemoryUsage() / 2); - BOOST_CHECK(pool.exists(tx4.GetId())); - BOOST_CHECK(!pool.exists(tx5.GetId())); - BOOST_CHECK(pool.exists(tx6.GetId())); - BOOST_CHECK(!pool.exists(tx7.GetId())); + BOOST_CHECK(pool.exists(tx4.GetHash())); + BOOST_CHECK(!pool.exists(tx5.GetHash())); + BOOST_CHECK(pool.exists(tx6.GetHash())); + BOOST_CHECK(!pool.exists(tx7.GetHash())); - pool.addUnchecked(tx5.GetId(), entry.Fee(1000LL).FromTx(tx5, &pool)); - pool.addUnchecked(tx7.GetId(), entry.Fee(9000LL).FromTx(tx7, &pool)); + pool.addUnchecked(tx5.GetHash(), entry.Fee(1000LL).FromTx(tx5, &pool)); + pool.addUnchecked(tx7.GetHash(), entry.Fee(9000LL).FromTx(tx7, &pool)); std::vector vtx; SetMockTime(42); diff --git a/src/test/merkle_tests.cpp b/src/test/merkle_tests.cpp --- a/src/test/merkle_tests.cpp +++ b/src/test/merkle_tests.cpp @@ -18,7 +18,7 @@ vMerkleTree.reserve(block.vtx.size() * 2 + 16); for (std::vector::const_iterator it(block.vtx.begin()); it != block.vtx.end(); ++it) - vMerkleTree.push_back((*it)->GetId()); + vMerkleTree.push_back((*it)->GetHash()); int j = 0; bool mutated = false; for (int nSize = block.vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { @@ -145,7 +145,7 @@ BlockGetMerkleBranch(block, merkleTree, mtx); BOOST_CHECK(oldBranch == newBranch); BOOST_CHECK( - ComputeMerkleRootFromBranch(block.vtx[mtx]->GetId(), + ComputeMerkleRootFromBranch(block.vtx[mtx]->GetHash(), newBranch, mtx) == oldRoot); } } diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -94,21 +94,21 @@ CMutableTransaction tx; tx.vin.resize(1); tx.vin[0].scriptSig = CScript() << OP_1; - tx.vin[0].prevout.hash = txFirst[0]->GetId(); + tx.vin[0].prevout.hash = txFirst[0]->GetHash(); tx.vin[0].prevout.n = 0; tx.vout.resize(1); tx.vout[0].nValue = 5000000000LL - 1000; // This tx has a low fee: 1000 satoshis. // Save this txid for later use. - uint256 hashParentTx = tx.GetId(); + uint256 hashParentTx = tx.GetHash(); mempool.addUnchecked( hashParentTx, entry.Fee(1000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); // This tx has a medium fee: 10000 satoshis. - tx.vin[0].prevout.hash = txFirst[1]->GetId(); + tx.vin[0].prevout.hash = txFirst[1]->GetHash(); tx.vout[0].nValue = 5000000000LL - 10000; - uint256 hashMediumFeeTx = tx.GetId(); + uint256 hashMediumFeeTx = tx.GetHash(); mempool.addUnchecked( hashMediumFeeTx, entry.Fee(10000).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); @@ -117,22 +117,22 @@ tx.vin[0].prevout.hash = hashParentTx; // 50k satoshi fee. tx.vout[0].nValue = 5000000000LL - 1000 - 50000; - uint256 hashHighFeeTx = tx.GetId(); + uint256 hashHighFeeTx = tx.GetHash(); mempool.addUnchecked( hashHighFeeTx, entry.Fee(50000).Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); std::unique_ptr pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey); - BOOST_CHECK(pblocktemplate->block.vtx[1]->GetId() == hashParentTx); - BOOST_CHECK(pblocktemplate->block.vtx[2]->GetId() == hashHighFeeTx); - BOOST_CHECK(pblocktemplate->block.vtx[3]->GetId() == hashMediumFeeTx); + BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashParentTx); + BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashHighFeeTx); + BOOST_CHECK(pblocktemplate->block.vtx[3]->GetHash() == hashMediumFeeTx); // Test that a package below the block min tx fee doesn't get included tx.vin[0].prevout.hash = hashHighFeeTx; // 0 fee. tx.vout[0].nValue = 5000000000LL - 1000 - 50000; - uint256 hashFreeTx = tx.GetId(); + uint256 hashFreeTx = tx.GetHash(); mempool.addUnchecked(hashFreeTx, entry.Fee(0).FromTx(tx)); size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); @@ -142,14 +142,14 @@ tx.vin[0].prevout.hash = hashFreeTx; tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse; - uint256 hashLowFeeTx = tx.GetId(); + uint256 hashLowFeeTx = tx.GetHash(); mempool.addUnchecked(hashLowFeeTx, entry.Fee(feeToUse).FromTx(tx)); pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey); // Verify that the free tx and the low fee tx didn't get selected. for (size_t i = 0; i < pblocktemplate->block.vtx.size(); ++i) { - BOOST_CHECK(pblocktemplate->block.vtx[i]->GetId() != hashFreeTx); - BOOST_CHECK(pblocktemplate->block.vtx[i]->GetId() != hashLowFeeTx); + BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx); + BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx); } // Test that packages above the min relay fee do get included, even if one @@ -158,22 +158,22 @@ mempool.removeRecursive(tx); // Now we should be just over the min relay fee. tx.vout[0].nValue -= 2; - hashLowFeeTx = tx.GetId(); + hashLowFeeTx = tx.GetHash(); mempool.addUnchecked(hashLowFeeTx, entry.Fee(feeToUse + 2).FromTx(tx)); pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey); - BOOST_CHECK(pblocktemplate->block.vtx[4]->GetId() == hashFreeTx); - BOOST_CHECK(pblocktemplate->block.vtx[5]->GetId() == hashLowFeeTx); + BOOST_CHECK(pblocktemplate->block.vtx[4]->GetHash() == hashFreeTx); + BOOST_CHECK(pblocktemplate->block.vtx[5]->GetHash() == hashLowFeeTx); // Test that transaction selection properly updates ancestor fee // calculations as ancestor transactions get included in a block. Add a // 0-fee transaction that has 2 outputs. - tx.vin[0].prevout.hash = txFirst[2]->GetId(); + tx.vin[0].prevout.hash = txFirst[2]->GetHash(); tx.vout.resize(2); tx.vout[0].nValue = 5000000000LL - 100000000; // 1BCC output. tx.vout[1].nValue = 100000000; - uint256 hashFreeTx2 = tx.GetId(); + uint256 hashFreeTx2 = tx.GetHash(); mempool.addUnchecked(hashFreeTx2, entry.Fee(0).SpendsCoinbase(true).FromTx(tx)); @@ -182,7 +182,7 @@ tx.vout.resize(1); feeToUse = blockMinFeeRate.GetFee(freeTxSize).GetSatoshis(); tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse; - uint256 hashLowFeeTx2 = tx.GetId(); + uint256 hashLowFeeTx2 = tx.GetHash(); mempool.addUnchecked(hashLowFeeTx2, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx)); pblocktemplate = @@ -190,8 +190,8 @@ // Verify that this tx isn't selected. for (size_t i = 0; i < pblocktemplate->block.vtx.size(); ++i) { - BOOST_CHECK(pblocktemplate->block.vtx[i]->GetId() != hashFreeTx2); - BOOST_CHECK(pblocktemplate->block.vtx[i]->GetId() != hashLowFeeTx2); + BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx2); + BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx2); } // This tx will be mineable, and should cause hashLowFeeTx2 to be selected @@ -199,10 +199,10 @@ tx.vin[0].prevout.n = 1; // 10k satoshi fee. tx.vout[0].nValue = 100000000 - 10000; - mempool.addUnchecked(tx.GetId(), entry.Fee(10000).FromTx(tx)); + mempool.addUnchecked(tx.GetHash(), entry.Fee(10000).FromTx(tx)); pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey); - BOOST_CHECK(pblocktemplate->block.vtx[8]->GetId() == hashLowFeeTx2); + BOOST_CHECK(pblocktemplate->block.vtx[8]->GetHash() == hashLowFeeTx2); } void TestCoinbaseMessageEB(uint64_t eb, std::string cbmsg) { @@ -313,13 +313,13 @@ // NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP << OP_CHECKMULTISIG << OP_1; - tx.vin[0].prevout.hash = txFirst[0]->GetId(); + tx.vin[0].prevout.hash = txFirst[0]->GetHash(); tx.vin[0].prevout.n = 0; tx.vout.resize(1); tx.vout[0].nValue = BLOCKSUBSIDY; for (unsigned int i = 0; i < 1001; ++i) { tx.vout[0].nValue -= LOWFEE; - hash = tx.GetId(); + hash = tx.GetHash(); // Only first tx spends coinbase. bool spendsCoinbase = (i == 0) ? true : false; // If we don't set the # of sig ops in the CTxMemPoolEntry, template @@ -335,11 +335,11 @@ std::runtime_error); mempool.clear(); - tx.vin[0].prevout.hash = txFirst[0]->GetId(); + tx.vin[0].prevout.hash = txFirst[0]->GetHash(); tx.vout[0].nValue = BLOCKSUBSIDY; for (unsigned int i = 0; i < 1001; ++i) { tx.vout[0].nValue -= LOWFEE; - hash = tx.GetId(); + hash = tx.GetHash(); // Only first tx spends coinbase. bool spendsCoinbase = (i == 0) ? true : false; // If we do set the # of sig ops in the CTxMemPoolEntry, template @@ -363,11 +363,11 @@ for (unsigned int i = 0; i < 18; ++i) tx.vin[0].scriptSig << vchData << OP_DROP; tx.vin[0].scriptSig << OP_1; - tx.vin[0].prevout.hash = txFirst[0]->GetId(); + tx.vin[0].prevout.hash = txFirst[0]->GetHash(); tx.vout[0].nValue = BLOCKSUBSIDY; for (unsigned int i = 0; i < 128; ++i) { tx.vout[0].nValue -= LOWFEE; - hash = tx.GetId(); + hash = tx.GetHash(); // Only first tx spends coinbase. bool spendsCoinbase = (i == 0) ? true : false; mempool.addUnchecked(hash, entry.Fee(LOWFEE) @@ -382,7 +382,7 @@ mempool.clear(); // Orphan in mempool, template creation fails. - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).FromTx(tx)); BOOST_CHECK_THROW( BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey), @@ -391,20 +391,20 @@ // Child with higher priority than parent. tx.vin[0].scriptSig = CScript() << OP_1; - tx.vin[0].prevout.hash = txFirst[1]->GetId(); + tx.vin[0].prevout.hash = txFirst[1]->GetHash(); tx.vout[0].nValue = BLOCKSUBSIDY - HIGHFEE; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked( hash, entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); tx.vin[0].prevout.hash = hash; tx.vin.resize(2); tx.vin[1].scriptSig = CScript() << OP_1; - tx.vin[1].prevout.hash = txFirst[0]->GetId(); + tx.vin[1].prevout.hash = txFirst[0]->GetHash(); tx.vin[1].prevout.n = 0; // First txn output + fresh coinbase - new txn fee. tx.vout[0].nValue = tx.vout[0].nValue + BLOCKSUBSIDY - HIGHERFEE; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked( hash, entry.Fee(HIGHERFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); @@ -418,7 +418,7 @@ tx.vin[0].prevout.SetNull(); tx.vin[0].scriptSig = CScript() << OP_0 << OP_1; tx.vout[0].nValue = 0; - hash = tx.GetId(); + hash = tx.GetHash(); // Give it a fee so it'll get mined. mempool.addUnchecked( hash, @@ -429,13 +429,13 @@ mempool.clear(); // Invalid (pre-p2sh) txn in mempool, template creation fails. - tx.vin[0].prevout.hash = txFirst[0]->GetId(); + tx.vin[0].prevout.hash = txFirst[0]->GetHash(); tx.vin[0].prevout.n = 0; tx.vin[0].scriptSig = CScript() << OP_1; tx.vout[0].nValue = BLOCKSUBSIDY - LOWFEE; script = CScript() << OP_0; tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script)); - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked( hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); @@ -443,7 +443,7 @@ tx.vin[0].scriptSig = CScript() << std::vector(script.begin(), script.end()); tx.vout[0].nValue -= LOWFEE; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked( hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx)); @@ -453,16 +453,16 @@ mempool.clear(); // Double spend txn pair in mempool, template creation fails. - tx.vin[0].prevout.hash = txFirst[0]->GetId(); + tx.vin[0].prevout.hash = txFirst[0]->GetHash(); tx.vin[0].scriptSig = CScript() << OP_1; tx.vout[0].nValue = BLOCKSUBSIDY - HIGHFEE; tx.vout[0].scriptPubKey = CScript() << OP_1; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked( hash, entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); tx.vout[0].scriptPubKey = CScript() << OP_2; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked( hash, entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); @@ -521,7 +521,7 @@ tx.vin.resize(1); prevheights.resize(1); // Only 1 transaction. - tx.vin[0].prevout.hash = txFirst[0]->GetId(); + tx.vin[0].prevout.hash = txFirst[0]->GetHash(); tx.vin[0].prevout.n = 0; tx.vin[0].scriptSig = CScript() << OP_1; // txFirst[0] is the 2nd block @@ -531,7 +531,7 @@ tx.vout[0].nValue = BLOCKSUBSIDY - HIGHFEE; tx.vout[0].scriptPubKey = CScript() << OP_1; tx.nLockTime = 0; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked( hash, entry.Fee(HIGHFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx)); @@ -552,7 +552,7 @@ CreateBlockIndex(chainActive.Tip()->nHeight + 2))); // Relative time locked. - tx.vin[0].prevout.hash = txFirst[1]->GetId(); + tx.vin[0].prevout.hash = txFirst[1]->GetHash(); // txFirst[1] is the 3rd block. tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | (((chainActive.Tip()->GetMedianTimePast() + 1 - @@ -560,7 +560,7 @@ CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) + 1); prevheights[0] = baseheight + 2; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); { @@ -590,11 +590,11 @@ } // Absolute height locked. - tx.vin[0].prevout.hash = txFirst[2]->GetId(); + tx.vin[0].prevout.hash = txFirst[2]->GetHash(); tx.vin[0].nSequence = CTxIn::SEQUENCE_FINAL - 1; prevheights[0] = baseheight + 3; tx.nLockTime = chainActive.Tip()->nHeight + 1; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); { @@ -620,11 +620,11 @@ } // Absolute time locked. - tx.vin[0].prevout.hash = txFirst[3]->GetId(); + tx.vin[0].prevout.hash = txFirst[3]->GetHash(); tx.nLockTime = chainActive.Tip()->GetMedianTimePast(); prevheights.resize(1); prevheights[0] = baseheight + 4; - hash = tx.GetId(); + hash = tx.GetHash(); mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx)); { diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -71,7 +71,7 @@ txTo[i].vin.resize(1); txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetId(); + txTo[i].vin[0].prevout.hash = txFrom.GetHash(); txTo[i].vout[0].nValue = 1; } @@ -345,7 +345,7 @@ txTo[i].vin.resize(1); txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetId(); + txTo[i].vin[0].prevout.hash = txFrom.GetHash(); txTo[i].vout[0].nValue = 1; } diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -50,7 +50,7 @@ uint256 merkleRoot1 = BlockMerkleRoot(block); std::vector vTxid(nTx, uint256()); for (unsigned int j = 0; j < nTx; j++) - vTxid[j] = block.vtx[j]->GetId(); + vTxid[j] = block.vtx[j]->GetHash(); int nHeight = 1, nTx_ = nTx; while (nTx_ > 1) { nTx_ = (nTx_ + 1) / 2; diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp --- a/src/test/policyestimator_tests.cpp +++ b/src/test/policyestimator_tests.cpp @@ -56,7 +56,7 @@ for (int k = 0; k < 4; k++) { // make transaction unique tx.vin[0].prevout.n = 10000 * blocknum + 100 * j + k; - uint256 hash = tx.GetId(); + uint256 hash = tx.GetHash(); mpool.addUnchecked(hash, entry.Fee(feeV[j]) .Time(GetTime()) .Priority(0) @@ -152,7 +152,7 @@ // add 4 fee txs for (int k = 0; k < 4; k++) { tx.vin[0].prevout.n = 10000 * blocknum + 100 * j + k; - uint256 txid = tx.GetId(); + uint256 txid = tx.GetHash(); mpool.addUnchecked(txid, entry.Fee(feeV[j]) .Time(GetTime()) .Priority(0) @@ -199,7 +199,7 @@ // add 4 fee txs for (int k = 0; k < 4; k++) { tx.vin[0].prevout.n = 10000 * blocknum + 100 * j + k; - uint256 txid = tx.GetId(); + uint256 txid = tx.GetHash(); mpool.addUnchecked(txid, entry.Fee(feeV[j]) .Time(GetTime()) .Priority(0) @@ -222,7 +222,7 @@ // value below the mempool min fee and that estimateSmartPriority returns // essentially an infinite value mpool.addUnchecked( - tx.GetId(), + tx.GetHash(), entry.Fee(feeV[5]).Time(GetTime()).Priority(0).Height(blocknum).FromTx( tx, &mpool)); // evict that transaction which should set a mempool min fee of diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp --- a/src/test/script_P2SH_tests.cpp +++ b/src/test/script_P2SH_tests.cpp @@ -34,7 +34,7 @@ txTo.vin.resize(1); txTo.vout.resize(1); txTo.vin[0].prevout.n = 0; - txTo.vin[0].prevout.hash = txFrom.GetId(); + txTo.vin[0].prevout.hash = txFrom.GetHash(); txTo.vin[0].scriptSig = scriptSig; txTo.vout[0].nValue = 1; @@ -92,7 +92,7 @@ txTo[i].vin.resize(1); txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetId(); + txTo[i].vin[0].prevout.hash = txFrom.GetHash(); txTo[i].vout[0].nValue = 1; BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), strprintf("IsMine %d", i)); @@ -197,7 +197,7 @@ txTo[i].vin.resize(1); txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetId(); + txTo[i].vin[0].prevout.hash = txFrom.GetHash(); txTo[i].vout[0].nValue = 1 * CENT.GetSatoshis(); txTo[i].vout[0].scriptPubKey = inner[i]; BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), @@ -388,7 +388,7 @@ txTo.vin.resize(5); for (int i = 0; i < 5; i++) { txTo.vin[i].prevout.n = i; - txTo.vin[i].prevout.hash = txFrom.GetId(); + txTo.vin[i].prevout.hash = txFrom.GetHash(); } BOOST_CHECK( SignSignature(keystore, txFrom, txTo, 0, SIGHASH_ALL | SIGHASH_FORKID)); @@ -416,7 +416,7 @@ txToNonStd1.vout[0].nValue = 1000; txToNonStd1.vin.resize(1); txToNonStd1.vin[0].prevout.n = 5; - txToNonStd1.vin[0].prevout.hash = txFrom.GetId(); + txToNonStd1.vin[0].prevout.hash = txFrom.GetHash(); txToNonStd1.vin[0].scriptSig << std::vector(sixteenSigops.begin(), sixteenSigops.end()); @@ -430,7 +430,7 @@ txToNonStd2.vout[0].nValue = 1000; txToNonStd2.vin.resize(1); txToNonStd2.vin[0].prevout.n = 6; - txToNonStd2.vin[0].prevout.hash = txFrom.GetId(); + txToNonStd2.vin[0].prevout.hash = txFrom.GetHash(); txToNonStd2.vin[0].scriptSig << std::vector(twentySigops.begin(), twentySigops.end()); diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -140,7 +140,7 @@ txSpend.nLockTime = 0; txSpend.vin.resize(1); txSpend.vout.resize(1); - txSpend.vin[0].prevout.hash = txCredit.GetId(); + txSpend.vin[0].prevout.hash = txCredit.GetHash(); txSpend.vin[0].prevout.n = 0; txSpend.vin[0].scriptSig = scriptSig; txSpend.vin[0].nSequence = CTxIn::SEQUENCE_FINAL; diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp --- a/src/test/sigopcount_tests.cpp +++ b/src/test/sigopcount_tests.cpp @@ -97,7 +97,7 @@ spendingTx.nVersion = 1; spendingTx.vin.resize(1); - spendingTx.vin[0].prevout.hash = creationTx.GetId(); + spendingTx.vin[0].prevout.hash = creationTx.GetHash(); spendingTx.vin[0].prevout.n = 0; spendingTx.vin[0].scriptSig = scriptSig; spendingTx.vout.resize(1); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -299,14 +299,14 @@ CMutableTransaction t1; t1.vin.resize(3); - t1.vin[0].prevout.hash = dummyTransactions[0].GetId(); + t1.vin[0].prevout.hash = dummyTransactions[0].GetHash(); t1.vin[0].prevout.n = 1; t1.vin[0].scriptSig << std::vector(65, 0); - t1.vin[1].prevout.hash = dummyTransactions[1].GetId(); + t1.vin[1].prevout.hash = dummyTransactions[1].GetHash(); t1.vin[1].prevout.n = 0; t1.vin[1].scriptSig << std::vector(65, 0) << std::vector(33, 4); - t1.vin[2].prevout.hash = dummyTransactions[1].GetId(); + t1.vin[2].prevout.hash = dummyTransactions[1].GetHash(); t1.vin[2].prevout.n = 1; t1.vin[2].scriptSig << std::vector(65, 0) << std::vector(33, 4); @@ -341,7 +341,7 @@ CMutableTransaction inputm; inputm.nVersion = 1; inputm.vin.resize(1); - inputm.vin[0].prevout.hash = output->GetId(); + inputm.vin[0].prevout.hash = output->GetHash(); inputm.vin[0].prevout.n = 0; inputm.vout.resize(1); inputm.vout[0].nValue = 1; @@ -529,7 +529,7 @@ CMutableTransaction t; t.vin.resize(1); - t.vin[0].prevout.hash = dummyTransactions[0].GetId(); + t.vin[0].prevout.hash = dummyTransactions[0].GetHash(); t.vin[0].prevout.n = 1; t.vin[0].scriptSig << std::vector(65, 0); t.vout.resize(1); diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp --- a/src/test/txvalidationcache_tests.cpp +++ b/src/test/txvalidationcache_tests.cpp @@ -44,7 +44,7 @@ for (int i = 0; i < 2; i++) { spends[i].nVersion = 1; spends[i].vin.resize(1); - spends[i].vin[0].prevout.hash = coinbaseTxns[0].GetId(); + spends[i].vin[0].prevout.hash = coinbaseTxns[0].GetHash(); spends[i].vin[0].prevout.n = 0; spends[i].vout.resize(1); spends[i].vout[0].nValue = 11 * CENT.GetSatoshis(); @@ -171,7 +171,7 @@ spend_tx.nVersion = 1; spend_tx.vin.resize(1); - spend_tx.vin[0].prevout.hash = coinbaseTxns[0].GetId(); + spend_tx.vin[0].prevout.hash = coinbaseTxns[0].GetHash(); spend_tx.vin[0].prevout.n = 0; spend_tx.vout.resize(4); spend_tx.vout[0].nValue = 11 * CENT.GetSatoshis(); @@ -244,7 +244,7 @@ CMutableTransaction invalid_under_p2sh_tx; invalid_under_p2sh_tx.nVersion = 1; invalid_under_p2sh_tx.vin.resize(1); - invalid_under_p2sh_tx.vin[0].prevout.hash = spend_tx.GetId(); + invalid_under_p2sh_tx.vin[0].prevout.hash = spend_tx.GetHash(); invalid_under_p2sh_tx.vin[0].prevout.n = 0; invalid_under_p2sh_tx.vout.resize(1); invalid_under_p2sh_tx.vout[0].nValue = 11 * CENT.GetSatoshis(); @@ -263,7 +263,7 @@ invalid_with_cltv_tx.nVersion = 1; invalid_with_cltv_tx.nLockTime = 100; invalid_with_cltv_tx.vin.resize(1); - invalid_with_cltv_tx.vin[0].prevout.hash = spend_tx.GetId(); + invalid_with_cltv_tx.vin[0].prevout.hash = spend_tx.GetHash(); invalid_with_cltv_tx.vin[0].prevout.n = 1; invalid_with_cltv_tx.vin[0].nSequence = 0; invalid_with_cltv_tx.vout.resize(1); @@ -298,7 +298,7 @@ CMutableTransaction invalid_with_csv_tx; invalid_with_csv_tx.nVersion = 2; invalid_with_csv_tx.vin.resize(1); - invalid_with_csv_tx.vin[0].prevout.hash = spend_tx.GetId(); + invalid_with_csv_tx.vin[0].prevout.hash = spend_tx.GetHash(); invalid_with_csv_tx.vin[0].prevout.n = 2; invalid_with_csv_tx.vin[0].nSequence = 100; invalid_with_csv_tx.vout.resize(1); @@ -335,9 +335,9 @@ tx.nVersion = 1; tx.vin.resize(2); - tx.vin[0].prevout.hash = spend_tx.GetId(); + tx.vin[0].prevout.hash = spend_tx.GetHash(); tx.vin[0].prevout.n = 0; - tx.vin[1].prevout.hash = spend_tx.GetId(); + tx.vin[1].prevout.hash = spend_tx.GetHash(); tx.vin[1].prevout.n = 3; tx.vout.resize(1); tx.vout[0].nValue = 22 * CENT.GetSatoshis(); diff --git a/src/test/undo_tests.cpp b/src/test/undo_tests.cpp --- a/src/test/undo_tests.cpp +++ b/src/test/undo_tests.cpp @@ -76,7 +76,7 @@ auto prevTx0 = CTransaction(tx); AddCoins(view, prevTx0, 100); - tx.vin[0].prevout.hash = prevTx0.GetId(); + tx.vin[0].prevout.hash = prevTx0.GetHash(); auto tx0 = CTransaction(tx); block.vtx[1] = MakeTransactionRef(tx0); @@ -85,16 +85,16 @@ UpdateUTXOSet(block, view, blockundo, chainparams, 123456); BOOST_CHECK(view.GetBestBlock() == block.GetHash()); - BOOST_CHECK(HasSpendableCoin(view, coinbaseTx.GetId())); - BOOST_CHECK(HasSpendableCoin(view, tx0.GetId())); - BOOST_CHECK(!HasSpendableCoin(view, prevTx0.GetId())); + BOOST_CHECK(HasSpendableCoin(view, coinbaseTx.GetHash())); + BOOST_CHECK(HasSpendableCoin(view, tx0.GetHash())); + BOOST_CHECK(!HasSpendableCoin(view, prevTx0.GetHash())); UndoBlock(block, view, blockundo, chainparams, 123456); BOOST_CHECK(view.GetBestBlock() == block.hashPrevBlock); - BOOST_CHECK(!HasSpendableCoin(view, coinbaseTx.GetId())); - BOOST_CHECK(!HasSpendableCoin(view, tx0.GetId())); - BOOST_CHECK(HasSpendableCoin(view, prevTx0.GetId())); + BOOST_CHECK(!HasSpendableCoin(view, coinbaseTx.GetHash())); + BOOST_CHECK(!HasSpendableCoin(view, tx0.GetHash())); + BOOST_CHECK(HasSpendableCoin(view, prevTx0.GetHash())); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -235,7 +235,7 @@ struct mempoolentry_txid { typedef uint256 result_type; result_type operator()(const CTxMemPoolEntry &entry) const { - return entry.GetTx().GetId(); + return entry.GetTx().GetHash(); } }; @@ -292,7 +292,7 @@ double f1 = double(b.GetTxSize() * a.GetModifiedFee().GetSatoshis()); double f2 = double(a.GetTxSize() * b.GetModifiedFee().GetSatoshis()); if (f1 == f2) { - return b.GetTx().GetId() < a.GetTx().GetId(); + return b.GetTx().GetHash() < a.GetTx().GetHash(); } return f1 > f2; } @@ -319,7 +319,7 @@ double f2 = aSize * bFees; if (f1 == f2) { - return a.GetTx().GetId() < b.GetTx().GetId(); + return a.GetTx().GetHash() < b.GetTx().GetHash(); } return f1 > f2; @@ -525,7 +525,7 @@ struct CompareIteratorByHash { bool operator()(const txiter &a, const txiter &b) const { - return a->GetTx().GetId() < b->GetTx().GetId(); + return a->GetTx().GetHash() < b->GetTx().GetHash(); } }; typedef std::set setEntries; diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -108,7 +108,7 @@ Amount modifyFee = 0; int64_t modifyCount = 0; for (txiter cit : setAllDescendants) { - if (!setExclude.count(cit->GetTx().GetId())) { + if (!setExclude.count(cit->GetTx().GetHash())) { modifySize += cit->GetTxSize(); modifyFee += cit->GetModifiedFee(); modifyCount++; @@ -159,7 +159,7 @@ // First calculate the children, and update setMemPoolChildren to // include them, and update their setMemPoolParents to include this tx. for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) { - const uint256 &childHash = iter->second->GetId(); + const uint256 &childHash = iter->second->GetHash(); txiter childIter = mapTx.find(childHash); assert(childIter != mapTx.end()); // We can skip updating entries we've encountered before or that are @@ -221,12 +221,12 @@ limitDescendantSize) { errString = strprintf( "exceeds descendant size limit for tx %s [limit: %u]", - stageit->GetTx().GetId().ToString(), limitDescendantSize); + stageit->GetTx().GetHash().ToString(), limitDescendantSize); return false; } else if (stageit->GetCountWithDescendants() + 1 > limitDescendantCount) { errString = strprintf("too many descendants for tx %s [limit: %u]", - stageit->GetTx().GetId().ToString(), + stageit->GetTx().GetHash().ToString(), limitDescendantCount); return false; } else if (totalSizeWithAncestors > limitAncestorSize) { @@ -467,7 +467,7 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason) { NotifyEntryRemoved(it->GetSharedTx(), reason); - const uint256 txid = it->GetTx().GetId(); + const uint256 txid = it->GetTx().GetHash(); for (const CTxIn &txin : it->GetTx().vin) { mapNextTx.erase(txin.prevout); } @@ -526,7 +526,7 @@ { LOCK(cs); setEntries txToRemove; - txiter origit = mapTx.find(origTx.GetId()); + txiter origit = mapTx.find(origTx.GetHash()); if (origit != mapTx.end()) { txToRemove.insert(origit); } else { @@ -535,9 +535,9 @@ // during chain re-orgs if origTx isn't re-accepted into the mempool // for any reason. for (unsigned int i = 0; i < origTx.vout.size(); i++) { - auto it = mapNextTx.find(COutPoint(origTx.GetId(), i)); + auto it = mapNextTx.find(COutPoint(origTx.GetHash(), i)); if (it == mapNextTx.end()) continue; - txiter nextit = mapTx.find(it->second->GetId()); + txiter nextit = mapTx.find(it->second->GetHash()); assert(nextit != mapTx.end()); txToRemove.insert(nextit); } @@ -611,7 +611,7 @@ if (it != mapNextTx.end()) { const CTransaction &txConflict = *it->second; if (txConflict != tx) { - ClearPrioritisation(txConflict.GetId()); + ClearPrioritisation(txConflict.GetHash()); removeRecursive(txConflict, MemPoolRemovalReason::CONFLICT); } } @@ -627,7 +627,7 @@ LOCK(cs); std::vector entries; for (const auto &tx : vtx) { - uint256 txid = tx->GetId(); + uint256 txid = tx->GetHash(); indexed_transaction_set::iterator i = mapTx.find(txid); if (i != mapTx.end()) entries.push_back(&*i); @@ -636,14 +636,14 @@ // update policy estimates minerPolicyEstimator->processBlock(nBlockHeight, entries); for (const auto &tx : vtx) { - txiter it = mapTx.find(tx->GetId()); + txiter it = mapTx.find(tx->GetHash()); if (it != mapTx.end()) { setEntries stage; stage.insert(it); RemoveStaged(stage, true, MemPoolRemovalReason::BLOCK); } removeConflicts(*tx); - ClearPrioritisation(tx->GetId()); + ClearPrioritisation(tx->GetHash()); } lastRollingFeeUpdate = GetTime(); blockSinceLastRollingFeeBump = true; @@ -748,12 +748,12 @@ // Check children against mapNextTx CTxMemPool::setEntries setChildrenCheck; - auto iter = mapNextTx.lower_bound(COutPoint(it->GetTx().GetId(), 0)); + auto iter = mapNextTx.lower_bound(COutPoint(it->GetTx().GetHash(), 0)); int64_t childSizes = 0; for (; iter != mapNextTx.end() && - iter->first->hash == it->GetTx().GetId(); + iter->first->hash == it->GetTx().GetHash(); ++iter) { - txiter childit = mapTx.find(iter->second->GetId()); + txiter childit = mapTx.find(iter->second->GetHash()); assert(childit != mapTx.end()); // mapNextTx points to in-mempool transactions if (setChildrenCheck.insert(childit).second) { @@ -797,7 +797,7 @@ } } for (auto it = mapNextTx.cbegin(); it != mapNextTx.cend(); it++) { - uint256 txid = it->second->GetId(); + uint256 txid = it->second->GetHash(); indexed_transaction_set::const_iterator it2 = mapTx.find(txid); const CTransaction &tx = it2->GetTx(); assert(it2 != mapTx.end()); @@ -862,7 +862,7 @@ vtxid.reserve(mapTx.size()); for (auto it : iters) { - vtxid.push_back(it->GetTx().GetId()); + vtxid.push_back(it->GetTx().GetHash()); } } diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -682,7 +682,7 @@ AssertLockHeld(cs_main); const CTransaction &tx = *ptx; - const uint256 txid = tx.GetId(); + const uint256 txid = tx.GetHash(); if (pfMissingInputs) { *pfMissingInputs = false; } @@ -1071,7 +1071,7 @@ e.what()); } hashBlock = header.GetHash(); - if (txOut->GetId() != txid) + if (txOut->GetHash() != txid) return error("%s: txid mismatch", __func__); return true; } @@ -1091,7 +1091,7 @@ CBlock block; if (ReadBlockFromDisk(block, pindexSlow, params)) { for (const auto &tx : block.vtx) { - if (tx->GetId() == txid) { + if (tx->GetHash() == txid) { txOut = tx; hashBlock = pindexSlow->GetBlockHash(); return true; @@ -1664,7 +1664,7 @@ size_t i = block.vtx.size(); while (i-- > 0) { const CTransaction &tx = *(block.vtx[i]); - uint256 txid = tx.GetId(); + uint256 txid = tx.GetHash(); // Check that all outputs are available and match the outputs in the // block itself exactly. @@ -2077,7 +2077,8 @@ fCacheResults, fCacheResults, PrecomputedTransactionData(tx), &vChecks)) { return error("ConnectBlock(): CheckInputs on %s failed with %s", - tx.GetId().ToString(), FormatStateMessage(state)); + tx.GetHash().ToString(), + FormatStateMessage(state)); } control.Add(vChecks); @@ -2090,7 +2091,7 @@ UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight); - vPos.push_back(std::make_pair(tx.GetId(), pos)); + vPos.push_back(std::make_pair(tx.GetHash(), pos)); pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); } @@ -2168,7 +2169,7 @@ // Watch for changes to the previous coinbase transaction. static uint256 hashPrevBestCoinBase; GetMainSignals().UpdatedTransaction(hashPrevBestCoinBase); - hashPrevBestCoinBase = block.vtx[0]->GetId(); + hashPrevBestCoinBase = block.vtx[0]->GetHash(); int64_t nTime6 = GetTimeMicros(); nTimeCallbacks += nTime6 - nTime5; @@ -2467,8 +2468,8 @@ !AcceptToMemoryPool(config, mempool, stateDummy, it, false, nullptr, nullptr, true)) { mempool.removeRecursive(tx, MemPoolRemovalReason::REORG); - } else if (mempool.exists(tx.GetId())) { - vHashUpdate.push_back(tx.GetId()); + } else if (mempool.exists(tx.GetHash())) { + vHashUpdate.push_back(tx.GetHash()); } } // AcceptToMemoryPool/addUnchecked all assume that new mempool entries @@ -3264,7 +3265,7 @@ return state.Invalid(false, state.GetRejectCode(), state.GetRejectReason(), strprintf("Coinbase check failed (txid %s) %s", - block.vtx[0]->GetId().ToString(), + block.vtx[0]->GetHash().ToString(), state.GetDebugMessage())); } @@ -3302,7 +3303,7 @@ return state.Invalid( false, state.GetRejectCode(), state.GetRejectReason(), strprintf("Transaction check failed (txid %s) %s", - tx->GetId().ToString(), state.GetDebugMessage())); + tx->GetHash().ToString(), state.GetDebugMessage())); } } @@ -4943,8 +4944,8 @@ Amount amountdelta = nFeeDelta; if (amountdelta != 0) { - mempool.PrioritiseTransaction(tx->GetId(), - tx->GetId().ToString(), + mempool.PrioritiseTransaction(tx->GetHash(), + tx->GetHash().ToString(), prioritydummy, amountdelta); } CValidationState state; @@ -5015,7 +5016,7 @@ file << *(i.tx); file << (int64_t)i.nTime; file << (int64_t)i.nFeeDelta.GetSatoshis(); - mapDeltas.erase(i.tx->GetId()); + mapDeltas.erase(i.tx->GetHash()); } file << mapDeltas; diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -286,7 +286,7 @@ CMutableTransaction tx; if (!DecodeHexTx(tx, request.params[0].get_str())) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); - uint256 txid = tx.GetId(); + uint256 txid = tx.GetHash(); CWalletTx wtx(pwalletMain, MakeTransactionRef(std::move(tx))); CDataStream ssMB(ParseHexV(request.params[1], "proof"), SER_NETWORK, diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -244,7 +244,7 @@ bool isAbandoned() const { return (hashBlock == ABANDON_HASH); } void setAbandoned() { hashBlock = ABANDON_HASH; } - const uint256 &GetId() const { return tx->GetId(); } + const uint256 &GetId() const { return tx->GetHash(); } bool IsCoinBase() const { return tx->IsCoinBase(); } }; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1168,10 +1168,10 @@ std::pair range = mapTxSpends.equal_range(txin.prevout); while (range.first != range.second) { - if (range.first->second != tx.GetId()) { + if (range.first->second != tx.GetHash()) { LogPrintf("Transaction %s (in block %s) conflicts with " "wallet transaction %s (both spend %s:%i)\n", - tx.GetId().ToString(), + tx.GetHash().ToString(), pIndex->GetBlockHash().ToString(), range.first->second.ToString(), range.first->first.hash.ToString(), @@ -1183,7 +1183,7 @@ } } - bool fExisted = mapWallet.count(tx.GetId()) != 0; + bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) { return false; } diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp --- a/src/zmq/zmqpublishnotifier.cpp +++ b/src/zmq/zmqpublishnotifier.cpp @@ -145,7 +145,7 @@ bool CZMQPublishHashTransactionNotifier::NotifyTransaction( const CTransaction &transaction) { - uint256 txid = transaction.GetId(); + uint256 txid = transaction.GetHash(); LogPrint("zmq", "zmq: Publish hashtx %s\n", txid.GetHex()); char data[32]; for (unsigned int i = 0; i < 32; i++) @@ -175,7 +175,7 @@ bool CZMQPublishRawTransactionNotifier::NotifyTransaction( const CTransaction &transaction) { - uint256 txid = transaction.GetId(); + uint256 txid = transaction.GetHash(); LogPrint("zmq", "zmq: Publish rawtx %s\n", txid.GetHex()); CDataStream ss(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); ss << transaction;