Segwit: Rename CTransaction::GetWitnessHash() -> CTransaction::GetHashWithWitness()

The upstream name of GetWitnessHash() is very confusing as it is not a hash of the witness data for the transaction, but rather a hash of the full serialization of the transaction including witness data. This goes beyond confusing to downright wrong with CT/CA where the witness hash will be a hash tree of witness data (rangeproofs, surjectionproofs, script signatures, etc.) and NOT have any transaction data.
This commit is contained in:
Mark Friedenbach 2017-03-11 14:20:27 -08:00 committed by Gregory Sanders
parent d3f60513d2
commit 889a05fdd4
7 changed files with 7 additions and 7 deletions

View file

@ -25,7 +25,7 @@ CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block, bool f
prefilledtxn[0] = {0, block.vtx[0]};
for (size_t i = 1; i < block.vtx.size(); i++) {
const CTransaction& tx = block.vtx[i];
shorttxids[i - 1] = GetShortID(fUseWTXID ? tx.GetWitnessHash() : tx.GetHash());
shorttxids[i - 1] = GetShortID(fUseWTXID ? tx.GetHashWithWitness() : tx.GetHash());
}
}

View file

@ -158,7 +158,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
{
entry.pushKV("txid", tx.GetHash().GetHex());
entry.pushKV("hash", tx.GetWitnessHash().GetHex());
entry.pushKV("hash", tx.GetHashWithWitness().GetHex());
entry.pushKV("version", tx.nVersion);
entry.pushKV("locktime", (int64_t)tx.nLockTime);

View file

@ -103,7 +103,7 @@ void CTransaction::UpdateHash() const
*const_cast<uint256*>(&hash) = SerializeHash(*this, SER_GETHASH, SERIALIZE_TRANSACTION_NO_WITNESS);
}
uint256 CTransaction::GetWitnessHash() const
uint256 CTransaction::GetHashWithWitness() const
{
return SerializeHash(*this, SER_GETHASH, 0);
}

View file

@ -760,7 +760,7 @@ public:
}
// Compute a hash that includes both transaction and witness data
uint256 GetWitnessHash() const;
uint256 GetHashWithWitness() const;
// Check if explicit TX fees overflow or are negative
bool HasValidFee() const;

View file

@ -633,7 +633,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
entry.push_back(Pair("data", EncodeHexTx(tx)));
entry.push_back(Pair("txid", txHash.GetHex()));
entry.push_back(Pair("hash", tx.GetWitnessHash().GetHex()));
entry.push_back(Pair("hash", tx.GetHashWithWitness().GetHex()));
UniValue deps(UniValue::VARR);
BOOST_FOREACH (const CTxIn &in, tx.vin)

View file

@ -89,7 +89,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
{
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
entry.push_back(Pair("hash", tx.GetWitnessHash().GetHex()));
entry.push_back(Pair("hash", tx.GetHashWithWitness().GetHex()));
entry.push_back(Pair("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION)));
entry.push_back(Pair("vsize", (int)::GetVirtualTransactionSize(tx)));
entry.push_back(Pair("version", tx.nVersion));

View file

@ -442,7 +442,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
totalTxSize += entry.GetTxSize();
minerPolicyEstimator->processTransaction(entry, fCurrentEstimate);
vTxHashes.emplace_back(tx.GetWitnessHash(), newit);
vTxHashes.emplace_back(tx.GetHashWithWitness(), newit);
newit->vTxHashesIdx = vTxHashes.size() - 1;
typedef std::pair<uint256, COutPoint> WithdrawPair;