Skip to content

Commit

Permalink
refactor: return directly the double sha256 when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Feb 10, 2024
1 parent 3190a94 commit cf150bd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1481,37 +1481,37 @@ class CTransactionSignatureSerializer
}
};

/** Compute the (single) SHA256 of the concatenation of all prevouts of a tx. */
/** Compute the double SHA256 of the concatenation of all prevouts of a tx. */
template <class T>
uint256 GetPrevoutsSHA256(const T& txTo)
uint256 GetPrevoutsHash(const T& txTo)
{
CHashWriter ss(SER_GETHASH, 0);
for (const auto& txin : txTo.vin) {
ss << txin.prevout;
}
return ss.GetSHA256();
return ss.GetHash();
}

/** Compute the (single) SHA256 of the concatenation of all nSequences of a tx. */
/** Compute the double SHA256 of the concatenation of all nSequences of a tx. */
template <class T>
uint256 GetSequencesSHA256(const T& txTo)
uint256 GetSequencesHash(const T& txTo)
{
CHashWriter ss(SER_GETHASH, 0);
for (const auto& txin : txTo.vin) {
ss << txin.nSequence;
}
return ss.GetSHA256();
return ss.GetHash();
}

/** Compute the (single) SHA256 of the concatenation of all txouts of a tx. */
/** Compute the double SHA256 of the concatenation of all txouts of a tx. */
template <class T>
uint256 GetOutputsSHA256(const T& txTo)
uint256 GetOutputsHash(const T& txTo)
{
CHashWriter ss(SER_GETHASH, 0);
for (const auto& txout : txTo.vout) {
ss << txout;
}
return ss.GetSHA256();
return ss.GetHash();
}

} // namespace
Expand Down

0 comments on commit cf150bd

Please sign in to comment.