diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 319be2991..6541b4fa0 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -498,7 +498,7 @@ static void OutputTxJSON(const CTransaction& tx) static void OutputTxHash(const CTransaction& tx) { - string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id) + string strHexHash = tx.GetTxid().GetHex(); // the hex-encoded transaction hash (aka the transaction id) fprintf(stdout, "%s\n", strHexHash.c_str()); } diff --git a/src/bloom.cpp b/src/bloom.cpp index de8720659..bd1e13679 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -142,7 +142,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx) return true; if (isEmpty) return false; - const uint256& hash = tx.GetHash(); + const uint256& hash = tx.GetTxid(); if (contains(hash)) fFound = true; diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 8de90918d..17c961f13 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -89,7 +89,7 @@ public: //genesis.nBits = 0x1d00ffff; genesis.nBits = 0x207fffff; genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001"); - genesis.nSolution = {400496, 12965800, 7933378, 26516310, 3573504, 12897574, 9332739, 12534918}; + genesis.nSolution = {400496, 12965800, 7933378, 26516310, 3573504, 12897574, 9332739, 12534918 }; consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x5ff8e250c158c0694814582883343e8a0de5b7e7a5236324d4bf3293a56b6bc5")); @@ -158,10 +158,10 @@ public: //! Modify the testnet genesis block so the timestamp is valid for a later start. genesis.nTime = 1296688602; genesis.nBits = 0x207fffff; - genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000"); - genesis.nSolution = {830051, 14471730, 2076450, 21556280, 12194645, 22042975, 16221394, 24048626}; + genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001"); + genesis.nSolution = {72259, 18942116, 2293670, 7851750, 998282, 2855279, 12981515, 15324503}; consensus.hashGenesisBlock = genesis.GetHash(); - assert(consensus.hashGenesisBlock == uint256S("0x69675325ac7fb1f5a6bebb7fc8581f9160cbf970817f50b5199df7ff7b2833bd")); + assert(consensus.hashGenesisBlock == uint256S("0x20a21e2f7d7079d517cb19f8db30bafd396652d34c2705093531d0172e40ebc6")); vFixedSeeds.clear(); vSeeds.clear(); @@ -226,11 +226,11 @@ public: nEquihashK = 5; genesis.nTime = 1296688602; genesis.nBits = 0x207fffff; - genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000003"); - genesis.nSolution = {21, 374, 135, 192, 103, 221, 198, 303, 87, 330, 306, 464, 98, 239, 146, 471, 35, 137, 53, 387, 97, 454, 412, 434, 75, 352, 180, 367, 121, 480, 158, 482}; + genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000005"); + genesis.nSolution = {8, 205, 95, 334, 13, 385, 266, 399, 58, 389, 129, 383, 110, 284, 460, 499, 45, 496, 269, 348, 65, 242, 212, 272, 141, 477, 394, 469, 175, 185, 270, 365}; consensus.hashGenesisBlock = genesis.GetHash(); nDefaultPort = 18444; - assert(consensus.hashGenesisBlock == uint256S("0x37e57b7047e1a59918a8f98b9bbebc0b6e16e246211ad1f5c664d7e8f7d8d709")); + assert(consensus.hashGenesisBlock == uint256S("0x0d5badaa07ac1914c9b2429825cafe9273763f2c5d44eadabf1e333e50a9e281")); nPruneAfterHeight = 1000; vFixedSeeds.clear(); //! Regtest mode doesn't have any fixed seeds. diff --git a/src/core_write.cpp b/src/core_write.cpp index c3babec2f..b7db39432 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -88,7 +88,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey, void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry) { - entry.pushKV("txid", tx.GetHash().GetHex()); + entry.pushKV("txid", tx.GetTxid().GetHex()); entry.pushKV("version", tx.nVersion); entry.pushKV("locktime", (int64_t)tx.nLockTime); diff --git a/src/init.cpp b/src/init.cpp index 19ac9792d..6b3d9a1df 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1384,7 +1384,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) BOOST_FOREACH(const CWalletTx& wtxOld, vWtx) { - uint256 hash = wtxOld.GetHash(); + uint256 hash = wtxOld.GetTxid(); std::map::iterator mi = pwalletMain->mapWallet.find(hash); if (mi != pwalletMain->mapWallet.end()) { diff --git a/src/main.cpp b/src/main.cpp index b9d58cd17..b5d4f3d94 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -553,7 +553,7 @@ CBlockTreeDB *pblocktree = NULL; bool AddOrphanTx(const CTransaction& tx, NodeId peer) { - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); if (mapOrphanTransactions.count(hash)) return false; @@ -607,7 +607,7 @@ void EraseOrphansFor(NodeId peer) map::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid if (maybeErase->second.fromPeer == peer) { - EraseOrphanTx(maybeErase->second.tx.GetHash()); + EraseOrphanTx(maybeErase->second.tx.GetTxid()); ++nErased; } } @@ -1033,7 +1033,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF { { LOCK(mempool.cs); - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); double dPriorityDelta = 0; CAmount nFeeDelta = 0; mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); @@ -1088,7 +1088,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); // is it already in the memory pool? - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); if (pool.exists(hash)) return false; @@ -1280,7 +1280,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock return error("%s: Deserialize or I/O error - %s", __func__, e.what()); } hashBlock = header.GetHash(); - if (txOut.GetHash() != hash) + if (txOut.GetTxid() != hash) return error("%s: txid mismatch", __func__); return true; } @@ -1302,7 +1302,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock CBlock block; if (ReadBlockFromDisk(block, pindexSlow)) { BOOST_FOREACH(const CTransaction &tx, block.vtx) { - if (tx.GetHash() == hash) { + if (tx.GetTxid() == hash) { txOut = tx; hashBlock = pindexSlow->GetBlockHash(); return true; @@ -1593,7 +1593,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach } // add outputs - inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight); + inputs.ModifyCoins(tx.GetTxid())->FromTx(tx, nHeight); } void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight) @@ -1605,7 +1605,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach bool CScriptCheck::operator()() { const CScript &scriptSig = ptxTo->vin[nIn].scriptSig; if (!VerifyScript(scriptSig, scriptPubKey, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, cacheStore), &error)) { - return ::error("CScriptCheck(): %s:%d VerifySignature failed: %s", ptxTo->GetHash().ToString(), nIn, ScriptErrorString(error)); + return ::error("CScriptCheck(): %s:%d VerifySignature failed: %s", ptxTo->GetTxid().ToString(), nIn, ScriptErrorString(error)); } return true; } @@ -1620,11 +1620,11 @@ bool NonContextualCheckInputs(const CTransaction& tx, CValidationState &state, c // This doesn't trigger the DoS code on purpose; if it did, it would make it easier // for an attacker to attempt to split the network. if (!inputs.HaveInputs(tx)) - return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetHash().ToString())); + return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetTxid().ToString())); // are the JoinSplit's requirements met? if (!inputs.HaveJoinSplitRequirements(tx)) - return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetHash().ToString())); + return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetTxid().ToString())); CAmount nValueIn = 0; CAmount nFees = 0; @@ -1661,13 +1661,13 @@ bool NonContextualCheckInputs(const CTransaction& tx, CValidationState &state, c if (nValueIn < tx.GetValueOut()) return state.DoS(100, error("CheckInputs(): %s value in (%s) < value out (%s)", - tx.GetHash().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())), + tx.GetTxid().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())), REJECT_INVALID, "bad-txns-in-belowout"); // Tally transaction fees CAmount nTxFee = nValueIn - tx.GetValueOut(); if (nTxFee < 0) - return state.DoS(100, error("CheckInputs(): %s nTxFee < 0", tx.GetHash().ToString()), + return state.DoS(100, error("CheckInputs(): %s nTxFee < 0", tx.GetTxid().ToString()), REJECT_INVALID, "bad-txns-fee-negative"); nFees += nTxFee; if (!MoneyRange(nFees)) @@ -1886,7 +1886,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex // undo transactions in reverse order for (int i = block.vtx.size() - 1; i >= 0; i--) { const CTransaction &tx = block.vtx[i]; - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); // Check that all outputs are available and match the outputs in the block itself // exactly. @@ -2067,7 +2067,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Do not allow blocks that contain transactions which 'overwrite' older transactions, // unless those are already completely spent. BOOST_FOREACH(const CTransaction& tx, block.vtx) { - const CCoins* coins = view.AccessCoins(tx.GetHash()); + const CCoins* coins = view.AccessCoins(tx.GetTxid()); if (coins && !coins->IsPruned()) return state.DoS(100, error("ConnectBlock(): tried to overwrite transaction"), REJECT_INVALID, "bad-txns-BIP30"); @@ -2165,7 +2165,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } - vPos.push_back(std::make_pair(tx.GetHash(), pos)); + vPos.push_back(std::make_pair(tx.GetTxid(), pos)); pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); } @@ -2222,7 +2222,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Watch for changes to the previous coinbase transaction. static uint256 hashPrevBestCoinBase; GetMainSignals().UpdatedTransaction(hashPrevBestCoinBase); - hashPrevBestCoinBase = block.vtx[0].GetHash(); + hashPrevBestCoinBase = block.vtx[0].GetTxid(); int64_t nTime4 = GetTimeMicros(); nTimeCallbacks += nTime4 - nTime3; LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001); @@ -4654,7 +4654,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, CTransaction tx; vRecv >> tx; - CInv inv(MSG_TX, tx.GetHash()); + CInv inv(MSG_TX, tx.GetTxid()); pfrom->AddInventoryKnown(inv); LOCK(cs_main); @@ -4676,7 +4676,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrint("mempool", "AcceptToMemoryPool: peer=%d %s: accepted %s (poolsz %u)\n", pfrom->id, pfrom->cleanSubVer, - tx.GetHash().ToString(), + tx.GetTxid().ToString(), mempool.mapTx.size()); // Recursively process any orphan transactions that depended on this one @@ -4745,7 +4745,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted); } else { assert(recentRejects); - recentRejects->insert(tx.GetHash()); + recentRejects->insert(tx.GetTxid()); if (pfrom->fWhitelisted) { // Always relay transactions received from whitelisted peers, even @@ -4761,7 +4761,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int nDoS = 0; if (state.IsInvalid(nDoS)) { - LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(), + LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetTxid().ToString(), pfrom->id, pfrom->cleanSubVer, state.GetRejectReason()); pfrom->PushMessage("reject", strCommand, state.GetRejectCode(), diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp index f8e877df2..1d1f41ecd 100644 --- a/src/merkleblock.cpp +++ b/src/merkleblock.cpp @@ -23,7 +23,7 @@ CMerkleBlock::CMerkleBlock(const CBlock& block, CBloomFilter& filter) for (unsigned int i = 0; i < block.vtx.size(); i++) { - const uint256& hash = block.vtx[i].GetHash(); + const uint256& hash = block.vtx[i].GetTxid(); if (filter.IsRelevantAndUpdate(block.vtx[i])) { vMatch.push_back(true); @@ -49,7 +49,7 @@ CMerkleBlock::CMerkleBlock(const CBlock& block, const std::set& txids) for (unsigned int i = 0; i < block.vtx.size(); i++) { - const uint256& hash = block.vtx[i].GetHash(); + const uint256& hash = block.vtx[i].GetTxid(); if (txids.count(hash)) vMatch.push_back(true); else diff --git a/src/miner.cpp b/src/miner.cpp index 7f4949104..2e7192127 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -211,7 +211,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); dPriority = tx.ComputePriority(dPriority, nTxSize); - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); mempool.ApplyDeltas(hash, dPriority, nTotalIn); CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); @@ -255,7 +255,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) continue; // Skip free transactions if we're past the minimum block size: - const uint256& hash = tx.GetHash(); + const uint256& hash = tx.GetTxid(); double dPriorityDelta = 0; CAmount nFeeDelta = 0; mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); @@ -302,7 +302,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if (fPrintPriority) { LogPrintf("priority %.1f fee %s txid %s\n", - dPriority, feeRate.ToString(), tx.GetHash().ToString()); + dPriority, feeRate.ToString(), tx.GetTxid().ToString()); } // Add transactions that depend on this one to the priority queue diff --git a/src/net.cpp b/src/net.cpp index e4b22f9cc..412f4aa3d 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1751,7 +1751,7 @@ void RelayTransaction(const CTransaction& tx) void RelayTransaction(const CTransaction& tx, const CDataStream& ss) { - CInv inv(MSG_TX, tx.GetHash()); + CInv inv(MSG_TX, tx.GetTxid()); { LOCK(cs_mapRelay); // Expire old relay messages diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index ffe31d194..b6b5afbcb 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -344,7 +344,7 @@ bool CBlockPolicyEstimator::isPriDataPoint(const CFeeRate &fee, double pri) void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, bool fCurrentEstimate) { unsigned int txHeight = entry.GetHeight(); - uint256 hash = entry.GetTx().GetHash(); + uint256 hash = entry.GetTx().GetTxid(); if (mapMemPoolTxs[hash].stats != NULL) { LogPrint("estimatefee", "Blockpolicy error mempool tx %s already being tracked\n", hash.ToString().c_str()); diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index c2300c82a..9188274dd 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -55,7 +55,7 @@ uint256 CBlock::BuildMerkleTree(bool* fMutated) const vMerkleTree.clear(); vMerkleTree.reserve(vtx.size() * 2 + 16); // Safe upper bound for the number of total nodes. for (std::vector::const_iterator it(vtx.begin()); it != vtx.end(); ++it) - vMerkleTree.push_back(it->GetHash()); + vMerkleTree.push_back(it->GetTxid()); int j = 0; bool mutated = false; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 102a1a33d..854a0be66 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -116,11 +116,6 @@ CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.n } -uint256 CMutableTransaction::GetHash() const -{ - return SerializeHash(*this); -} - void CTransaction::UpdateHash() const { *const_cast(&hash) = SerializeHash(*this); @@ -132,6 +127,7 @@ CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig) { UpdateHash(); + UpdateTxid(); } CTransaction& CTransaction::operator=(const CTransaction &tx) { @@ -143,6 +139,7 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) { *const_cast(&joinSplitPubKey) = tx.joinSplitPubKey; *const_cast(&joinSplitSig) = tx.joinSplitSig; *const_cast(&hash) = tx.hash; + *const_cast(&txid) = tx.txid; return *this; } @@ -211,8 +208,9 @@ unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const std::string CTransaction::ToString() const { std::string str; - str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n", - GetHash().ToString().substr(0,10), + str += strprintf("CTransaction(txid=%s, hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n", + txid.ToString().substr(0,10), + hash.ToString().substr(0,10), nVersion, vin.size(), vout.size(), @@ -223,3 +221,32 @@ std::string CTransaction::ToString() const str += " " + vout[i].ToString() + "\n"; return str; } + +// Update the txid which is non-malleable. +// Signature data is cleared before the transaction is serialized and hashed. +void CTransaction::UpdateTxid() const +{ + // Create a deep copy of this transaction + CMutableTransaction tx(*this); + + // We keep the sigscript for coinbase txs to avoid duplicate txids (BIP34 and BIP30) + if (!IsCoinBase()) { + // Clear sigscript from all transaction inputs. + for (CTxIn & txIn : tx.vin) { + txIn.scriptSig.clear(); + } + + // Clear joinSplitSig by filling the buffer with zero + tx.joinSplitSig.assign(0); + } + + *const_cast(&txid) = SerializeHash(tx); +} + +// Return a txid which is non-malleable. +uint256 CMutableTransaction::GetTxid() const +{ + CTransaction tx(*this); + return tx.GetTxid(); +} + diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index a664159b0..ecfe40d10 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -288,6 +288,8 @@ private: /** Memory only. */ const uint256 hash; void UpdateHash() const; + const uint256 txid; + void UpdateTxid() const; public: typedef boost::array joinsplit_sig_t; @@ -331,18 +333,16 @@ public: READWRITE(*const_cast(&joinSplitSig)); } } - if (ser_action.ForRead()) + if (ser_action.ForRead()) { UpdateHash(); + UpdateTxid(); + } } bool IsNull() const { return vin.empty() && vout.empty(); } - const uint256& GetHash() const { - return hash; - } - // Return sum of txouts. CAmount GetValueOut() const; // GetValueIn() is a method on CCoinsViewCache, because @@ -373,6 +373,11 @@ public: } std::string ToString() const; + + // Return the txid, which is the double SHA256 hash over portions of the transaction. + const uint256& GetTxid() const { + return txid; + } }; /** A mutable version of CTransaction. */ @@ -407,10 +412,10 @@ struct CMutableTransaction } } - /** Compute the hash of this CMutableTransaction. This is computed on the - * fly, as opposed to GetHash() in CTransaction, which uses a cached result. + /** Compute the non-malleable txid of this CMutableTransaction. This is computed on the + * fly, as opposed to GetTxid() in CTransaction, which uses a cached result. */ - uint256 GetHash() const; + uint256 GetTxid() const; }; #endif // BITCOIN_PRIMITIVES_TRANSACTION_H diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 6a527429e..5aa3939c3 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -496,7 +496,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) { // unselect already spent, very unlikely scenario, this could happen // when selected are spent elsewhere, like rpc or another computer - uint256 txhash = out.tx->GetHash(); + uint256 txhash = out.tx->GetTxid(); COutPoint outpt(txhash, out.i); if (model->isSpent(outpt)) { @@ -782,7 +782,7 @@ void CoinControlDialog::updateView() nInputSum += nInputSize; // transaction hash - uint256 txhash = out.tx->GetHash(); + uint256 txhash = out.tx->GetTxid(); itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex())); // vout index diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index d7ee3d4c7..f897f49e3 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -240,7 +240,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty()) strHTML += "
" + tr("Comment") + ":
" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "
"; - strHTML += "" + tr("Transaction ID") + ": " + TransactionRecord::formatSubTxId(wtx.GetHash(), rec->idx) + "
"; + strHTML += "" + tr("Transaction ID") + ": " + TransactionRecord::formatSubTxId(wtx.GetTxid(), rec->idx) + "
"; // Message from normal bitcoin:URI (bitcoin:123...?message=example) Q_FOREACH (const PAIRTYPE(string, string)& r, wtx.vOrderForm) diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 15d13e9fc..f802bcf30 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -39,7 +39,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet * CAmount nCredit = wtx.GetCredit(ISMINE_ALL); CAmount nDebit = wtx.GetDebit(ISMINE_ALL); CAmount nNet = nCredit - nDebit; - uint256 hash = wtx.GetHash(); + uint256 hash = wtx.GetTxid(); std::map mapValue = wtx.mapValue; if (nNet > 0 || wtx.IsCoinBase()) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 0450a5a3b..ac7102265 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -80,7 +80,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDe txs.push_back(objTx); } else - txs.push_back(tx.GetHash().GetHex()); + txs.push_back(tx.GetTxid().GetHex()); } result.push_back(Pair("tx", txs)); result.push_back(Pair("time", block.GetBlockTime())); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 6b979aa34..447ab07bd 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -561,7 +561,7 @@ Value getblocktemplate(const Array& params, bool fHelp) int i = 0; BOOST_FOREACH (CTransaction& tx, pblock->vtx) { - uint256 txHash = tx.GetHash(); + uint256 txHash = tx.GetTxid(); setTxIndex[txHash] = i++; if (tx.IsCoinBase()) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 617dc7785..513df78d1 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -57,7 +57,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry) { - entry.push_back(Pair("txid", tx.GetHash().GetHex())); + entry.push_back(Pair("txid", tx.GetTxid().GetHex())); entry.push_back(Pair("version", tx.nVersion)); entry.push_back(Pair("locktime", (int64_t)tx.nLockTime)); Array vin; @@ -307,7 +307,7 @@ Value gettxoutproof(const Array& params, bool fHelp) unsigned int ntxFound = 0; BOOST_FOREACH(const CTransaction&tx, block.vtx) - if (setTxids.count(tx.GetHash())) + if (setTxids.count(tx.GetTxid())) ntxFound++; if (ntxFound != setTxids.size()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "(Not all) transactions not found in specified block"); @@ -818,7 +818,7 @@ Value sendrawtransaction(const Array& params, bool fHelp) CTransaction tx; if (!DecodeHexTx(tx, params[0].get_str())) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); - uint256 hashTx = tx.GetHash(); + uint256 hashTx = tx.GetTxid(); bool fOverrideFees = false; if (params.size() > 1) diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index bf2554875..1c3b79c65 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans) CMutableTransaction tx; tx.vin.resize(1); tx.vin[0].prevout.n = 0; - tx.vin[0].prevout.hash = txPrev.GetHash(); + tx.vin[0].prevout.hash = txPrev.GetTxid(); tx.vout.resize(1); tx.vout[0].nValue = 1*CENT; tx.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID()); @@ -169,7 +169,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans) for (unsigned int j = 0; j < tx.vin.size(); j++) { tx.vin[j].prevout.n = j; - tx.vin[j].prevout.hash = txPrev.GetHash(); + tx.vin[j].prevout.hash = txPrev.GetTxid(); } SignSignature(keystore, txPrev, tx, 0); // Re-use same signature for other inputs diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp index 0c2ade48d..c624d1953 100644 --- a/src/test/accounting_tests.cpp +++ b/src/test/accounting_tests.cpp @@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade) wtx.mapValue["comment"] = "z"; pwalletMain->AddToWallet(wtx, false, &walletdb); - vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]); + vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetTxid()]); vpwtx[0]->nTimeReceived = (unsigned int)1333333335; vpwtx[0]->nOrderPos = -1; @@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade) *static_cast(&wtx) = CTransaction(tx); } pwalletMain->AddToWallet(wtx, false, &walletdb); - vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]); + vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetTxid()]); vpwtx[1]->nTimeReceived = (unsigned int)1333333336; wtx.mapValue["comment"] = "x"; @@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade) *static_cast(&wtx) = CTransaction(tx); } pwalletMain->AddToWallet(wtx, false, &walletdb); - vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]); + vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetTxid()]); vpwtx[2]->nTimeReceived = (unsigned int)1333333329; vpwtx[2]->nOrderPos = -1; diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp index e99f99226..77b16fd4e 100644 --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -113,50 +113,55 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_key) BOOST_AUTO_TEST_CASE(bloom_match) { - // Random real transaction (b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b) + // Random zcash transaction (19cfa5db35f33a2e67fe1b9b738731b62e548d2f27c55a2f28523fec52b71525) CTransaction tx; - CDataStream stream(ParseHex("01000000010b26e9b7735eb6aabdf358bab62f9816a21ba9ebdb719d5299e88607d722c190000000008b4830450220070aca44506c5cef3a16ed519d7c3c39f8aab192c4e1c90d065f37b8a4af6141022100a8e160b856c2d43d27d8fba71e5aef6405b8643ac4cb7cb3c462aced7f14711a0141046d11fee51b0e60666d5049a9101a72741df480b96ee26488a4d3466b95c9a40ac5eeef87e10a5cd336c19a84565f80fa6c547957b7700ff4dfbdefe76036c339ffffffff021bff3d11000000001976a91404943fdd508053c75000106d3bc6e2754dbcff1988ac2f15de00000000001976a914a266436d2965547608b9e15d9032a7b9d64fa43188ac00000000"), SER_DISK, CLIENT_VERSION); + CDataStream stream(ParseHex("01000000015ad78be5497476bbf84869d8156761ca850b6e82e48ad1315069a3726516a3d1010000006b483045022100ba5e90204e83c5f961b67c6232c1cc6c360afd36d43fcfae0de7af2e75f4cda7022012fec415a12048dbb70511fda6195b090b56735232281dc1144409833a092edc012102c322382e17c9ed4f47183f219cc5dd7853f939fb8eebae3c943622e0abf8d5e5feffffff0280969800000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988acd694693a000000001976a9145f0d00adba6489150808feb4108d7be582cbb2e188ac0a000000"), SER_DISK, CLIENT_VERSION); stream >> tx; - // and one which spends it (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436) - unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x85, 0x65, 0xef, 0x40, 0x6d, 0xd5, 0xd6, 0x3d, 0x4f, 0xf9, 0x4f, 0x31, 0x8f, 0xe8, 0x20, 0x27, 0xfd, 0x4d, 0xc4, 0x51, 0xb0, 0x44, 0x74, 0x01, 0x9f, 0x74, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x49, 0x30, 0x46, 0x02, 0x21, 0x00, 0xda, 0x0d, 0xc6, 0xae, 0xce, 0xfe, 0x1e, 0x06, 0xef, 0xdf, 0x05, 0x77, 0x37, 0x57, 0xde, 0xb1, 0x68, 0x82, 0x09, 0x30, 0xe3, 0xb0, 0xd0, 0x3f, 0x46, 0xf5, 0xfc, 0xf1, 0x50, 0xbf, 0x99, 0x0c, 0x02, 0x21, 0x00, 0xd2, 0x5b, 0x5c, 0x87, 0x04, 0x00, 0x76, 0xe4, 0xf2, 0x53, 0xf8, 0x26, 0x2e, 0x76, 0x3e, 0x2d, 0xd5, 0x1e, 0x7f, 0xf0, 0xbe, 0x15, 0x77, 0x27, 0xc4, 0xbc, 0x42, 0x80, 0x7f, 0x17, 0xbd, 0x39, 0x01, 0x41, 0x04, 0xe6, 0xc2, 0x6e, 0xf6, 0x7d, 0xc6, 0x10, 0xd2, 0xcd, 0x19, 0x24, 0x84, 0x78, 0x9a, 0x6c, 0xf9, 0xae, 0xa9, 0x93, 0x0b, 0x94, 0x4b, 0x7e, 0x2d, 0xb5, 0x34, 0x2b, 0x9d, 0x9e, 0x5b, 0x9f, 0xf7, 0x9a, 0xff, 0x9a, 0x2e, 0xe1, 0x97, 0x8d, 0xd7, 0xfd, 0x01, 0xdf, 0xc5, 0x22, 0xee, 0x02, 0x28, 0x3d, 0x3b, 0x06, 0xa9, 0xd0, 0x3a, 0xcf, 0x80, 0x96, 0x96, 0x8d, 0x7d, 0xbb, 0x0f, 0x91, 0x78, 0xff, 0xff, 0xff, 0xff, 0x02, 0x8b, 0xa7, 0x94, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xba, 0xde, 0xec, 0xfd, 0xef, 0x05, 0x07, 0x24, 0x7f, 0xc8, 0xf7, 0x42, 0x41, 0xd7, 0x3b, 0xc0, 0x39, 0x97, 0x2d, 0x7b, 0x88, 0xac, 0x40, 0x94, 0xa8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00}; - vector vch(ch, ch + sizeof(ch) -1); - CDataStream spendStream(vch, SER_DISK, CLIENT_VERSION); + // and one which spends it (1079621bf638e8bea9ee2f8d15287ae31a269969c360006d68d8ee07a7f532e6) + CDataStream spendStream(ParseHex("01000000012515b752ec3f52282f5ac5272f8d542eb63187739b1bfe672e3af335dba5cf19000000006b4830450221009e496c27d1ec174666da187815407c5b7b4d71ed8935e427a334df6d5d7c9e2c022007ca48eabad68cdec0a7d3be15d64a950bb3d80ac2b988fcd82394064a0a32a0012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cffffffff01808d5b00000000001976a9146d1c88970e614202031a4f2ba13846f8ce91019e88ac00000000"), SER_DISK, CLIENT_VERSION); + + //unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x85, 0x65, 0xef, 0x40, 0x6d, 0xd5, 0xd6, 0x3d, 0x4f, 0xf9, 0x4f, 0x31, 0x8f, 0xe8, 0x20, 0x27, 0xfd, 0x4d, 0xc4, 0x51, 0xb0, 0x44, 0x74, 0x01, 0x9f, 0x74, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x49, 0x30, 0x46, 0x02, 0x21, 0x00, 0xda, 0x0d, 0xc6, 0xae, 0xce, 0xfe, 0x1e, 0x06, 0xef, 0xdf, 0x05, 0x77, 0x37, 0x57, 0xde, 0xb1, 0x68, 0x82, 0x09, 0x30, 0xe3, 0xb0, 0xd0, 0x3f, 0x46, 0xf5, 0xfc, 0xf1, 0x50, 0xbf, 0x99, 0x0c, 0x02, 0x21, 0x00, 0xd2, 0x5b, 0x5c, 0x87, 0x04, 0x00, 0x76, 0xe4, 0xf2, 0x53, 0xf8, 0x26, 0x2e, 0x76, 0x3e, 0x2d, 0xd5, 0x1e, 0x7f, 0xf0, 0xbe, 0x15, 0x77, 0x27, 0xc4, 0xbc, 0x42, 0x80, 0x7f, 0x17, 0xbd, 0x39, 0x01, 0x41, 0x04, 0xe6, 0xc2, 0x6e, 0xf6, 0x7d, 0xc6, 0x10, 0xd2, 0xcd, 0x19, 0x24, 0x84, 0x78, 0x9a, 0x6c, 0xf9, 0xae, 0xa9, 0x93, 0x0b, 0x94, 0x4b, 0x7e, 0x2d, 0xb5, 0x34, 0x2b, 0x9d, 0x9e, 0x5b, 0x9f, 0xf7, 0x9a, 0xff, 0x9a, 0x2e, 0xe1, 0x97, 0x8d, 0xd7, 0xfd, 0x01, 0xdf, 0xc5, 0x22, 0xee, 0x02, 0x28, 0x3d, 0x3b, 0x06, 0xa9, 0xd0, 0x3a, 0xcf, 0x80, 0x96, 0x96, 0x8d, 0x7d, 0xbb, 0x0f, 0x91, 0x78, 0xff, 0xff, 0xff, 0xff, 0x02, 0x8b, 0xa7, 0x94, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xba, 0xde, 0xec, 0xfd, 0xef, 0x05, 0x07, 0x24, 0x7f, 0xc8, 0xf7, 0x42, 0x41, 0xd7, 0x3b, 0xc0, 0x39, 0x97, 0x2d, 0x7b, 0x88, 0xac, 0x40, 0x94, 0xa8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00}; + //vector vch(ch, ch + sizeof(ch) -1); + //CDataStream spendStream(vch, SER_DISK, CLIENT_VERSION); + CTransaction spendingTx; spendStream >> spendingTx; CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); - filter.insert(uint256S("0xb4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b")); + filter.insert(uint256S("0x19cfa5db35f33a2e67fe1b9b738731b62e548d2f27c55a2f28523fec52b71525")); BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match tx hash"); filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); // byte-reversed tx hash - filter.insert(ParseHex("6bff7fcd4f8565ef406dd5d63d4ff94f318fe82027fd4dc451b04474019f74b4")); + filter.insert(ParseHex("2515b752ec3f52282f5ac5272f8d542eb63187739b1bfe672e3af335dba5cf19")); BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match manually serialized tx hash"); filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); - filter.insert(ParseHex("30450220070aca44506c5cef3a16ed519d7c3c39f8aab192c4e1c90d065f37b8a4af6141022100a8e160b856c2d43d27d8fba71e5aef6405b8643ac4cb7cb3c462aced7f14711a01")); + filter.insert(ParseHex("3045022100ba5e90204e83c5f961b67c6232c1cc6c360afd36d43fcfae0de7af2e75f4cda7022012fec415a12048dbb70511fda6195b090b56735232281dc1144409833a092edc01")); BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match input signature"); filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); - filter.insert(ParseHex("046d11fee51b0e60666d5049a9101a72741df480b96ee26488a4d3466b95c9a40ac5eeef87e10a5cd336c19a84565f80fa6c547957b7700ff4dfbdefe76036c339")); + filter.insert(ParseHex("02c322382e17c9ed4f47183f219cc5dd7853f939fb8eebae3c943622e0abf8d5e5")); BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match input pub key"); filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); - filter.insert(ParseHex("04943fdd508053c75000106d3bc6e2754dbcff19")); + filter.insert(ParseHex("30271a250e92135ce0db0783ebb63aaeb58e47f9")); BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match output address"); BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(spendingTx), "Simple Bloom filter didn't add output"); + // Need a second output for this. filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); - filter.insert(ParseHex("a266436d2965547608b9e15d9032a7b9d64fa431")); + filter.insert(ParseHex("5f0d00adba6489150808feb4108d7be582cbb2e1")); BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match output address"); + // This prev output has index of 1 filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); - filter.insert(COutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b"), 0)); + filter.insert(COutPoint(uint256S("0xd1a3166572a3695031d18ae4826e0b85ca616715d86948f8bb767449e58bd75a"), 1)); BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't match COutPoint"); filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); - COutPoint prevOutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bdaab65e73b7e9260b"), 0); + COutPoint prevOutPoint(uint256S("0xd1a3166572a3695031d18ae4826e0b85ca616715d86948f8bb767449e58bd75a"), 1); { vector data(32 + sizeof(unsigned int)); memcpy(&data[0], prevOutPoint.hash.begin(), 32); @@ -184,15 +189,15 @@ BOOST_AUTO_TEST_CASE(bloom_match) BOOST_AUTO_TEST_CASE(merkle_block_1) { - // Random real block (0000000000013b8ab2cd513b0261a14096412195a72a0c4827d229dcc7e0f7af) - // With 9 txes + // zcash regtest block 25abec437fb3e176fc3058076b78ec95249f20ceb4e2cff69f90525d964440b5 + // With 6 txes CBlock block; - CDataStream stream(ParseHex("0100000090f0a9f110702f808219ebea1173056042a714bad51b916cb6800000000000005275289558f51c9966699404ae2294730c3c9f9bda53523ce50e9b95e558da2fdb261b4d4c86041b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001ab1bf93000901000000010000000000000000000000000000000000000000000000000000000000000000ffffffff07044c86041b0146ffffffff0100f2052a01000000434104e18f7afbe4721580e81e8414fc8c24d7cfacf254bb5c7b949450c3e997c2dc1242487a8169507b631eb3771f2b425483fb13102c4eb5d858eef260fe70fbfae0ac00000000010000000196608ccbafa16abada902780da4dc35dafd7af05fa0da08cf833575f8cf9e836000000004a493046022100dab24889213caf43ae6adc41cf1c9396c08240c199f5225acf45416330fd7dbd022100fe37900e0644bf574493a07fc5edba06dbc07c311b947520c2d514bc5725dcb401ffffffff0100f2052a010000001976a914f15d1921f52e4007b146dfa60f369ed2fc393ce288ac000000000100000001fb766c1288458c2bafcfec81e48b24d98ec706de6b8af7c4e3c29419bfacb56d000000008c493046022100f268ba165ce0ad2e6d93f089cfcd3785de5c963bb5ea6b8c1b23f1ce3e517b9f022100da7c0f21adc6c401887f2bfd1922f11d76159cbc597fbd756a23dcbb00f4d7290141042b4e8625a96127826915a5b109852636ad0da753c9e1d5606a50480cd0c40f1f8b8d898235e571fe9357d9ec842bc4bba1827daaf4de06d71844d0057707966affffffff0280969800000000001976a9146963907531db72d0ed1a0cfb471ccb63923446f388ac80d6e34c000000001976a914f0688ba1c0d1ce182c7af6741e02658c7d4dfcd388ac000000000100000002c40297f730dd7b5a99567eb8d27b78758f607507c52292d02d4031895b52f2ff010000008b483045022100f7edfd4b0aac404e5bab4fd3889e0c6c41aa8d0e6fa122316f68eddd0a65013902205b09cc8b2d56e1cd1f7f2fafd60a129ed94504c4ac7bdc67b56fe67512658b3e014104732012cb962afa90d31b25d8fb0e32c94e513ab7a17805c14ca4c3423e18b4fb5d0e676841733cb83abaf975845c9f6f2a8097b7d04f4908b18368d6fc2d68ecffffffffca5065ff9617cbcba45eb23726df6498a9b9cafed4f54cbab9d227b0035ddefb000000008a473044022068010362a13c7f9919fa832b2dee4e788f61f6f5d344a7c2a0da6ae740605658022006d1af525b9a14a35c003b78b72bd59738cd676f845d1ff3fc25049e01003614014104732012cb962afa90d31b25d8fb0e32c94e513ab7a17805c14ca4c3423e18b4fb5d0e676841733cb83abaf975845c9f6f2a8097b7d04f4908b18368d6fc2d68ecffffffff01001ec4110200000043410469ab4181eceb28985b9b4e895c13fa5e68d85761b7eee311db5addef76fa8621865134a221bd01f28ec9999ee3e021e60766e9d1f3458c115fb28650605f11c9ac000000000100000001cdaf2f758e91c514655e2dc50633d1e4c84989f8aa90a0dbc883f0d23ed5c2fa010000008b48304502207ab51be6f12a1962ba0aaaf24a20e0b69b27a94fac5adf45aa7d2d18ffd9236102210086ae728b370e5329eead9accd880d0cb070aea0c96255fae6c4f1ddcce1fd56e014104462e76fd4067b3a0aa42070082dcb0bf2f388b6495cf33d789904f07d0f55c40fbd4b82963c69b3dc31895d0c772c812b1d5fbcade15312ef1c0e8ebbb12dcd4ffffffff02404b4c00000000001976a9142b6ba7c9d796b75eef7942fc9288edd37c32f5c388ac002d3101000000001976a9141befba0cdc1ad56529371864d9f6cb042faa06b588ac000000000100000001b4a47603e71b61bc3326efd90111bf02d2f549b067f4c4a8fa183b57a0f800cb010000008a4730440220177c37f9a505c3f1a1f0ce2da777c339bd8339ffa02c7cb41f0a5804f473c9230220585b25a2ee80eb59292e52b987dad92acb0c64eced92ed9ee105ad153cdb12d001410443bd44f683467e549dae7d20d1d79cbdb6df985c6e9c029c8d0c6cb46cc1a4d3cf7923c5021b27f7a0b562ada113bc85d5fda5a1b41e87fe6e8802817cf69996ffffffff0280651406000000001976a9145505614859643ab7b547cd7f1f5e7e2a12322d3788ac00aa0271000000001976a914ea4720a7a52fc166c55ff2298e07baf70ae67e1b88ac00000000010000000586c62cd602d219bb60edb14a3e204de0705176f9022fe49a538054fb14abb49e010000008c493046022100f2bc2aba2534becbdf062eb993853a42bbbc282083d0daf9b4b585bd401aa8c9022100b1d7fd7ee0b95600db8535bbf331b19eed8d961f7a8e54159c53675d5f69df8c014104462e76fd4067b3a0aa42070082dcb0bf2f388b6495cf33d789904f07d0f55c40fbd4b82963c69b3dc31895d0c772c812b1d5fbcade15312ef1c0e8ebbb12dcd4ffffffff03ad0e58ccdac3df9dc28a218bcf6f1997b0a93306faaa4b3a28ae83447b2179010000008b483045022100be12b2937179da88599e27bb31c3525097a07cdb52422d165b3ca2f2020ffcf702200971b51f853a53d644ebae9ec8f3512e442b1bcb6c315a5b491d119d10624c83014104462e76fd4067b3a0aa42070082dcb0bf2f388b6495cf33d789904f07d0f55c40fbd4b82963c69b3dc31895d0c772c812b1d5fbcade15312ef1c0e8ebbb12dcd4ffffffff2acfcab629bbc8685792603762c921580030ba144af553d271716a95089e107b010000008b483045022100fa579a840ac258871365dd48cd7552f96c8eea69bd00d84f05b283a0dab311e102207e3c0ee9234814cfbb1b659b83671618f45abc1326b9edcc77d552a4f2a805c0014104462e76fd4067b3a0aa42070082dcb0bf2f388b6495cf33d789904f07d0f55c40fbd4b82963c69b3dc31895d0c772c812b1d5fbcade15312ef1c0e8ebbb12dcd4ffffffffdcdc6023bbc9944a658ddc588e61eacb737ddf0a3cd24f113b5a8634c517fcd2000000008b4830450221008d6df731df5d32267954bd7d2dda2302b74c6c2a6aa5c0ca64ecbabc1af03c75022010e55c571d65da7701ae2da1956c442df81bbf076cdbac25133f99d98a9ed34c014104462e76fd4067b3a0aa42070082dcb0bf2f388b6495cf33d789904f07d0f55c40fbd4b82963c69b3dc31895d0c772c812b1d5fbcade15312ef1c0e8ebbb12dcd4ffffffffe15557cd5ce258f479dfd6dc6514edf6d7ed5b21fcfa4a038fd69f06b83ac76e010000008b483045022023b3e0ab071eb11de2eb1cc3a67261b866f86bf6867d4558165f7c8c8aca2d86022100dc6e1f53a91de3efe8f63512850811f26284b62f850c70ca73ed5de8771fb451014104462e76fd4067b3a0aa42070082dcb0bf2f388b6495cf33d789904f07d0f55c40fbd4b82963c69b3dc31895d0c772c812b1d5fbcade15312ef1c0e8ebbb12dcd4ffffffff01404b4c00000000001976a9142b6ba7c9d796b75eef7942fc9288edd37c32f5c388ac00000000010000000166d7577163c932b4f9690ca6a80b6e4eb001f0a2fa9023df5595602aae96ed8d000000008a4730440220262b42546302dfb654a229cefc86432b89628ff259dc87edd1154535b16a67e102207b4634c020a97c3e7bbd0d4d19da6aa2269ad9dded4026e896b213d73ca4b63f014104979b82d02226b3a4597523845754d44f13639e3bf2df5e82c6aab2bdc79687368b01b1ab8b19875ae3c90d661a3d0a33161dab29934edeb36aa01976be3baf8affffffff02404b4c00000000001976a9144854e695a02af0aeacb823ccbc272134561e0a1688ac40420f00000000001976a914abee93376d6b37b5c2940655a6fcaf1c8e74237988ac0000000001000000014e3f8ef2e91349a9059cb4f01e54ab2597c1387161d3da89919f7ea6acdbb371010000008c49304602210081f3183471a5ca22307c0800226f3ef9c353069e0773ac76bb580654d56aa523022100d4c56465bdc069060846f4fbf2f6b20520b2a80b08b168b31e66ddb9c694e240014104976c79848e18251612f8940875b2b08d06e6dc73b9840e8860c066b7e87432c477e9a59a453e71e6d76d5fe34058b800a098fc1740ce3012e8fc8a00c96af966ffffffff02c0e1e400000000001976a9144134e75a6fcb6042034aab5e18570cf1f844f54788ac404b4c00000000001976a9142b6ba7c9d796b75eef7942fc9288edd37c32f5c388ac00000000"), SER_NETWORK, PROTOCOL_VERSION); + CDataStream stream(ParseHex("040000008e0fd453540d05e9a718b02c4643ad30f56bc76b3ae4339b95cc162d272b064b23f737f85b3e014364614b706e37e032820c9b924cf3496d3dd2f5b267f2aa790000000000000000000000000000000000000000000000000000000000000000974b9857ffff7f200400180af05909e4db334305b55e0876b79eaa64ebdd64d56f8a8b503e99000020080000003301000069000000880000004e000000f6010000d9000000e40000001f00000032010000150100002101000036000000ec010000620000000d0100003d00000078010000df0000004b01000070000000e0010000f1000000e70100006c000000ce0100007e010000e30100006f000000b3000000ba010000bf0100000601000000010000000000000000000000000000000000000000000000000000000000000000ffffffff035c0101ffffffff0256dd9a3b0000000023210262e10da104f17773769ad0bfb03bbb98c51e1389e372fcc528bece7ded083955ac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a491870000000001000000018252cdb4d1d1a7417fb063a09b0fb89318fd8b792d93af80e27b8b477df4738c0000000048473044022068ad43fc1c4fb6d37c369ea2ee4120023380753ed7f01fd349b14d86f34acc4a02202b6852e81505e756781c396e99161e8627933730bb057181b94f3e40cd80a57901feffffff02400d0300000000001976a914c390a7a91a06692d15e50eae443018bae3434a3188ac05b9973b000000001976a91492a07418ce1a941746b22bf51bc5d33e8394cf2688ac0100000001000000019f726046a4fb8c30815afe55fd6799eb898c8948e9605c397294a8f25592fba300000000484730440220116b3265320e4b1dece005978b2194009693e5773496ef51ed599400275abd44022025bcf8e76b1399204b36929f6e6e1266d5dcc7939e45d7cb8334bd42dab4868401feffffff02a03f993b000000001976a914899e43d2889647d3c3eefd741e15c1373a4f895188aca0860100000000001976a914202662c4d7b0164bd21f64d5af99a7fdb6eb0d5d88ac0100000001000000012343cf08fa9ab78c3ed238e76c678efcfa54ed52e496eda7873e019a294eff30000000004847304402201c1b8318cd3f869a0a6e69f0577a27a10f531805330ab17f69d61711ee00ab6902207515fbebace064948eba406b541108fe1ad771c9005f849a97bb82a3212a3aaf01feffffff02557c983b000000001976a914ead7e8b79a77c04fe65cb52b969c0cfcf97d632d88acf0490200000000001976a9148298e83e54bf2b016697b5bdebae79f190bbec5588ac000000000100000001d9ce0f8646d4c5ce03d00250bdefd0c268b902f194b6ac6de9e79010f10ea3d1000000004847304402207f68d9fcb9d2376d7755e5819ba905bd6862839a929dc79e9cf0e2fd56b9ded80220600b7aa879d1bcce4c77561c3f3229fd0fa14cf65247cee9ad62d03eb2580d2401feffffff02f0490200000000001976a9148298e83e54bf2b016697b5bdebae79f190bbec5588ac557c983b000000001976a914a97a3406f9b8f7a3720e5d35ff785e756552084188ac010000000100000001394e4d8af2a70d68d1048a91625289e79bc1f3b6e9627eb83b802e6eec46d47a010000006a473044022044d71071d687954d0a72788121b8f5284fbe39bd34ac7c08824ea3b190fb1ad80220255c7820980fd0e0040fed568f00c200d7b564dc452e7e82b8287bb7d67447450121033f69ce5e46b834ef6ac60b50b0e053fab3f2a41fc8656b73296e91415af85a9ffeffffff02400d0300000000001976a914c390a7a91a06692d15e50eae443018bae3434a3188ac5b694b3b000000001976a9146a9912375a85f2bb9137a1bbcd8dd6517763497088ac01000000"), SER_NETWORK, PROTOCOL_VERSION); stream >> block; CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); // Match the last transaction - filter.insert(uint256S("0x74d681e0e03bafa802c8aa084379aa98d9fcd632ddc2ed9782b586ec87451f20")); + filter.insert(uint256S("0xe9ad9403edde19b31c09a9b5fd6fbbcaaab9e9905906d04b8acd0528671c6172")); CMerkleBlock merkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); @@ -200,17 +205,16 @@ BOOST_AUTO_TEST_CASE(merkle_block_1) BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); pair pair = merkleBlock.vMatchedTxn[0]; - BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x74d681e0e03bafa802c8aa084379aa98d9fcd632ddc2ed9782b586ec87451f20")); - BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 8); - + BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe9ad9403edde19b31c09a9b5fd6fbbcaaab9e9905906d04b8acd0528671c6172")); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 5); vector vMatched; BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched) == block.hashMerkleRoot); BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); for (unsigned int i = 0; i < vMatched.size(); i++) BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); - // Also match the 8th transaction - filter.insert(uint256S("0xdd1fd2a6fc16404faf339881a90adbde7f4f728691ac62e8f168809cdfae1053")); + // Also match the 2nd last + filter.insert(uint256S("0x8282c7e860d707964a7bdeec5adca426195abc60d295189ca505e79038b6d6e5")); merkleBlock = CMerkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); @@ -218,8 +222,8 @@ BOOST_AUTO_TEST_CASE(merkle_block_1) BOOST_CHECK(merkleBlock.vMatchedTxn[1] == pair); - BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xdd1fd2a6fc16404faf339881a90adbde7f4f728691ac62e8f168809cdfae1053")); - BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 7); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x8282c7e860d707964a7bdeec5adca426195abc60d295189ca505e79038b6d6e5")); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 4); BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched) == block.hashMerkleRoot); BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); @@ -227,17 +231,18 @@ BOOST_AUTO_TEST_CASE(merkle_block_1) BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); } + BOOST_AUTO_TEST_CASE(merkle_block_2) { - // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34ae6) - // With 4 txes + // Regtest zcash block 78d1747c76b6e226a141283fa989b7b4b758ef49f6e329b45f1ea927b5b06582 + // With 5 txes CBlock block; - CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29fc051906800000000fe7d5e12ef0ff901f6050211249919b1c0653771832b3a80c66cea42847f0ae1d4d26e49ffff001d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f0a441000401000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d029105ffffffff0100f2052a010000004341046d8709a041d34357697dfcb30a9d05900a6294078012bf3bb09c6f9b525f1d16d5503d7905db1ada9501446ea00728668fc5719aa80be2fdfc8a858a4dbdd4fbac00000000010000000255605dc6f5c3dc148b6da58442b0b2cd422be385eab2ebea4119ee9c268d28350000000049483045022100aa46504baa86df8a33b1192b1b9367b4d729dc41e389f2c04f3e5c7f0559aae702205e82253a54bf5c4f65b7428551554b2045167d6d206dfe6a2e198127d3f7df1501ffffffff55605dc6f5c3dc148b6da58442b0b2cd422be385eab2ebea4119ee9c268d2835010000004847304402202329484c35fa9d6bb32a55a70c0982f606ce0e3634b69006138683bcd12cbb6602200c28feb1e2555c3210f1dddb299738b4ff8bbe9667b68cb8764b5ac17b7adf0001ffffffff0200e1f505000000004341046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0cac00180d8f000000004341044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032cb86a5eb5e56842e92e19141d60a01928f8dd2c875a390f67c1f6c94cfc617c0ea45afac0000000001000000025f9a06d3acdceb56be1bfeaa3e8a25e62d182fa24fefe899d1c17f1dad4c2028000000004847304402205d6058484157235b06028c30736c15613a28bdb768ee628094ca8b0030d4d6eb0220328789c9a2ec27ddaec0ad5ef58efded42e6ea17c2e1ce838f3d6913f5e95db601ffffffff5f9a06d3acdceb56be1bfeaa3e8a25e62d182fa24fefe899d1c17f1dad4c2028010000004a493046022100c45af050d3cea806cedd0ab22520c53ebe63b987b8954146cdca42487b84bdd6022100b9b027716a6b59e640da50a864d6dd8a0ef24c76ce62391fa3eabaf4d2886d2d01ffffffff0200e1f505000000004341046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0cac00180d8f000000004341046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0cac000000000100000002e2274e5fea1bf29d963914bd301aa63b64daaf8a3e88f119b5046ca5738a0f6b0000000048473044022016e7a727a061ea2254a6c358376aaa617ac537eb836c77d646ebda4c748aac8b0220192ce28bf9f2c06a6467e6531e27648d2b3e2e2bae85159c9242939840295ba501ffffffffe2274e5fea1bf29d963914bd301aa63b64daaf8a3e88f119b5046ca5738a0f6b010000004a493046022100b7a1a755588d4190118936e15cd217d133b0e4a53c3c15924010d5648d8925c9022100aaef031874db2114f2d869ac2de4ae53908fbfea5b2b1862e181626bb9005c9f01ffffffff0200e1f505000000004341044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032cb86a5eb5e56842e92e19141d60a01928f8dd2c875a390f67c1f6c94cfc617c0ea45afac00180d8f000000004341046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0cac00000000"), SER_NETWORK, PROTOCOL_VERSION); + CDataStream stream(ParseHex("0400000058d318a0ce55f9f9fda7456c0c608ed68653776010cb6c6dcfc9657641506e1cce61be33285db054c4b3f1f2e069c759e94570e4902bcb0dbe549a39e4d98f6b0000000000000000000000000000000000000000000000000000000000000000a7559857fbff7f2003001c9c71914ce8f872f4dbc7c7d8b1615d6f6a1f78d04e07ceb619f0b700002001000000fd00000036000000f90100002600000058010000420000008301000083000000b8000000050100002301000094000000ab0000000d0100007e010000370000004500000006010000d10100007f000000330100009f010000d501000058000000aa000000a100000057010000b600000002010000be010000e10100000401000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0401150101ffffffff02d4dbd73b00000000232102498e387bed66f7ccd4a039208a46ea3e04680501b7a9c574df38bb2f172cbe0fac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a49187000000000100000001451bb020824ae2d6440576e58e9fa9c58086c547f0168c4cafe10f7b4285cded0000000049483045022100cf73e16190bc1a45451d9e603bb828b7b95f0bbae11865b8917bd3aa55f1699b0220454dce223ce17a266d2d193103bdc403378378a6dc9f0ad763537885fb55c69c01feffffff02567a4e3b000000001976a9146b18cb96f32a92fbeefb7cea7eaf0dd2bf95da3c88ac404b4c00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac0a00000001000000015ad78be5497476bbf84869d8156761ca850b6e82e48ad1315069a3726516a3d1010000006b483045022100ba5e90204e83c5f961b67c6232c1cc6c360afd36d43fcfae0de7af2e75f4cda7022012fec415a12048dbb70511fda6195b090b56735232281dc1144409833a092edc012102c322382e17c9ed4f47183f219cc5dd7853f939fb8eebae3c943622e0abf8d5e5feffffff0280969800000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988acd694693a000000001976a9145f0d00adba6489150808feb4108d7be582cbb2e188ac0a00000001000000012515b752ec3f52282f5ac5272f8d542eb63187739b1bfe672e3af335dba5cf19000000006b4830450221009e496c27d1ec174666da187815407c5b7b4d71ed8935e427a334df6d5d7c9e2c022007ca48eabad68cdec0a7d3be15d64a950bb3d80ac2b988fcd82394064a0a32a0012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cffffffff01808d5b00000000001976a9146d1c88970e614202031a4f2ba13846f8ce91019e88ac00000000"), SER_NETWORK, PROTOCOL_VERSION); stream >> block; CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); // Match the first transaction - filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aecb93b70")); + filter.insert(uint256S("0x2c713883648f44be99ff858b283517f571aa725a4fc032ca52c952fc68058d6e")); CMerkleBlock merkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); @@ -245,7 +250,7 @@ BOOST_AUTO_TEST_CASE(merkle_block_2) BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); pair pair = merkleBlock.vMatchedTxn[0]; - BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aecb93b70")); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x2c713883648f44be99ff858b283517f571aa725a4fc032ca52c952fc68058d6e")); BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); vector vMatched; @@ -254,10 +259,10 @@ BOOST_AUTO_TEST_CASE(merkle_block_2) for (unsigned int i = 0; i < vMatched.size(); i++) BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); - // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T3QvUKBz4qXMRpkg8jsfB5) - // This should match the third transaction because it spends the output matched - // It also matches the fourth transaction, which spends to the pubkey again - filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032cb86a5eb5e56842e92e19141d60a01928f8dd2c875a390f67c1f6c94cfc617c0ea45af")); + // Match an output from the second transaction (the pubkey for address mjuZa8Dy12HKyUNjc1whNTxRaGU4gGGLxY) + // It also matches the third transaction, which spends to the pubkey again + // This should match the last transaction because it spends the output matched + filter.insert(ParseHex("30271a250e92135ce0db0783ebb63aaeb58e47f9")); merkleBlock = CMerkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); @@ -266,13 +271,13 @@ BOOST_AUTO_TEST_CASE(merkle_block_2) BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]); - BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4fa22f182de6258a3eaafe1bbe56ebdcacd3069a5f")); + BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x77a47fdfefde8c91d0e0b14e61f1fd480913d609b7f655152abe14b40f4ffea9")); BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1); - BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x6b0f8a73a56c04b519f1883e8aafda643ba61a30bd1439969df21bea5f4e27e2")); + BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x19cfa5db35f33a2e67fe1b9b738731b62e548d2f27c55a2f28523fec52b71525")); BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2); - BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("0x3c1d7e82342158e4109df2e0b6348b6e84e403d8b4046d7007663ace63cddb23")); + BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("0x1079621bf638e8bea9ee2f8d15287ae31a269969c360006d68d8ee07a7f532e6")); BOOST_CHECK(merkleBlock.vMatchedTxn[3].first == 3); BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched) == block.hashMerkleRoot); @@ -283,15 +288,15 @@ BOOST_AUTO_TEST_CASE(merkle_block_2) BOOST_AUTO_TEST_CASE(merkle_block_2_with_update_none) { - // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34ae6) - // With 4 txes + // Regtest zcash block 78d1747c76b6e226a141283fa989b7b4b758ef49f6e329b45f1ea927b5b06582 + // With 5 txes CBlock block; - CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29fc051906800000000fe7d5e12ef0ff901f6050211249919b1c0653771832b3a80c66cea42847f0ae1d4d26e49ffff001d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f0a441000401000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d029105ffffffff0100f2052a010000004341046d8709a041d34357697dfcb30a9d05900a6294078012bf3bb09c6f9b525f1d16d5503d7905db1ada9501446ea00728668fc5719aa80be2fdfc8a858a4dbdd4fbac00000000010000000255605dc6f5c3dc148b6da58442b0b2cd422be385eab2ebea4119ee9c268d28350000000049483045022100aa46504baa86df8a33b1192b1b9367b4d729dc41e389f2c04f3e5c7f0559aae702205e82253a54bf5c4f65b7428551554b2045167d6d206dfe6a2e198127d3f7df1501ffffffff55605dc6f5c3dc148b6da58442b0b2cd422be385eab2ebea4119ee9c268d2835010000004847304402202329484c35fa9d6bb32a55a70c0982f606ce0e3634b69006138683bcd12cbb6602200c28feb1e2555c3210f1dddb299738b4ff8bbe9667b68cb8764b5ac17b7adf0001ffffffff0200e1f505000000004341046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0cac00180d8f000000004341044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032cb86a5eb5e56842e92e19141d60a01928f8dd2c875a390f67c1f6c94cfc617c0ea45afac0000000001000000025f9a06d3acdceb56be1bfeaa3e8a25e62d182fa24fefe899d1c17f1dad4c2028000000004847304402205d6058484157235b06028c30736c15613a28bdb768ee628094ca8b0030d4d6eb0220328789c9a2ec27ddaec0ad5ef58efded42e6ea17c2e1ce838f3d6913f5e95db601ffffffff5f9a06d3acdceb56be1bfeaa3e8a25e62d182fa24fefe899d1c17f1dad4c2028010000004a493046022100c45af050d3cea806cedd0ab22520c53ebe63b987b8954146cdca42487b84bdd6022100b9b027716a6b59e640da50a864d6dd8a0ef24c76ce62391fa3eabaf4d2886d2d01ffffffff0200e1f505000000004341046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0cac00180d8f000000004341046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0cac000000000100000002e2274e5fea1bf29d963914bd301aa63b64daaf8a3e88f119b5046ca5738a0f6b0000000048473044022016e7a727a061ea2254a6c358376aaa617ac537eb836c77d646ebda4c748aac8b0220192ce28bf9f2c06a6467e6531e27648d2b3e2e2bae85159c9242939840295ba501ffffffffe2274e5fea1bf29d963914bd301aa63b64daaf8a3e88f119b5046ca5738a0f6b010000004a493046022100b7a1a755588d4190118936e15cd217d133b0e4a53c3c15924010d5648d8925c9022100aaef031874db2114f2d869ac2de4ae53908fbfea5b2b1862e181626bb9005c9f01ffffffff0200e1f505000000004341044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032cb86a5eb5e56842e92e19141d60a01928f8dd2c875a390f67c1f6c94cfc617c0ea45afac00180d8f000000004341046a0765b5865641ce08dd39690aade26dfbf5511430ca428a3089261361cef170e3929a68aee3d8d4848b0c5111b0a37b82b86ad559fd2a745b44d8e8d9dfdc0cac00000000"), SER_NETWORK, PROTOCOL_VERSION); + CDataStream stream(ParseHex("0400000058d318a0ce55f9f9fda7456c0c608ed68653776010cb6c6dcfc9657641506e1cce61be33285db054c4b3f1f2e069c759e94570e4902bcb0dbe549a39e4d98f6b0000000000000000000000000000000000000000000000000000000000000000a7559857fbff7f2003001c9c71914ce8f872f4dbc7c7d8b1615d6f6a1f78d04e07ceb619f0b700002001000000fd00000036000000f90100002600000058010000420000008301000083000000b8000000050100002301000094000000ab0000000d0100007e010000370000004500000006010000d10100007f000000330100009f010000d501000058000000aa000000a100000057010000b600000002010000be010000e10100000401000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0401150101ffffffff02d4dbd73b00000000232102498e387bed66f7ccd4a039208a46ea3e04680501b7a9c574df38bb2f172cbe0fac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a49187000000000100000001451bb020824ae2d6440576e58e9fa9c58086c547f0168c4cafe10f7b4285cded0000000049483045022100cf73e16190bc1a45451d9e603bb828b7b95f0bbae11865b8917bd3aa55f1699b0220454dce223ce17a266d2d193103bdc403378378a6dc9f0ad763537885fb55c69c01feffffff02567a4e3b000000001976a9146b18cb96f32a92fbeefb7cea7eaf0dd2bf95da3c88ac404b4c00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac0a00000001000000015ad78be5497476bbf84869d8156761ca850b6e82e48ad1315069a3726516a3d1010000006b483045022100ba5e90204e83c5f961b67c6232c1cc6c360afd36d43fcfae0de7af2e75f4cda7022012fec415a12048dbb70511fda6195b090b56735232281dc1144409833a092edc012102c322382e17c9ed4f47183f219cc5dd7853f939fb8eebae3c943622e0abf8d5e5feffffff0280969800000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988acd694693a000000001976a9145f0d00adba6489150808feb4108d7be582cbb2e188ac0a00000001000000012515b752ec3f52282f5ac5272f8d542eb63187739b1bfe672e3af335dba5cf19000000006b4830450221009e496c27d1ec174666da187815407c5b7b4d71ed8935e427a334df6d5d7c9e2c022007ca48eabad68cdec0a7d3be15d64a950bb3d80ac2b988fcd82394064a0a32a0012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cffffffff01808d5b00000000001976a9146d1c88970e614202031a4f2ba13846f8ce91019e88ac00000000"), SER_NETWORK, PROTOCOL_VERSION); stream >> block; CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); // Match the first transaction - filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aecb93b70")); + filter.insert(uint256S("0x2c713883648f44be99ff858b283517f571aa725a4fc032ca52c952fc68058d6e")); CMerkleBlock merkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); @@ -299,7 +304,7 @@ BOOST_AUTO_TEST_CASE(merkle_block_2_with_update_none) BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); pair pair = merkleBlock.vMatchedTxn[0]; - BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aecb93b70")); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x2c713883648f44be99ff858b283517f571aa725a4fc032ca52c952fc68058d6e")); BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); vector vMatched; @@ -308,10 +313,10 @@ BOOST_AUTO_TEST_CASE(merkle_block_2_with_update_none) for (unsigned int i = 0; i < vMatched.size(); i++) BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); - // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T3QvUKBz4qXMRpkg8jsfB5) - // This should not match the third transaction though it spends the output matched - // It will match the fourth transaction, which has another pay-to-pubkey output to the same address - filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032cb86a5eb5e56842e92e19141d60a01928f8dd2c875a390f67c1f6c94cfc617c0ea45af")); + // Match an output from the second transaction (the pubkey for address mjuZa8Dy12HKyUNjc1whNTxRaGU4gGGLxY) + // It will match the third transaction, which has another pay-to-pubkey output to the same address + // This should not match the last transaction though it spends the output matched + filter.insert(ParseHex("30271a250e92135ce0db0783ebb63aaeb58e47f9")); merkleBlock = CMerkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); @@ -320,11 +325,11 @@ BOOST_AUTO_TEST_CASE(merkle_block_2_with_update_none) BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]); - BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4fa22f182de6258a3eaafe1bbe56ebdcacd3069a5f")); + BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x77a47fdfefde8c91d0e0b14e61f1fd480913d609b7f655152abe14b40f4ffea9")); BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1); - BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x3c1d7e82342158e4109df2e0b6348b6e84e403d8b4046d7007663ace63cddb23")); - BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 3); + BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x19cfa5db35f33a2e67fe1b9b738731b62e548d2f27c55a2f28523fec52b71525")); + BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2); BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched) == block.hashMerkleRoot); BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); @@ -332,24 +337,25 @@ BOOST_AUTO_TEST_CASE(merkle_block_2_with_update_none) BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); } + BOOST_AUTO_TEST_CASE(merkle_block_3_and_serialize) { - // Random real block (000000000000dab0130bbcc991d3d7ae6b81aa6f50a798888dfe62337458dc45) + // Regtest zcash block 528d8fc9ff3bb70e84011c1246eafa2977bce1ce0df29bb4b7512154ff8553a9 // With one tx CBlock block; - CDataStream stream(ParseHex("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b4b8b0000000000000b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f196367291b4d4c86041b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008fa45d63000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff08044c86041b020a02ffffffff0100f2052a01000000434104ecd3229b0571c3be876feaac0442a9f13c5a572742927af1dc623353ecf8c202225f64868137a18cdd85cbbb4c74fbccfd4f49639cf1bdc94a5672bb15ad5d4cac00000000"), SER_NETWORK, PROTOCOL_VERSION); + CDataStream stream(ParseHex("04000000b54044965d52909ff6cfe2b4ce209f2495ec786b075830fc76e1b37f43ecab254dde7891cec6846a10750145c12984a62d2f001e0640cb4b4fac6ceaca1ca0c70000000000000000000000000000000000000000000000000000000000000000fe4c9857ffff7f20030013205b410bb90025f179fdfc1d28fb9902d7d0c11958e349b2911850000020010000000a000000ae000000040100008d00000014010000b5010000d4010000220000003101000050010000c801000053000000d701000026010000ad01000016000000b60000004f000000ac0000004300000045000000c6000000cc0000002c000000d3000000ec000000b9010000ad000000ba000000e0000000d90100000101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff035d0101ffffffff0200ca9a3b0000000023210262e10da104f17773769ad0bfb03bbb98c51e1389e372fcc528bece7ded083955ac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a4918700000000"), SER_NETWORK, PROTOCOL_VERSION); stream >> block; CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); // Match the only transaction - filter.insert(uint256S("0x63194f18be0af63f2c6bc9dc0f777cbefed3d9415c4af83f3ee3a3d669c00cb5")); + filter.insert(uint256S("0xc7a01ccaea6cac4f4bcb40061e002f2da68429c1450175106a84c6ce9178de4d")); CMerkleBlock merkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); - BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x63194f18be0af63f2c6bc9dc0f777cbefed3d9415c4af83f3ee3a3d669c00cb5")); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xc7a01ccaea6cac4f4bcb40061e002f2da68429c1450175106a84c6ce9178de4d")); BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); vector vMatched; @@ -360,27 +366,30 @@ BOOST_AUTO_TEST_CASE(merkle_block_3_and_serialize) CDataStream merkleStream(SER_NETWORK, PROTOCOL_VERSION); merkleStream << merkleBlock; - - vector vch = ParseHex("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b4b8b0000000000000b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f196367291b4d4c86041b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008fa45d63000100000001b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f19630101"); + vector vch = ParseHex("04000000b54044965d52909ff6cfe2b4ce209f2495ec786b075830fc76e1b37f43ecab254dde7891cec6846a10750145c12984a62d2f001e0640cb4b4fac6ceaca1ca0c70000000000000000000000000000000000000000000000000000000000000000fe4c9857ffff7f20030013205b410bb90025f179fdfc1d28fb9902d7d0c11958e349b2911850000020010000000a000000ae000000040100008d00000014010000b5010000d4010000220000003101000050010000c801000053000000d701000026010000ad01000016000000b60000004f000000ac0000004300000045000000c6000000cc0000002c000000d3000000ec000000b9010000ad000000ba000000e0000000d901000001000000014dde7891cec6846a10750145c12984a62d2f001e0640cb4b4fac6ceaca1ca0c70101"); vector expected(vch.size()); for (unsigned int i = 0; i < vch.size(); i++) expected[i] = (char)vch[i]; + // Uncomment this line to print out the merkleBlock +// std::cout << HexStr(merkleStream.begin(), merkleStream.end()) << std::endl; + BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), merkleStream.begin(), merkleStream.end()); } + BOOST_AUTO_TEST_CASE(merkle_block_4) { - // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6dea4) - // With 7 txes + // Regtest zcash block 2af9d3f42301c7411b932268e0ca6dfef3864d2164970dd1dbc351a5a994c988 + // With 6 txes CBlock block; - CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc880670100000000007f16c5962e8bd963659c793ce370d95f093bc7e367117b3c30c1f8fdd0d9728776381b4d4c86041b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000554b8529000701000000010000000000000000000000000000000000000000000000000000000000000000ffffffff07044c86041b0136ffffffff0100f2052a01000000434104eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a2252247d97a46a91ac000000000100000001bcad20a6a29827d1424f08989255120bf7f3e9e3cdaaa6bb31b0737fe048724300000000494830450220356e834b046cadc0f8ebb5a8a017b02de59c86305403dad52cd77b55af062ea10221009253cd6c119d4729b77c978e1e2aa19f5ea6e0e52b3f16e32fa608cd5bab753901ffffffff02008d380c010000001976a9142b4b8072ecbba129b6453c63e129e643207249ca88ac0065cd1d000000001976a9141b8dd13b994bcfc787b32aeadf58ccb3615cbd5488ac000000000100000003fdacf9b3eb077412e7a968d2e4f11b9a9dee312d666187ed77ee7d26af16cb0b000000008c493046022100ea1608e70911ca0de5af51ba57ad23b9a51db8d28f82c53563c56a05c20f5a87022100a8bdc8b4a8acc8634c6b420410150775eb7f2474f5615f7fccd65af30f310fbf01410465fdf49e29b06b9a1582287b6279014f834edc317695d125ef623c1cc3aaece245bd69fcad7508666e9c74a49dc9056d5fc14338ef38118dc4afae5fe2c585caffffffff309e1913634ecb50f3c4f83e96e70b2df071b497b8973a3e75429df397b5af83000000004948304502202bdb79c596a9ffc24e96f4386199aba386e9bc7b6071516e2b51dda942b3a1ed022100c53a857e76b724fc14d45311eac5019650d415c3abb5428f3aae16d8e69bec2301ffffffff2089e33491695080c9edc18a428f7d834db5b6d372df13ce2b1b0e0cbcb1e6c10000000049483045022100d4ce67c5896ee251c810ac1ff9ceccd328b497c8f553ab6e08431e7d40bad6b5022033119c0c2b7d792d31f1187779c7bd95aefd93d90a715586d73801d9b47471c601ffffffff0100714460030000001976a914c7b55141d097ea5df7a0ed330cf794376e53ec8d88ac0000000001000000045bf0e214aa4069a3e792ecee1e1bf0c1d397cde8dd08138f4b72a00681743447000000008b48304502200c45de8c4f3e2c1821f2fc878cba97b1e6f8807d94930713aa1c86a67b9bf1e40221008581abfef2e30f957815fc89978423746b2086375ca8ecf359c85c2a5b7c88ad01410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffffd669f7d7958d40fc59d2253d88e0f248e29b599c80bbcec344a83dda5f9aa72c000000008a473044022078124c8beeaa825f9e0b30bff96e564dd859432f2d0cb3b72d3d5d93d38d7e930220691d233b6c0f995be5acb03d70a7f7a65b6bc9bdd426260f38a1346669507a3601410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95fffffffff878af0d93f5229a68166cf051fd372bb7a537232946e0a46f53636b4dafdaa4000000008c493046022100c717d1714551663f69c3c5759bdbb3a0fcd3fab023abc0e522fe6440de35d8290221008d9cbe25bffc44af2b18e81c58eb37293fd7fe1c2e7b46fc37ee8c96c50ab1e201410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffff27f2b668859cd7f2f894aa0fd2d9e60963bcd07c88973f425f999b8cbfd7a1e2000000008c493046022100e00847147cbf517bcc2f502f3ddc6d284358d102ed20d47a8aa788a62f0db780022100d17b2d6fa84dcaf1c95d88d7e7c30385aecf415588d749afd3ec81f6022cecd701410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffff0100c817a8040000001976a914b6efd80d99179f4f4ff6f4dd0a007d018c385d2188ac000000000100000001834537b2f1ce8ef9373a258e10545ce5a50b758df616cd4356e0032554ebd3c4000000008b483045022100e68f422dd7c34fdce11eeb4509ddae38201773dd62f284e8aa9d96f85099d0b002202243bd399ff96b649a0fad05fa759d6a882f0af8c90cf7632c2840c29070aec20141045e58067e815c2f464c6a2a15f987758374203895710c2d452442e28496ff38ba8f5fd901dc20e29e88477167fe4fc299bf818fd0d9e1632d467b2a3d9503b1aaffffffff0280d7e636030000001976a914f34c3e10eb387efe872acb614c89e78bfca7815d88ac404b4c00000000001976a914a84e272933aaf87e1715d7786c51dfaeb5b65a6f88ac00000000010000000143ac81c8e6f6ef307dfe17f3d906d999e23e0189fda838c5510d850927e03ae7000000008c4930460221009c87c344760a64cb8ae6685a3eec2c1ac1bed5b88c87de51acd0e124f266c16602210082d07c037359c3a257b5c63ebd90f5a5edf97b2ac1c434b08ca998839f346dd40141040ba7e521fa7946d12edbb1d1e95a15c34bd4398195e86433c92b431cd315f455fe30032ede69cad9d1e1ed6c3c4ec0dbfced53438c625462afb792dcb098544bffffffff0240420f00000000001976a9144676d1b820d63ec272f1900d59d43bc6463d96f888ac40420f00000000001976a914648d04341d00d7968b3405c034adc38d4d8fb9bd88ac00000000010000000248cc917501ea5c55f4a8d2009c0567c40cfe037c2e71af017d0a452ff705e3f1000000008b483045022100bf5fdc86dc5f08a5d5c8e43a8c9d5b1ed8c65562e280007b52b133021acd9acc02205e325d613e555f772802bf413d36ba807892ed1a690a77811d3033b3de226e0a01410429fa713b124484cb2bd7b5557b2c0b9df7b2b1fee61825eadc5ae6c37a9920d38bfccdc7dc3cb0c47d7b173dbc9db8d37db0a33ae487982c59c6f8606e9d1791ffffffff41ed70551dd7e841883ab8f0b16bf04176b7d1480e4f0af9f3d4c3595768d068000000008b4830450221008513ad65187b903aed1102d1d0c47688127658c51106753fed0151ce9c16b80902201432b9ebcb87bd04ceb2de66035fbbaf4bf8b00d1cfe41f1a1f7338f9ad79d210141049d4cf80125bf50be1709f718c07ad15d0fc612b7da1f5570dddc35f2a352f0f27c978b06820edca9ef982c35fda2d255afba340068c5035552368bc7200c1488ffffffff0100093d00000000001976a9148edb68822f1ad580b043c7b3df2e400f8699eb4888ac00000000"), SER_NETWORK, PROTOCOL_VERSION); + CDataStream stream(ParseHex("04000000ceafe737af74e90fd22ba542d7fe3cd149d8724e4820ae94d1478b056d2ada166ecd34e2c9cf6458b6dc1e88d6ebbeb68cf61976398d2e25e7af12bdfb9e80b30000000000000000000000000000000000000000000000000000000000000000fa589857feff7f200100766220c3fb1793605fcfa671397bed77091d27090840c09c6c90cddb000020250000003c0100005f0100009a01000048000000e60100006b010000bc010000470000003b0100008300000001010000c800000020010000d1000000b601000034000000080100003d0000004b0000003a000000a900000094000000da010000530000008000000096000000a4010000b700000002010000c1000000d70000000601000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0401170101ffffffff024ce29a3b000000002321021046035a4c9cf071676bbb2cafdccf8cdc7b67af239132992273ad53b3c23488ac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a491870000000001000000012bef176bd090bad3344e609e17b1e7b3be71b5e45a4809c917f94a61c8e992060000000049483045022100d2a72fa35d3e8737879d6dd964e5e5704b146871d946d46098edd59ab3415ed00220568bb41fb34f17db1fa609257b4fd04ffb0e35b41d43d288e5576e774f63bfda01feffffff0200848b3b000000001976a914baa161d9bd51f624ff4db28e3f00179c572e18cf88ac40420f00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac0c0000000100000001a9fe4f0fb414be2a1555f6b709d6130948fdf1614eb1e0d0918cdeefdf7fa477000000006a47304402201316590dc69641d6c2c31c89b4434c214be5ffa58f8c7488123edb084aa7e72b02205eb24de0dd8dbe872d1221c4aad477f63988d5497b19ec5950ea1285cf3fb915012103e138ca8f557bbfa4260a15d79b849f92430f507c6631703a9c5e35822e9d952ffeffffff026cf12f3b000000001976a91409c106c79fa392733402b3f37c7fa4523158fbdf88ac80841e00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac0c00000001000000012515b752ec3f52282f5ac5272f8d542eb63187739b1bfe672e3af335dba5cf19010000006a473044022075f197b8d4df09e85b97b3aaeaaf0584ebdfc6b3bdc2743abfe4e573f68dea8002201850c7b96ec1593091d95377e8d7acc005032dce356325547bfb66bcca95d137012103ef486cc2238f19830e7761f015fbfd7df29699c13759abdaa883d78091c8b46dfeffffff02acc93b3a000000001976a914ec7dc17fd971f1d3341a064cf9f40c120075ebe488acc0c62d00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac000000000100000002a9fe4f0fb414be2a1555f6b709d6130948fdf1614eb1e0d0918cdeefdf7fa477010000006b483045022100e43bdeeb6c46a6f6cfc04f4c7365c899d73bab617da50be62ddeaaf8773ee6b4022040d292378e87892711e866fde87fcb9781caede32081e0d8d2ad88c4bf8787ed012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cfeffffffe632f5a707eed8686d0060c36999261ae37a28158d2feea9bee838f61b627910000000006a4730440220179282f7f2298b1cdf369f5e36fd0380fdbc47e9b6c5b335d45d4734dc463448022030ec39229fc0daaf52ac6d96cfb739b6a59c880a811a933cb8994e5f5b08a4c80121038b35ef477570faed211a1f119441864d41b014a8a6475aad660c2961f8eb03a7feffffff02404b4c00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac32865b00000000001976a914f5ca46c06a8ee7653ba4c16c392db42d1e2ed3c388ac0c0000000100000001d4766c87e4f552823eea2d7ab989660605e62eb05a6d2b5ad43b36ae4f557c15000000006b4830450221009b226907cab7113b909b020049110c54c295bd693c0650fe6ed75acbc8dc276f02204981fab2548805f1922c1e2929aa2d1072a21cd15f6d2823897cbc5a0986f517012103716c8473f87f1212caf9aa5150cbc16b5059c9a416cd4606149693d3bd477442feffffff0200093d00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac16801e00000000001976a9149ded6f93a3a2b4f67a30ff30f10f5449ce63713488ac0c000000"), SER_NETWORK, PROTOCOL_VERSION); stream >> block; CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); // Match the last transaction - filter.insert(uint256S("0x0a2a92f0bda4727d0a13eaddf4dd9ac6b5c61a1429e6b2b818f19b15df0ac154")); + filter.insert(uint256S("0xc10fa281cd5d2261a66875ee397b968881e3046e81b7792bcd2c2f9036a3dffa")); CMerkleBlock merkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); @@ -388,8 +397,8 @@ BOOST_AUTO_TEST_CASE(merkle_block_4) BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); pair pair = merkleBlock.vMatchedTxn[0]; - BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x0a2a92f0bda4727d0a13eaddf4dd9ac6b5c61a1429e6b2b818f19b15df0ac154")); - BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 6); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xc10fa281cd5d2261a66875ee397b968881e3046e81b7792bcd2c2f9036a3dffa")); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 5); vector vMatched; BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched) == block.hashMerkleRoot); @@ -398,13 +407,13 @@ BOOST_AUTO_TEST_CASE(merkle_block_4) BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); // Also match the 4th transaction - filter.insert(uint256S("0x02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041")); + filter.insert(uint256S("0xd2f48bd2d3ec3679f2af0c79e2ad292fb84987f521704ef10bb9de8e1c50e687")); merkleBlock = CMerkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 2); - BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041")); + BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xd2f48bd2d3ec3679f2af0c79e2ad292fb84987f521704ef10bb9de8e1c50e687")); BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 3); BOOST_CHECK(merkleBlock.vMatchedTxn[1] == pair); @@ -417,47 +426,47 @@ BOOST_AUTO_TEST_CASE(merkle_block_4) BOOST_AUTO_TEST_CASE(merkle_block_4_test_p2pubkey_only) { - // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6dea4) - // With 7 txes + // Regtest zcash block 2af9d3f42301c7411b932268e0ca6dfef3864d2164970dd1dbc351a5a994c988 + // With 6 txes CBlock block; - CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc880670100000000007f16c5962e8bd963659c793ce370d95f093bc7e367117b3c30c1f8fdd0d9728776381b4d4c86041b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000554b8529000701000000010000000000000000000000000000000000000000000000000000000000000000ffffffff07044c86041b0136ffffffff0100f2052a01000000434104eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a2252247d97a46a91ac000000000100000001bcad20a6a29827d1424f08989255120bf7f3e9e3cdaaa6bb31b0737fe048724300000000494830450220356e834b046cadc0f8ebb5a8a017b02de59c86305403dad52cd77b55af062ea10221009253cd6c119d4729b77c978e1e2aa19f5ea6e0e52b3f16e32fa608cd5bab753901ffffffff02008d380c010000001976a9142b4b8072ecbba129b6453c63e129e643207249ca88ac0065cd1d000000001976a9141b8dd13b994bcfc787b32aeadf58ccb3615cbd5488ac000000000100000003fdacf9b3eb077412e7a968d2e4f11b9a9dee312d666187ed77ee7d26af16cb0b000000008c493046022100ea1608e70911ca0de5af51ba57ad23b9a51db8d28f82c53563c56a05c20f5a87022100a8bdc8b4a8acc8634c6b420410150775eb7f2474f5615f7fccd65af30f310fbf01410465fdf49e29b06b9a1582287b6279014f834edc317695d125ef623c1cc3aaece245bd69fcad7508666e9c74a49dc9056d5fc14338ef38118dc4afae5fe2c585caffffffff309e1913634ecb50f3c4f83e96e70b2df071b497b8973a3e75429df397b5af83000000004948304502202bdb79c596a9ffc24e96f4386199aba386e9bc7b6071516e2b51dda942b3a1ed022100c53a857e76b724fc14d45311eac5019650d415c3abb5428f3aae16d8e69bec2301ffffffff2089e33491695080c9edc18a428f7d834db5b6d372df13ce2b1b0e0cbcb1e6c10000000049483045022100d4ce67c5896ee251c810ac1ff9ceccd328b497c8f553ab6e08431e7d40bad6b5022033119c0c2b7d792d31f1187779c7bd95aefd93d90a715586d73801d9b47471c601ffffffff0100714460030000001976a914c7b55141d097ea5df7a0ed330cf794376e53ec8d88ac0000000001000000045bf0e214aa4069a3e792ecee1e1bf0c1d397cde8dd08138f4b72a00681743447000000008b48304502200c45de8c4f3e2c1821f2fc878cba97b1e6f8807d94930713aa1c86a67b9bf1e40221008581abfef2e30f957815fc89978423746b2086375ca8ecf359c85c2a5b7c88ad01410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffffd669f7d7958d40fc59d2253d88e0f248e29b599c80bbcec344a83dda5f9aa72c000000008a473044022078124c8beeaa825f9e0b30bff96e564dd859432f2d0cb3b72d3d5d93d38d7e930220691d233b6c0f995be5acb03d70a7f7a65b6bc9bdd426260f38a1346669507a3601410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95fffffffff878af0d93f5229a68166cf051fd372bb7a537232946e0a46f53636b4dafdaa4000000008c493046022100c717d1714551663f69c3c5759bdbb3a0fcd3fab023abc0e522fe6440de35d8290221008d9cbe25bffc44af2b18e81c58eb37293fd7fe1c2e7b46fc37ee8c96c50ab1e201410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffff27f2b668859cd7f2f894aa0fd2d9e60963bcd07c88973f425f999b8cbfd7a1e2000000008c493046022100e00847147cbf517bcc2f502f3ddc6d284358d102ed20d47a8aa788a62f0db780022100d17b2d6fa84dcaf1c95d88d7e7c30385aecf415588d749afd3ec81f6022cecd701410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffff0100c817a8040000001976a914b6efd80d99179f4f4ff6f4dd0a007d018c385d2188ac000000000100000001834537b2f1ce8ef9373a258e10545ce5a50b758df616cd4356e0032554ebd3c4000000008b483045022100e68f422dd7c34fdce11eeb4509ddae38201773dd62f284e8aa9d96f85099d0b002202243bd399ff96b649a0fad05fa759d6a882f0af8c90cf7632c2840c29070aec20141045e58067e815c2f464c6a2a15f987758374203895710c2d452442e28496ff38ba8f5fd901dc20e29e88477167fe4fc299bf818fd0d9e1632d467b2a3d9503b1aaffffffff0280d7e636030000001976a914f34c3e10eb387efe872acb614c89e78bfca7815d88ac404b4c00000000001976a914a84e272933aaf87e1715d7786c51dfaeb5b65a6f88ac00000000010000000143ac81c8e6f6ef307dfe17f3d906d999e23e0189fda838c5510d850927e03ae7000000008c4930460221009c87c344760a64cb8ae6685a3eec2c1ac1bed5b88c87de51acd0e124f266c16602210082d07c037359c3a257b5c63ebd90f5a5edf97b2ac1c434b08ca998839f346dd40141040ba7e521fa7946d12edbb1d1e95a15c34bd4398195e86433c92b431cd315f455fe30032ede69cad9d1e1ed6c3c4ec0dbfced53438c625462afb792dcb098544bffffffff0240420f00000000001976a9144676d1b820d63ec272f1900d59d43bc6463d96f888ac40420f00000000001976a914648d04341d00d7968b3405c034adc38d4d8fb9bd88ac00000000010000000248cc917501ea5c55f4a8d2009c0567c40cfe037c2e71af017d0a452ff705e3f1000000008b483045022100bf5fdc86dc5f08a5d5c8e43a8c9d5b1ed8c65562e280007b52b133021acd9acc02205e325d613e555f772802bf413d36ba807892ed1a690a77811d3033b3de226e0a01410429fa713b124484cb2bd7b5557b2c0b9df7b2b1fee61825eadc5ae6c37a9920d38bfccdc7dc3cb0c47d7b173dbc9db8d37db0a33ae487982c59c6f8606e9d1791ffffffff41ed70551dd7e841883ab8f0b16bf04176b7d1480e4f0af9f3d4c3595768d068000000008b4830450221008513ad65187b903aed1102d1d0c47688127658c51106753fed0151ce9c16b80902201432b9ebcb87bd04ceb2de66035fbbaf4bf8b00d1cfe41f1a1f7338f9ad79d210141049d4cf80125bf50be1709f718c07ad15d0fc612b7da1f5570dddc35f2a352f0f27c978b06820edca9ef982c35fda2d255afba340068c5035552368bc7200c1488ffffffff0100093d00000000001976a9148edb68822f1ad580b043c7b3df2e400f8699eb4888ac00000000"), SER_NETWORK, PROTOCOL_VERSION); + CDataStream stream(ParseHex("04000000ceafe737af74e90fd22ba542d7fe3cd149d8724e4820ae94d1478b056d2ada166ecd34e2c9cf6458b6dc1e88d6ebbeb68cf61976398d2e25e7af12bdfb9e80b30000000000000000000000000000000000000000000000000000000000000000fa589857feff7f200100766220c3fb1793605fcfa671397bed77091d27090840c09c6c90cddb000020250000003c0100005f0100009a01000048000000e60100006b010000bc010000470000003b0100008300000001010000c800000020010000d1000000b601000034000000080100003d0000004b0000003a000000a900000094000000da010000530000008000000096000000a4010000b700000002010000c1000000d70000000601000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0401170101ffffffff024ce29a3b000000002321021046035a4c9cf071676bbb2cafdccf8cdc7b67af239132992273ad53b3c23488ac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a491870000000001000000012bef176bd090bad3344e609e17b1e7b3be71b5e45a4809c917f94a61c8e992060000000049483045022100d2a72fa35d3e8737879d6dd964e5e5704b146871d946d46098edd59ab3415ed00220568bb41fb34f17db1fa609257b4fd04ffb0e35b41d43d288e5576e774f63bfda01feffffff0200848b3b000000001976a914baa161d9bd51f624ff4db28e3f00179c572e18cf88ac40420f00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac0c0000000100000001a9fe4f0fb414be2a1555f6b709d6130948fdf1614eb1e0d0918cdeefdf7fa477000000006a47304402201316590dc69641d6c2c31c89b4434c214be5ffa58f8c7488123edb084aa7e72b02205eb24de0dd8dbe872d1221c4aad477f63988d5497b19ec5950ea1285cf3fb915012103e138ca8f557bbfa4260a15d79b849f92430f507c6631703a9c5e35822e9d952ffeffffff026cf12f3b000000001976a91409c106c79fa392733402b3f37c7fa4523158fbdf88ac80841e00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac0c00000001000000012515b752ec3f52282f5ac5272f8d542eb63187739b1bfe672e3af335dba5cf19010000006a473044022075f197b8d4df09e85b97b3aaeaaf0584ebdfc6b3bdc2743abfe4e573f68dea8002201850c7b96ec1593091d95377e8d7acc005032dce356325547bfb66bcca95d137012103ef486cc2238f19830e7761f015fbfd7df29699c13759abdaa883d78091c8b46dfeffffff02acc93b3a000000001976a914ec7dc17fd971f1d3341a064cf9f40c120075ebe488acc0c62d00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac000000000100000002a9fe4f0fb414be2a1555f6b709d6130948fdf1614eb1e0d0918cdeefdf7fa477010000006b483045022100e43bdeeb6c46a6f6cfc04f4c7365c899d73bab617da50be62ddeaaf8773ee6b4022040d292378e87892711e866fde87fcb9781caede32081e0d8d2ad88c4bf8787ed012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cfeffffffe632f5a707eed8686d0060c36999261ae37a28158d2feea9bee838f61b627910000000006a4730440220179282f7f2298b1cdf369f5e36fd0380fdbc47e9b6c5b335d45d4734dc463448022030ec39229fc0daaf52ac6d96cfb739b6a59c880a811a933cb8994e5f5b08a4c80121038b35ef477570faed211a1f119441864d41b014a8a6475aad660c2961f8eb03a7feffffff02404b4c00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac32865b00000000001976a914f5ca46c06a8ee7653ba4c16c392db42d1e2ed3c388ac0c0000000100000001d4766c87e4f552823eea2d7ab989660605e62eb05a6d2b5ad43b36ae4f557c15000000006b4830450221009b226907cab7113b909b020049110c54c295bd693c0650fe6ed75acbc8dc276f02204981fab2548805f1922c1e2929aa2d1072a21cd15f6d2823897cbc5a0986f517012103716c8473f87f1212caf9aa5150cbc16b5059c9a416cd4606149693d3bd477442feffffff0200093d00000000001976a91430271a250e92135ce0db0783ebb63aaeb58e47f988ac16801e00000000001976a9149ded6f93a3a2b4f67a30ff30f10f5449ce63713488ac0c000000"), SER_NETWORK, PROTOCOL_VERSION); stream >> block; CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_P2PUBKEY_ONLY); - // Match the generation pubkey - filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a2252247d97a46a91")); + // Match the generation pubkey (coinbase tx output scriptpubkey) + filter.insert(ParseHex("021046035a4c9cf071676bbb2cafdccf8cdc7b67af239132992273ad53b3c23488")); // ...and the output address of the 4th transaction - filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21")); + filter.insert(ParseHex("30271a250e92135ce0db0783ebb63aaeb58e47f9")); CMerkleBlock merkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); - // We should match the generation outpoint - BOOST_CHECK(filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b"), 0))); - // ... but not the 4th transaction's output (its not pay-2-pubkey) - BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041"), 0))); + // We should match the generation outpoint (coinbase tx txid) + BOOST_CHECK(filter.contains(COutPoint(uint256S("0x760d72ad023855ab213b2be97844b8e56be314510f619a7d647a6ec541f724c3"), 0))); + // ... but not the 4th transaction's output (its not pay-2-pubkey) (the 4th tx's txid) + BOOST_CHECK(!filter.contains(COutPoint(uint256S("d2f48bd2d3ec3679f2af0c79e2ad292fb84987f521704ef10bb9de8e1c50e687"), 0))); } BOOST_AUTO_TEST_CASE(merkle_block_4_test_update_none) { - // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6dea4) + // Regtest zcash block 0c54eb9bf064c28342e030e940364b1379b0a63a81434d0bbc0246f8ebc1112d // With 7 txes CBlock block; - CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc880670100000000007f16c5962e8bd963659c793ce370d95f093bc7e367117b3c30c1f8fdd0d9728776381b4d4c86041b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000554b8529000701000000010000000000000000000000000000000000000000000000000000000000000000ffffffff07044c86041b0136ffffffff0100f2052a01000000434104eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a2252247d97a46a91ac000000000100000001bcad20a6a29827d1424f08989255120bf7f3e9e3cdaaa6bb31b0737fe048724300000000494830450220356e834b046cadc0f8ebb5a8a017b02de59c86305403dad52cd77b55af062ea10221009253cd6c119d4729b77c978e1e2aa19f5ea6e0e52b3f16e32fa608cd5bab753901ffffffff02008d380c010000001976a9142b4b8072ecbba129b6453c63e129e643207249ca88ac0065cd1d000000001976a9141b8dd13b994bcfc787b32aeadf58ccb3615cbd5488ac000000000100000003fdacf9b3eb077412e7a968d2e4f11b9a9dee312d666187ed77ee7d26af16cb0b000000008c493046022100ea1608e70911ca0de5af51ba57ad23b9a51db8d28f82c53563c56a05c20f5a87022100a8bdc8b4a8acc8634c6b420410150775eb7f2474f5615f7fccd65af30f310fbf01410465fdf49e29b06b9a1582287b6279014f834edc317695d125ef623c1cc3aaece245bd69fcad7508666e9c74a49dc9056d5fc14338ef38118dc4afae5fe2c585caffffffff309e1913634ecb50f3c4f83e96e70b2df071b497b8973a3e75429df397b5af83000000004948304502202bdb79c596a9ffc24e96f4386199aba386e9bc7b6071516e2b51dda942b3a1ed022100c53a857e76b724fc14d45311eac5019650d415c3abb5428f3aae16d8e69bec2301ffffffff2089e33491695080c9edc18a428f7d834db5b6d372df13ce2b1b0e0cbcb1e6c10000000049483045022100d4ce67c5896ee251c810ac1ff9ceccd328b497c8f553ab6e08431e7d40bad6b5022033119c0c2b7d792d31f1187779c7bd95aefd93d90a715586d73801d9b47471c601ffffffff0100714460030000001976a914c7b55141d097ea5df7a0ed330cf794376e53ec8d88ac0000000001000000045bf0e214aa4069a3e792ecee1e1bf0c1d397cde8dd08138f4b72a00681743447000000008b48304502200c45de8c4f3e2c1821f2fc878cba97b1e6f8807d94930713aa1c86a67b9bf1e40221008581abfef2e30f957815fc89978423746b2086375ca8ecf359c85c2a5b7c88ad01410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffffd669f7d7958d40fc59d2253d88e0f248e29b599c80bbcec344a83dda5f9aa72c000000008a473044022078124c8beeaa825f9e0b30bff96e564dd859432f2d0cb3b72d3d5d93d38d7e930220691d233b6c0f995be5acb03d70a7f7a65b6bc9bdd426260f38a1346669507a3601410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95fffffffff878af0d93f5229a68166cf051fd372bb7a537232946e0a46f53636b4dafdaa4000000008c493046022100c717d1714551663f69c3c5759bdbb3a0fcd3fab023abc0e522fe6440de35d8290221008d9cbe25bffc44af2b18e81c58eb37293fd7fe1c2e7b46fc37ee8c96c50ab1e201410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffff27f2b668859cd7f2f894aa0fd2d9e60963bcd07c88973f425f999b8cbfd7a1e2000000008c493046022100e00847147cbf517bcc2f502f3ddc6d284358d102ed20d47a8aa788a62f0db780022100d17b2d6fa84dcaf1c95d88d7e7c30385aecf415588d749afd3ec81f6022cecd701410462bb73f76ca0994fcb8b4271e6fb7561f5c0f9ca0cf6485261c4a0dc894f4ab844c6cdfb97cd0b60ffb5018ffd6238f4d87270efb1d3ae37079b794a92d7ec95ffffffff0100c817a8040000001976a914b6efd80d99179f4f4ff6f4dd0a007d018c385d2188ac000000000100000001834537b2f1ce8ef9373a258e10545ce5a50b758df616cd4356e0032554ebd3c4000000008b483045022100e68f422dd7c34fdce11eeb4509ddae38201773dd62f284e8aa9d96f85099d0b002202243bd399ff96b649a0fad05fa759d6a882f0af8c90cf7632c2840c29070aec20141045e58067e815c2f464c6a2a15f987758374203895710c2d452442e28496ff38ba8f5fd901dc20e29e88477167fe4fc299bf818fd0d9e1632d467b2a3d9503b1aaffffffff0280d7e636030000001976a914f34c3e10eb387efe872acb614c89e78bfca7815d88ac404b4c00000000001976a914a84e272933aaf87e1715d7786c51dfaeb5b65a6f88ac00000000010000000143ac81c8e6f6ef307dfe17f3d906d999e23e0189fda838c5510d850927e03ae7000000008c4930460221009c87c344760a64cb8ae6685a3eec2c1ac1bed5b88c87de51acd0e124f266c16602210082d07c037359c3a257b5c63ebd90f5a5edf97b2ac1c434b08ca998839f346dd40141040ba7e521fa7946d12edbb1d1e95a15c34bd4398195e86433c92b431cd315f455fe30032ede69cad9d1e1ed6c3c4ec0dbfced53438c625462afb792dcb098544bffffffff0240420f00000000001976a9144676d1b820d63ec272f1900d59d43bc6463d96f888ac40420f00000000001976a914648d04341d00d7968b3405c034adc38d4d8fb9bd88ac00000000010000000248cc917501ea5c55f4a8d2009c0567c40cfe037c2e71af017d0a452ff705e3f1000000008b483045022100bf5fdc86dc5f08a5d5c8e43a8c9d5b1ed8c65562e280007b52b133021acd9acc02205e325d613e555f772802bf413d36ba807892ed1a690a77811d3033b3de226e0a01410429fa713b124484cb2bd7b5557b2c0b9df7b2b1fee61825eadc5ae6c37a9920d38bfccdc7dc3cb0c47d7b173dbc9db8d37db0a33ae487982c59c6f8606e9d1791ffffffff41ed70551dd7e841883ab8f0b16bf04176b7d1480e4f0af9f3d4c3595768d068000000008b4830450221008513ad65187b903aed1102d1d0c47688127658c51106753fed0151ce9c16b80902201432b9ebcb87bd04ceb2de66035fbbaf4bf8b00d1cfe41f1a1f7338f9ad79d210141049d4cf80125bf50be1709f718c07ad15d0fc612b7da1f5570dddc35f2a352f0f27c978b06820edca9ef982c35fda2d255afba340068c5035552368bc7200c1488ffffffff0100093d00000000001976a9148edb68822f1ad580b043c7b3df2e400f8699eb4888ac00000000"), SER_NETWORK, PROTOCOL_VERSION); + CDataStream stream(ParseHex("04000000e1bf965fddae55b8e781877a939425f839e788959f9fbc72b81aef757848d1558f8f11f4bedfde1217f4b6f96fc9a91d0331386d0e01ea98eeccf03f9a6b35d50000000000000000000000000000000000000000000000000000000000000000005d9857feff7f200100e93d380bd116212dfc1d41e78e4df3d32d275d00d4f79808bbb884d30000201b00000051010000c1000000a1010000650000007a01000099000000b101000056000000700100008d0000007e01000076000000f70100009b010000fe010000260000000a0100008b000000430100002900000093010000a5000000d20000002a000000970000005e0000004601000080000000010100008c000000e70000000701000000010000000000000000000000000000000000000000000000000000000000000000ffffffff04011a0101ffffffff0283f19a3b00000000232102ce609e4c9c1ce8c86b5732cc71879d93d57bdcd78082cffb77bfa5c24c10dc50ac80b2e60e0000000017a9146708e6670db0b950dac68031025cc5b63213a49187000000000100000001c23c131d2130af5157aac9b378b5a2af8e02d6e9be91f2b3cb770731a62e698f000000004847304402204a0b8d78f2ab6b2c91e7e532c2344b064c13e3c198bb8c9e2613f796d028cb8b022040b8ad89ac9e7fa7b803dfe361f8af3681e89246f5f97aa6f5b49555d1f5ab7801feffffff02403f0738000000001976a91447568c26a8bdfa77a9253ed2036724f0b2c1fe5f88ac00879303000000001976a914640bac400ad1fecc1391b6f1536924a28e61907d88ac0f0000000100000001824d5f206ecb4d82fe4e7a3a10fe0b4186b0111298529d6d705a9bf56441a66d00000000494830450221009e1b7e896bdea8592040a9b2d40060b5c7440ff8adbe6fe2ce4a9ef003771058022013ef290a725f44147fb01c083ba7b7997f4c2675bdeccc107784cfc86b0f800b01feffffff0280969800000000001976a914640bac400ad1fecc1391b6f1536924a28e61907d88acc02f023b000000001976a914a6e9f40a37e4f1bc0f196cc8b8ee387e936e934488ac0f00000001000000017453c9e5a088cb04e40ef59abd459156da3288998b82589ee888c556f74573a4000000006a473044022036be899b55d10fbef581a392a813c9ea25fdbfa577d1e8d8b50c91a39b3d2d050220208f3356f8c599e62486fa67f300629aabba8a9c57a1feb63cfcf8d0197c97620121033506b92281f803dcfab4aedad1cbc4d0617499c55bda8a8704eb1add18e89235feffffff0296252939000000001976a914abc8feb974411a2307badee01e384641d49c186488ac005a6202000000001976a914640bac400ad1fecc1391b6f1536924a28e61907d88ac0f0000000100000006ef2f1a8d0ab669daa867c61aaa5446587c685a0a29933a29e3f68947ac9c31ff000000006a473044022069b9dc8e8321b51701f0e4ad74715e9a1928e7b4925d66eb060bcf7674092d1a0220417a26ed0e01c2167cbabfc5dec1a50099d77c666ae04cb3ccd493355830f802012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cfeffffffef2f1a8d0ab669daa867c61aaa5446587c685a0a29933a29e3f68947ac9c31ff010000006a473044022078ba511e4c3bd22c66104d4380f553af4a318438da50340fa85e1bb7781a98d3022076022f343a883617be8b84c51127d081d9f533381108343abcc71546b9f05579012102498e387bed66f7ccd4a039208a46ea3e04680501b7a9c574df38bb2f172cbe0ffeffffff22e2702586c53ab876e350837d537cfbe2eda625e90c56bc6ac402e1ba2638cc010000006b483045022100e7e385d8cc3abd1f4d9d2bb2ee53ec75f1cc3aefdaae2e8fb2260d64b52ef2700220155ee4eb5352df0ecf6477ec39588da85983d17b07f8687878727acea9137617012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cfefffffffadfa336902f2ccd2b79b7816e04e38188967b39ee7568a661225dcd81a20fc1000000006a4730440220166afc981f529ec240a9c76fd1a13f5266b49462c0d3b28370aa81f34f9de3d90220062b0579b6bae54b03e2606e3fc2c493a6b827884fe6b609e7871ee808675ca8012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cfefffffffadfa336902f2ccd2b79b7816e04e38188967b39ee7568a661225dcd81a20fc1010000006a4730440220619df55063805d43bc046f710db900fbfe28ac5194aa3ad377a88765e119460a02205407f3f8272469fad59b0ab2b00c5c373aa35ccf0411040d977b58db9f39fea6012103322175384bd15072c75bc7c1bc0fa5e5595895cb3b8fd179b2b24746b673f5f6feffffff87e6501c8edeb90bf14e7021f58749b82f29ade2790caff27936ecd3d28bf4d2010000006a47304402204b84bf98244adb41dd739285513bcf50007875021257a821f9ae57991eb12cd102203fde9f5076f8dbf65ada8fc1e5ab46df3dba8d7621664cea3b84688a3a4b85d2012102afe67a769ff6a19f6a227b05d7e1a6b0a2e6851481c8c92f232979d33bb2bc0cfeffffff02fe651e00000000001976a91441ec7511554c71640aea061e628067f3db3aafd088ac002d3101000000001976a914640bac400ad1fecc1391b6f1536924a28e61907d88ac0f000000010000000122e2702586c53ab876e350837d537cfbe2eda625e90c56bc6ac402e1ba2638cc000000006a4730440220054c70db6a2433e3d94a43f5f198a05eca9b44b4f0763ae78b5bc70b08d52eb10220103062e40bfbd270117b5cca182098d143fedb44b572df912fe04798afba409e012102343107eef41bde463901d99c3011c9be972c9077a0c4c5897bb63eda936f8c74feffffff0287296639000000001976a914fe850141a91ae3eb661d8f425284ba2e3a03af2188ac80c3c901000000001976a914640bac400ad1fecc1391b6f1536924a28e61907d88ac0f000000010000000187e6501c8edeb90bf14e7021f58749b82f29ade2790caff27936ecd3d28bf4d2000000006b48304502210081c47f61994bc0999a2bbaefb7ebf625421793025e981564cf50dfa517791960022037d28ed35e2764ab8a5f579c5cfc7eb66dc246aebcb312f683baa82f49f6e492012102fe844d4520021d8f54985995fd57565139ee832b47dcec52106dbcdd928acf6efeffffff02c2d44037000000001976a914236bffa399b69dadbbbe662b59f3ca16327d68b288ac80f0fa02000000001976a914640bac400ad1fecc1391b6f1536924a28e61907d88ac0f000000"), SER_NETWORK, PROTOCOL_VERSION); stream >> block; CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); - // Match the generation pubkey - filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2c01ec0f0dd5b2e86e7168cefe0d81113c3807420ce13ad1357231a2252247d97a46a91")); + // Match the generation pubkey (coinbase tx output script) + filter.insert(ParseHex("02ce609e4c9c1ce8c86b5732cc71879d93d57bdcd78082cffb77bfa5c24c10dc50")); // ...and the output address of the 4th transaction - filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21")); + filter.insert(ParseHex("640bac400ad1fecc1391b6f1536924a28e61907d")); CMerkleBlock merkleBlock(block, filter); BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); // We shouldn't match any outpoints (UPDATE_NONE) - BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b86c7765e489f7a6ff3360fe5c674360b"), 0))); - BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df5bc041"), 0))); + BOOST_CHECK(!filter.contains(COutPoint(uint256S("0xc234ca41d97fc9da0312899aedff68d71d02dfb0533af97992868772030f028f"), 0))); + BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x2551b7b6108a633db54c3df7aff09295561fcc2b5b0438b602e5c17deb1d128e"), 0))); } static std::vector RandomData() diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 695a8b05d..77fb3f3b5 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -504,7 +504,7 @@ BOOST_AUTO_TEST_CASE(coins_coinbase_spends) // Create coinbase spend CMutableTransaction mtx2; mtx2.vin.resize(1); - mtx2.vin[0].prevout = COutPoint(tx.GetHash(), 0); + mtx2.vin[0].prevout = COutPoint(tx.GetTxid(), 0); mtx2.vin[0].scriptSig = CScript() << OP_1; mtx2.vin[0].nSequence = 0; diff --git a/src/test/data/script_invalid.json b/src/test/data/script_invalid.json index 7afa2abf4..965be7251 100644 --- a/src/test/data/script_invalid.json +++ b/src/test/data/script_invalid.json @@ -791,12 +791,6 @@ "SIGPUSHONLY", "P2SH(P2PK) with non-push scriptSig" ], -[ - "0 0x47 0x304402205451ce65ad844dbb978b8bdedf5082e33b43cae8279c30f2c74d9e9ee49a94f802203fe95a7ccf74da7a232ee523ef4a53cb4d14bdd16289680cdb97a63819b8f42f01 0x46 0x304402205451ce65ad844dbb978b8bdedf5082e33b43cae8279c30f2c74d9e9ee49a94f802203fe95a7ccf74da7a232ee523ef4a53cb4d14bdd16289680cdb97a63819b8f42f", - "2 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 3 CHECKMULTISIG", - "P2SH,STRICTENC", - "2-of-3 with one valid and one invalid signature due to parse error, nSigs > validSigs" -], [ "11 0x47 0x304402200a5c6163f07b8d3b013c4d1d6dba25e780b39658d79ba37af7057a3b7f15ffa102201fd9b4eaa9943f734928b99a83592c2e7bf342ea2680f6a2bb705167966b742001", "0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG", @@ -812,3 +806,4 @@ ["The End"] ] + diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json index a4e15faea..0dd0b4cbe 100644 --- a/src/test/data/script_valid.json +++ b/src/test/data/script_valid.json @@ -909,3 +909,4 @@ ["The End"] ] + diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index 0996e13c4..294e0f159 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest) { txChild[i].vin.resize(1); txChild[i].vin[0].scriptSig = CScript() << OP_11; - txChild[i].vin[0].prevout.hash = txParent.GetHash(); + txChild[i].vin[0].prevout.hash = txParent.GetTxid(); txChild[i].vin[0].prevout.n = i; txChild[i].vout.resize(1); txChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest) { txGrandChild[i].vin.resize(1); txGrandChild[i].vin[0].scriptSig = CScript() << OP_11; - txGrandChild[i].vin[0].prevout.hash = txChild[i].GetHash(); + txGrandChild[i].vin[0].prevout.hash = txChild[i].GetTxid(); txGrandChild[i].vin[0].prevout.n = 0; txGrandChild[i].vout.resize(1); txGrandChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; @@ -60,17 +60,17 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest) BOOST_CHECK_EQUAL(removed.size(), 0); // Just the parent: - testPool.addUnchecked(txParent.GetHash(), CTxMemPoolEntry(txParent, 0, 0, 0.0, 1)); + testPool.addUnchecked(txParent.GetTxid(), CTxMemPoolEntry(txParent, 0, 0, 0.0, 1)); testPool.remove(txParent, removed, true); BOOST_CHECK_EQUAL(removed.size(), 1); removed.clear(); // Parent, children, grandchildren: - testPool.addUnchecked(txParent.GetHash(), CTxMemPoolEntry(txParent, 0, 0, 0.0, 1)); + testPool.addUnchecked(txParent.GetTxid(), CTxMemPoolEntry(txParent, 0, 0, 0.0, 1)); for (int i = 0; i < 3; i++) { - testPool.addUnchecked(txChild[i].GetHash(), CTxMemPoolEntry(txChild[i], 0, 0, 0.0, 1)); - testPool.addUnchecked(txGrandChild[i].GetHash(), CTxMemPoolEntry(txGrandChild[i], 0, 0, 0.0, 1)); + testPool.addUnchecked(txChild[i].GetTxid(), CTxMemPoolEntry(txChild[i], 0, 0, 0.0, 1)); + testPool.addUnchecked(txGrandChild[i].GetTxid(), CTxMemPoolEntry(txGrandChild[i], 0, 0, 0.0, 1)); } // Remove Child[0], GrandChild[0] should be removed: testPool.remove(txChild[0], removed, true); @@ -90,8 +90,8 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest) // 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].GetHash(), CTxMemPoolEntry(txChild[i], 0, 0, 0.0, 1)); - testPool.addUnchecked(txGrandChild[i].GetHash(), CTxMemPoolEntry(txGrandChild[i], 0, 0, 0.0, 1)); + testPool.addUnchecked(txChild[i].GetTxid(), CTxMemPoolEntry(txChild[i], 0, 0, 0.0, 1)); + testPool.addUnchecked(txGrandChild[i].GetTxid(), CTxMemPoolEntry(txGrandChild[i], 0, 0, 0.0, 1)); } // Now remove the parent, as might happen if a block-re-org occurs but the parent cannot be // put into the mempool (maybe because it is non-standard): diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index adc606aa7..fc22e94fd 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -253,14 +253,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vin.resize(1); // 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]->GetHash(); + tx.vin[0].prevout.hash = txFirst[0]->GetTxid(); tx.vin[0].prevout.n = 0; tx.vout.resize(1); tx.vout[0].nValue = 50000LL; for (unsigned int i = 0; i < 1001; ++i) { tx.vout[0].nValue -= 10; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); tx.vin[0].prevout.hash = hash; } @@ -275,12 +275,12 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) 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]->GetHash(); + tx.vin[0].prevout.hash = txFirst[0]->GetTxid(); tx.vout[0].nValue = 50000LL; for (unsigned int i = 0; i < 128; ++i) { tx.vout[0].nValue -= 350; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); tx.vin[0].prevout.hash = hash; } @@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) mempool.clear(); // orphan in mempool - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); delete pblocktemplate; @@ -297,17 +297,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) // child with higher priority than parent tx.vin[0].scriptSig = CScript() << OP_1; - tx.vin[0].prevout.hash = txFirst[1]->GetHash(); + tx.vin[0].prevout.hash = txFirst[1]->GetTxid(); tx.vout[0].nValue = 39000LL; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); tx.vin[0].prevout.hash = hash; tx.vin.resize(2); tx.vin[1].scriptSig = CScript() << OP_1; - tx.vin[1].prevout.hash = txFirst[0]->GetHash(); + tx.vin[1].prevout.hash = txFirst[0]->GetTxid(); tx.vin[1].prevout.n = 0; tx.vout[0].nValue = 49000LL; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); delete pblocktemplate; @@ -318,39 +318,39 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx.vin[0].prevout.SetNull(); tx.vin[0].scriptSig = CScript() << OP_0 << OP_1; tx.vout[0].nValue = 0; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); delete pblocktemplate; mempool.clear(); // invalid (pre-p2sh) txn in mempool - tx.vin[0].prevout.hash = txFirst[0]->GetHash(); + tx.vin[0].prevout.hash = txFirst[0]->GetTxid(); tx.vin[0].prevout.n = 0; tx.vin[0].scriptSig = CScript() << OP_1; tx.vout[0].nValue = 49000LL; script = CScript() << OP_0; tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script)); - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); tx.vin[0].prevout.hash = hash; tx.vin[0].scriptSig = CScript() << (std::vector)script; tx.vout[0].nValue -= 10000; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); delete pblocktemplate; mempool.clear(); // double spend txn pair in mempool - tx.vin[0].prevout.hash = txFirst[0]->GetHash(); + tx.vin[0].prevout.hash = txFirst[0]->GetTxid(); tx.vin[0].scriptSig = CScript() << OP_1; tx.vout[0].nValue = 49000LL; tx.vout[0].scriptPubKey = CScript() << OP_1; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); tx.vout[0].scriptPubKey = CScript() << OP_2; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey)); delete pblocktemplate; @@ -370,19 +370,19 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) SetMockTime(chainActive.Tip()->GetMedianTimePast()+1); // height locked - tx.vin[0].prevout.hash = txFirst[0]->GetHash(); + tx.vin[0].prevout.hash = txFirst[0]->GetTxid(); tx.vin[0].scriptSig = CScript() << OP_1; tx.vin[0].nSequence = 0; tx.vout[0].nValue = 49000LL; tx.vout[0].scriptPubKey = CScript() << OP_1; tx.nLockTime = chainActive.Tip()->nHeight+1; - hash = tx.GetHash(); + hash = tx.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11)); BOOST_CHECK(!CheckFinalTx(tx, LOCKTIME_MEDIAN_TIME_PAST)); // time locked tx2.vin.resize(1); - tx2.vin[0].prevout.hash = txFirst[1]->GetHash(); + tx2.vin[0].prevout.hash = txFirst[1]->GetTxid(); tx2.vin[0].prevout.n = 0; tx2.vin[0].scriptSig = CScript() << OP_1; tx2.vin[0].nSequence = 0; @@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) tx2.vout[0].nValue = 79000LL; tx2.vout[0].scriptPubKey = CScript() << OP_1; tx2.nLockTime = chainActive.Tip()->GetMedianTimePast()+1; - hash = tx2.GetHash(); + hash = tx2.GetTxid(); mempool.addUnchecked(hash, CTxMemPoolEntry(tx2, 11, GetTime(), 111.0, 11)); BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST)); diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index 6b189a6b5..cc6f6acbf 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(multisig_verify) txTo[i].vin.resize(1); txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetHash(); + txTo[i].vin[0].prevout.hash = txFrom.GetTxid(); txTo[i].vout[0].nValue = 1; } @@ -306,7 +306,7 @@ BOOST_AUTO_TEST_CASE(multisig_Sign) txTo[i].vin.resize(1); txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetHash(); + txTo[i].vin[0].prevout.hash = txFrom.GetTxid(); txTo[i].vout[0].nValue = 1; } diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index f6d06d680..e39aff233 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(pmt_test1) uint256 merkleRoot1 = block.BuildMerkleTree(); std::vector vTxid(nTx, uint256()); for (unsigned int j=0; j 1) { nTx_ = (nTx_+1)/2; diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp index cb64ee7c6..b6ef9e573 100644 --- a/src/test/policyestimator_tests.cpp +++ b/src/test/policyestimator_tests.cpp @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) for (int j = 0; j < 10; j++) { // For each fee/pri multiple for (int k = 0; k < 5; k++) { // add 4 fee txs for every priority tx tx.vin[0].prevout.n = 10000*blocknum+100*j+k; // make transaction unique - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); mpool.addUnchecked(hash, CTxMemPoolEntry(tx, feeV[k/4][j], GetTime(), priV[k/4][j], blocknum, mpool.HasNoInputsOf(tx))); txHashes[j].push_back(hash); } @@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) for (int j = 0; j < 10; j++) { // For each fee/pri multiple for (int k = 0; k < 5; k++) { // add 4 fee txs for every priority tx tx.vin[0].prevout.n = 10000*blocknum+100*j+k; - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); mpool.addUnchecked(hash, CTxMemPoolEntry(tx, feeV[k/4][j], GetTime(), priV[k/4][j], blocknum, mpool.HasNoInputsOf(tx))); txHashes[j].push_back(hash); } @@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates) for (int j = 0; j < 10; j++) { // For each fee/pri multiple for (int k = 0; k < 5; k++) { // add 4 fee txs for every priority tx tx.vin[0].prevout.n = 10000*blocknum+100*j+k; - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); mpool.addUnchecked(hash, CTxMemPoolEntry(tx, feeV[k/4][j], GetTime(), priV[k/4][j], blocknum, mpool.HasNoInputsOf(tx))); CTransaction btx; if (mpool.lookup(hash, btx)) diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp index c8cfe2872..cc8c5662d 100644 --- a/src/test/script_P2SH_tests.cpp +++ b/src/test/script_P2SH_tests.cpp @@ -40,7 +40,7 @@ Verify(const CScript& scriptSig, const CScript& scriptPubKey, bool fStrict, Scri txTo.vin.resize(1); txTo.vout.resize(1); txTo.vin[0].prevout.n = 0; - txTo.vin[0].prevout.hash = txFrom.GetHash(); + txTo.vin[0].prevout.hash = txFrom.GetTxid(); txTo.vin[0].scriptSig = scriptSig; txTo.vout[0].nValue = 1; @@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(sign) txTo[i].vin.resize(1); txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetHash(); + txTo[i].vin[0].prevout.hash = txFrom.GetTxid(); txTo[i].vout[0].nValue = 1; #ifdef ENABLE_WALLET BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), strprintf("IsMine %d", i)); @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(set) txTo[i].vin.resize(1); txTo[i].vout.resize(1); txTo[i].vin[0].prevout.n = i; - txTo[i].vin[0].prevout.hash = txFrom.GetHash(); + txTo[i].vin[0].prevout.hash = txFrom.GetTxid(); txTo[i].vout[0].nValue = 1*CENT; txTo[i].vout[0].scriptPubKey = inner[i]; #ifdef ENABLE_WALLET @@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard) txFrom.vout[6].scriptPubKey = GetScriptForDestination(CScriptID(twentySigops)); txFrom.vout[6].nValue = 6000; - coins.ModifyCoins(txFrom.GetHash())->FromTx(txFrom, 0); + coins.ModifyCoins(txFrom.GetTxid())->FromTx(txFrom, 0); CMutableTransaction txTo; txTo.vout.resize(1); @@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard) for (int i = 0; i < 5; i++) { txTo.vin[i].prevout.n = i; - txTo.vin[i].prevout.hash = txFrom.GetHash(); + txTo.vin[i].prevout.hash = txFrom.GetTxid(); } BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 0)); BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 1)); @@ -360,7 +360,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard) txToNonStd1.vout[0].nValue = 1000; txToNonStd1.vin.resize(1); txToNonStd1.vin[0].prevout.n = 5; - txToNonStd1.vin[0].prevout.hash = txFrom.GetHash(); + txToNonStd1.vin[0].prevout.hash = txFrom.GetTxid(); txToNonStd1.vin[0].scriptSig << static_cast >(sixteenSigops); BOOST_CHECK(!::AreInputsStandard(txToNonStd1, coins)); @@ -372,7 +372,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard) txToNonStd2.vout[0].nValue = 1000; txToNonStd2.vin.resize(1); txToNonStd2.vin[0].prevout.n = 6; - txToNonStd2.vin[0].prevout.hash = txFrom.GetHash(); + txToNonStd2.vin[0].prevout.hash = txFrom.GetTxid(); txToNonStd2.vin[0].scriptSig << static_cast >(twentySigops); BOOST_CHECK(!::AreInputsStandard(txToNonStd2, coins)); diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index c0614cca4..c6b4ed39e 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -79,7 +79,7 @@ CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMu txSpend.nLockTime = 0; txSpend.vin.resize(1); txSpend.vout.resize(1); - txSpend.vin[0].prevout.hash = txCredit.GetHash(); + txSpend.vin[0].prevout.hash = txCredit.GetTxid(); txSpend.vin[0].prevout.n = 0; txSpend.vin[0].scriptSig = scriptSig; txSpend.vin[0].nSequence = std::numeric_limits::max(); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 0c6c068f4..2e701b15e 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -279,14 +279,14 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet) dummyTransactions[0].vout[0].scriptPubKey << ToByteVector(key[0].GetPubKey()) << OP_CHECKSIG; dummyTransactions[0].vout[1].nValue = 50*CENT; dummyTransactions[0].vout[1].scriptPubKey << ToByteVector(key[1].GetPubKey()) << OP_CHECKSIG; - coinsRet.ModifyCoins(dummyTransactions[0].GetHash())->FromTx(dummyTransactions[0], 0); + coinsRet.ModifyCoins(dummyTransactions[0].GetTxid())->FromTx(dummyTransactions[0], 0); dummyTransactions[1].vout.resize(2); dummyTransactions[1].vout[0].nValue = 21*CENT; dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(key[2].GetPubKey().GetID()); dummyTransactions[1].vout[1].nValue = 22*CENT; dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey().GetID()); - coinsRet.ModifyCoins(dummyTransactions[1].GetHash())->FromTx(dummyTransactions[1], 0); + coinsRet.ModifyCoins(dummyTransactions[1].GetTxid())->FromTx(dummyTransactions[1], 0); return dummyTransactions; } @@ -508,13 +508,13 @@ BOOST_AUTO_TEST_CASE(test_Get) CMutableTransaction t1; t1.vin.resize(3); - t1.vin[0].prevout.hash = dummyTransactions[0].GetHash(); + t1.vin[0].prevout.hash = dummyTransactions[0].GetTxid(); t1.vin[0].prevout.n = 1; t1.vin[0].scriptSig << std::vector(65, 0); - t1.vin[1].prevout.hash = dummyTransactions[1].GetHash(); + t1.vin[1].prevout.hash = dummyTransactions[1].GetTxid(); 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].GetHash(); + t1.vin[2].prevout.hash = dummyTransactions[1].GetTxid(); t1.vin[2].prevout.n = 1; t1.vin[2].scriptSig << std::vector(65, 0) << std::vector(33, 4); t1.vout.resize(2); @@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard) CMutableTransaction t; t.vin.resize(1); - t.vin[0].prevout.hash = dummyTransactions[0].GetHash(); + t.vin[0].prevout.hash = dummyTransactions[0].GetTxid(); t.vin[0].prevout.n = 1; t.vin[0].scriptSig << std::vector(65, 0); t.vout.resize(1); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index e9c846485..77dcc0153 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -118,17 +118,17 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list& rem { LOCK(cs); std::deque txToRemove; - txToRemove.push_back(origTx.GetHash()); - if (fRecursive && !mapTx.count(origTx.GetHash())) { + txToRemove.push_back(origTx.GetTxid()); + if (fRecursive && !mapTx.count(origTx.GetTxid())) { // If recursively removing but origTx isn't in the mempool // be sure to remove any children that are in the pool. This can // happen 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++) { - std::map::iterator it = mapNextTx.find(COutPoint(origTx.GetHash(), i)); + std::map::iterator it = mapNextTx.find(COutPoint(origTx.GetTxid(), i)); if (it == mapNextTx.end()) continue; - txToRemove.push_back(it->second.ptx->GetHash()); + txToRemove.push_back(it->second.ptx->GetTxid()); } } while (!txToRemove.empty()) @@ -143,7 +143,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list& rem std::map::iterator it = mapNextTx.find(COutPoint(hash, i)); if (it == mapNextTx.end()) continue; - txToRemove.push_back(it->second.ptx->GetHash()); + txToRemove.push_back(it->second.ptx->GetTxid()); } } BOOST_FOREACH(const CTxIn& txin, tx.vin) @@ -254,7 +254,7 @@ void CTxMemPool::removeForBlock(const std::vector& vtx, unsigned i std::vector entries; BOOST_FOREACH(const CTransaction& tx, vtx) { - uint256 hash = tx.GetHash(); + uint256 hash = tx.GetTxid(); if (mapTx.count(hash)) entries.push_back(mapTx[hash]); } @@ -263,7 +263,7 @@ void CTxMemPool::removeForBlock(const std::vector& vtx, unsigned i std::list dummy; remove(tx, dummy, false); removeConflicts(tx, conflicts); - ClearPrioritisation(tx.GetHash()); + ClearPrioritisation(tx.GetTxid()); } // After the txs in the new block have been removed from the mempool, update policy estimates minerPolicyEstimator->processBlock(nBlockHeight, entries, fCurrentEstimate); @@ -361,7 +361,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const } } for (std::map::const_iterator it = mapNextTx.begin(); it != mapNextTx.end(); it++) { - uint256 hash = it->second.ptx->GetHash(); + uint256 hash = it->second.ptx->GetTxid(); map::const_iterator it2 = mapTx.find(hash); const CTransaction& tx = it2->second.GetTx(); assert(it2 != mapTx.end()); @@ -371,7 +371,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const } for (std::map::const_iterator it = mapNullifiers.begin(); it != mapNullifiers.end(); it++) { - uint256 hash = it->second->GetHash(); + uint256 hash = it->second->GetTxid(); map::const_iterator it2 = mapTx.find(hash); const CTransaction& tx = it2->second.GetTx(); assert(it2 != mapTx.end()); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0f72141f8..b9d588b9a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -74,7 +74,7 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry) entry.push_back(Pair("blockindex", wtx.nIndex)); entry.push_back(Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime())); } - uint256 hash = wtx.GetHash(); + uint256 hash = wtx.GetTxid(); entry.push_back(Pair("txid", hash.GetHex())); Array conflicts; BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts()) @@ -439,7 +439,7 @@ Value sendtoaddress(const Array& params, bool fHelp) SendMoney(address.Get(), nAmount, fSubtractFeeFromAmount, wtx); - return wtx.GetHash().GetHex(); + return wtx.GetTxid().GetHex(); } Value listaddressgroupings(const Array& params, bool fHelp) @@ -916,7 +916,7 @@ Value sendfrom(const Array& params, bool fHelp) SendMoney(address.Get(), nAmount, false, wtx); - return wtx.GetHash().GetHex(); + return wtx.GetTxid().GetHex(); } @@ -1023,7 +1023,7 @@ Value sendmany(const Array& params, bool fHelp) if (!pwalletMain->CommitTransaction(wtx, keyChange)) throw JSONRPCError(RPC_WALLET_ERROR, "Transaction commit failed"); - return wtx.GetHash().GetHex(); + return wtx.GetTxid().GetHex(); } // Defined in rpcmisc.cpp @@ -1135,7 +1135,7 @@ Value ListReceived(const Array& params, bool fByAccounts) tallyitem& item = mapTally[address]; item.nAmount += txout.nValue; item.nConf = min(item.nConf, nDepth); - item.txids.push_back(wtx.GetHash()); + item.txids.push_back(wtx.GetTxid()); if (mine & ISMINE_WATCH_ONLY) item.fIsWatchonly = true; } @@ -2324,7 +2324,7 @@ Value listunspent(const Array& params, bool fHelp) CAmount nValue = out.tx->vout[out.i].nValue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; Object entry; - entry.push_back(Pair("txid", out.tx->GetHash().GetHex())); + entry.push_back(Pair("txid", out.tx->GetTxid().GetHex())); entry.push_back(Pair("vout", out.i)); CTxDestination address; if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 242442061..f8215c939 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -58,7 +58,7 @@ struct CompareValueOnly std::string COutput::ToString() const { - return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue)); + return strprintf("COutput(%s, %d, %d) [%s]", tx->GetTxid().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue)); } const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const @@ -613,7 +613,7 @@ void CWallet::MarkDirty() bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb) { - uint256 hash = wtxIn.GetHash(); + uint256 hash = wtxIn.GetTxid(); if (fFromLoadWallet) { @@ -676,7 +676,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD } else LogPrintf("AddToWallet(): found %s in block %s not in index\n", - wtxIn.GetHash().ToString(), + wtxIn.GetTxid().ToString(), wtxIn.hashBlock.ToString()); } AddToSpends(hash); @@ -705,7 +705,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD } //// debug print - LogPrintf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : "")); + LogPrintf("AddToWallet %s %s%s\n", wtxIn.GetTxid().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : "")); // Write to disk if (fInsertedNew || fUpdated) @@ -723,7 +723,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD if ( !strCmd.empty()) { - boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex()); + boost::replace_all(strCmd, "%s", wtxIn.GetTxid().GetHex()); boost::thread t(runCommand, strCmd); // thread runs free } @@ -740,7 +740,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl { { AssertLockHeld(cs_wallet); - bool fExisted = mapWallet.count(tx.GetHash()) != 0; + bool fExisted = mapWallet.count(tx.GetTxid()) != 0; if (fExisted && !fUpdate) return false; if (fExisted || IsMine(tx) || IsFromMe(tx)) { @@ -935,7 +935,7 @@ int CWalletTx::GetRequestCount() const else { // Did anyone request this transaction? - map::const_iterator mi = pwallet->mapRequestCount.find(GetHash()); + map::const_iterator mi = pwallet->mapRequestCount.find(GetTxid()); if (mi != pwallet->mapRequestCount.end()) { nRequests = (*mi).second; @@ -993,7 +993,7 @@ void CWalletTx::GetAmounts(list& listReceived, if (!ExtractDestination(txout.scriptPubKey, address)) { LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n", - this->GetHash().ToString()); + this->GetTxid().ToString()); address = CNoDestination(); } @@ -1048,7 +1048,7 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived, bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb) { - return pwalletdb->WriteTx(GetHash(), *this); + return pwalletdb->WriteTx(GetTxid(), *this); } void CWallet::WitnessNoteCommitment(std::vector commitments, @@ -1167,7 +1167,7 @@ void CWallet::ReacceptWalletTransactions() { const uint256& wtxid = item.first; CWalletTx& wtx = item.second; - assert(wtx.GetHash() == wtxid); + assert(wtx.GetTxid() == wtxid); int nDepth = wtx.GetDepthInMainChain(); @@ -1192,7 +1192,7 @@ bool CWalletTx::RelayWalletTransaction() if (!IsCoinBase()) { if (GetDepthInMainChain() == 0) { - LogPrintf("Relaying wtx %s\n", GetHash().ToString()); + LogPrintf("Relaying wtx %s\n", GetTxid().ToString()); RelayTransaction((CTransaction)*this); return true; } @@ -1205,7 +1205,7 @@ set CWalletTx::GetConflicts() const set result; if (pwallet != NULL) { - uint256 myHash = GetHash(); + uint256 myHash = GetTxid(); result = pwallet->GetConflicts(myHash); result.erase(myHash); } @@ -1303,7 +1303,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache) const return nAvailableCreditCached; CAmount nCredit = 0; - uint256 hashTx = GetHash(); + uint256 hashTx = GetTxid(); for (unsigned int i = 0; i < vout.size(); i++) { if (!pwallet->IsSpent(hashTx, i)) @@ -1349,7 +1349,7 @@ CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool& fUseCache) const CAmount nCredit = 0; for (unsigned int i = 0; i < vout.size(); i++) { - if (!pwallet->IsSpent(GetHash(), i)) + if (!pwallet->IsSpent(GetTxid(), i)) { const CTxOut &txout = vout[i]; nCredit += pwallet->GetCredit(txout, ISMINE_WATCH_ONLY); @@ -1418,7 +1418,7 @@ std::vector CWallet::ResendWalletTransactionsBefore(int64_t nTime) { CWalletTx& wtx = *item.second; if (wtx.RelayWalletTransaction()) - result.push_back(wtx.GetHash()); + result.push_back(wtx.GetTxid()); } return result; } @@ -1954,7 +1954,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, // Note how the sequence number is set to max()-1 so that the // nLockTime set above actually works. BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins) - txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(), + txNew.vin.push_back(CTxIn(coin.first->GetTxid(),coin.second,CScript(), std::numeric_limits::max()-1)); // Sign @@ -2042,7 +2042,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) { CWalletTx &coin = mapWallet[txin.prevout.hash]; coin.BindWallet(this); - NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED); + NotifyTransactionChanged(this, coin.GetTxid(), CT_UPDATED); } if (fFileBacked) @@ -2050,7 +2050,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) } // Track how many getdata requests our transaction gets - mapRequestCount[wtxNew.GetHash()] = 0; + mapRequestCount[wtxNew.GetTxid()] = 0; if (fBroadcastTransactions) { @@ -2781,7 +2781,7 @@ int CMerkleTx::GetDepthInMainChainINTERNAL(const CBlockIndex* &pindexRet) const // Make sure the merkle branch connects to this block if (!fMerkleVerified) { - if (CBlock::CheckMerkleBranch(GetHash(), vMerkleBranch, nIndex) != pindex->hashMerkleRoot) + if (CBlock::CheckMerkleBranch(GetTxid(), vMerkleBranch, nIndex) != pindex->hashMerkleRoot) return 0; fMerkleVerified = true; } @@ -2794,7 +2794,7 @@ int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const { AssertLockHeld(cs_main); int nResult = GetDepthInMainChainINTERNAL(pindexRet); - if (nResult == 0 && !mempool.exists(GetHash())) + if (nResult == 0 && !mempool.exists(GetTxid())) return -1; // Not in chain, not in mempool return nResult; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index f777926e7..6f08ad681 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -288,7 +288,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet) if (pwtx) { - if (!WriteTx(pwtx->GetHash(), *pwtx)) + if (!WriteTx(pwtx->GetTxid(), *pwtx)) return DB_LOAD_FAIL; } else @@ -312,7 +312,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet) // Since we're changing the order, write it back if (pwtx) { - if (!WriteTx(pwtx->GetHash(), *pwtx)) + if (!WriteTx(pwtx->GetTxid(), *pwtx)) return DB_LOAD_FAIL; } else @@ -371,7 +371,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, CWalletTx wtx; ssValue >> wtx; CValidationState state; - if (!(CheckTransaction(wtx, state) && (wtx.GetHash() == hash) && state.IsValid())) + if (!(CheckTransaction(wtx, state) && (wtx.GetTxid() == hash) && state.IsValid())) return false; // Undo serialize changes in 31600 diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index 004f9d0cb..c7460fb35 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -171,7 +171,7 @@ double benchmark_large_tx() auto orig_tx = CTransaction(m_orig_tx); CMutableTransaction spending_tx; - auto input_hash = orig_tx.GetHash(); + auto input_hash = orig_tx.GetTxid(); // Add NUM_INPUTS inputs for (size_t i = 0; i < NUM_INPUTS; i++) { spending_tx.vin.emplace_back(input_hash, 0);