@@ -1342,7 +1342,7 @@ class CTransactionSignatureSerializer
13421342template <class T >
13431343uint256 GetPrevoutsSHA256 (const T& txTo)
13441344{
1345- CHashWriter ss (SER_GETHASH, 0 ) ;
1345+ HashWriter ss{} ;
13461346 for (const auto & txin : txTo.vin ) {
13471347 ss << txin.prevout ;
13481348 }
@@ -1353,7 +1353,7 @@ uint256 GetPrevoutsSHA256(const T& txTo)
13531353template <class T >
13541354uint256 GetSequencesSHA256 (const T& txTo)
13551355{
1356- CHashWriter ss (SER_GETHASH, 0 ) ;
1356+ HashWriter ss{} ;
13571357 for (const auto & txin : txTo.vin ) {
13581358 ss << txin.nSequence ;
13591359 }
@@ -1364,7 +1364,7 @@ uint256 GetSequencesSHA256(const T& txTo)
13641364template <class T >
13651365uint256 GetOutputsSHA256 (const T& txTo)
13661366{
1367- CHashWriter ss (SER_GETHASH, 0 ) ;
1367+ HashWriter ss{} ;
13681368 for (const auto & txout : txTo.vout ) {
13691369 ss << txout;
13701370 }
@@ -1374,7 +1374,7 @@ uint256 GetOutputsSHA256(const T& txTo)
13741374/* * Compute the (single) SHA256 of the concatenation of all amounts spent by a tx. */
13751375uint256 GetSpentAmountsSHA256 (const std::vector<CTxOut>& outputs_spent)
13761376{
1377- CHashWriter ss (SER_GETHASH, 0 ) ;
1377+ HashWriter ss{} ;
13781378 for (const auto & txout : outputs_spent) {
13791379 ss << txout.nValue ;
13801380 }
@@ -1384,7 +1384,7 @@ uint256 GetSpentAmountsSHA256(const std::vector<CTxOut>& outputs_spent)
13841384/* * Compute the (single) SHA256 of the concatenation of all scriptPubKeys spent by a tx. */
13851385uint256 GetSpentScriptsSHA256 (const std::vector<CTxOut>& outputs_spent)
13861386{
1387- CHashWriter ss (SER_GETHASH, 0 ) ;
1387+ HashWriter ss{} ;
13881388 for (const auto & txout : outputs_spent) {
13891389 ss << txout.scriptPubKey ;
13901390 }
@@ -1458,9 +1458,9 @@ template void PrecomputedTransactionData::Init(const CMutableTransaction& txTo,
14581458template PrecomputedTransactionData::PrecomputedTransactionData(const CTransaction& txTo);
14591459template PrecomputedTransactionData::PrecomputedTransactionData(const CMutableTransaction& txTo);
14601460
1461- const CHashWriter HASHER_TAPSIGHASH = TaggedHash(" TapSighash" );
1462- const CHashWriter HASHER_TAPLEAF = TaggedHash(" TapLeaf" );
1463- const CHashWriter HASHER_TAPBRANCH = TaggedHash(" TapBranch" );
1461+ const HashWriter HASHER_TAPSIGHASH{ TaggedHash (" TapSighash" )} ;
1462+ const HashWriter HASHER_TAPLEAF{ TaggedHash (" TapLeaf" )} ;
1463+ const HashWriter HASHER_TAPBRANCH{ TaggedHash (" TapBranch" )} ;
14641464
14651465static bool HandleMissingData (MissingDataBehavior mdb)
14661466{
@@ -1499,7 +1499,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
14991499 return HandleMissingData (mdb);
15001500 }
15011501
1502- CHashWriter ss = HASHER_TAPSIGHASH;
1502+ HashWriter ss{ HASHER_TAPSIGHASH} ;
15031503
15041504 // Epoch
15051505 static constexpr uint8_t EPOCH = 0 ;
@@ -1544,7 +1544,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
15441544 if (output_type == SIGHASH_SINGLE) {
15451545 if (in_pos >= tx_to.vout .size ()) return false ;
15461546 if (!execdata.m_output_hash ) {
1547- CHashWriter sha_single_output (SER_GETHASH, 0 ) ;
1547+ HashWriter sha_single_output{} ;
15481548 sha_single_output << tx_to.vout [in_pos];
15491549 execdata.m_output_hash = sha_single_output.GetSHA256 ();
15501550 }
@@ -1587,12 +1587,12 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
15871587 if ((nHashType & 0x1f ) != SIGHASH_SINGLE && (nHashType & 0x1f ) != SIGHASH_NONE) {
15881588 hashOutputs = cacheready ? cache->hashOutputs : SHA256Uint256 (GetOutputsSHA256 (txTo));
15891589 } else if ((nHashType & 0x1f ) == SIGHASH_SINGLE && nIn < txTo.vout .size ()) {
1590- CHashWriter ss (SER_GETHASH, 0 ) ;
1590+ HashWriter ss{} ;
15911591 ss << txTo.vout [nIn];
15921592 hashOutputs = ss.GetHash ();
15931593 }
15941594
1595- CHashWriter ss (SER_GETHASH, 0 ) ;
1595+ HashWriter ss{} ;
15961596 // Version
15971597 ss << txTo.nVersion ;
15981598 // Input prevouts/nSequence (none/all, depending on flags)
@@ -1627,7 +1627,7 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
16271627 CTransactionSignatureSerializer<T> txTmp (txTo, scriptCode, nIn, nHashType);
16281628
16291629 // Serialize and hash
1630- CHashWriter ss (SER_GETHASH, 0 ) ;
1630+ HashWriter ss{} ;
16311631 ss << txTmp << nHashType;
16321632 return ss.GetHash ();
16331633}
@@ -1827,7 +1827,7 @@ static bool ExecuteWitnessScript(const Span<const valtype>& stack_span, const CS
18271827
18281828uint256 ComputeTapleafHash (uint8_t leaf_version, const CScript& script)
18291829{
1830- return (CHashWriter ( HASHER_TAPLEAF) << leaf_version << script).GetSHA256 ();
1830+ return (HashWriter{ HASHER_TAPLEAF} << leaf_version << script).GetSHA256 ();
18311831}
18321832
18331833uint256 ComputeTaprootMerkleRoot (Span<const unsigned char > control, const uint256& tapleaf_hash)
@@ -1839,7 +1839,7 @@ uint256 ComputeTaprootMerkleRoot(Span<const unsigned char> control, const uint25
18391839 const int path_len = (control.size () - TAPROOT_CONTROL_BASE_SIZE) / TAPROOT_CONTROL_NODE_SIZE;
18401840 uint256 k = tapleaf_hash;
18411841 for (int i = 0 ; i < path_len; ++i) {
1842- CHashWriter ss_branch{HASHER_TAPBRANCH};
1842+ HashWriter ss_branch{HASHER_TAPBRANCH};
18431843 Span node{Span{control}.subspan (TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * i, TAPROOT_CONTROL_NODE_SIZE)};
18441844 if (std::lexicographical_compare (k.begin (), k.end (), node.begin (), node.end ())) {
18451845 ss_branch << k << node;
@@ -1902,7 +1902,7 @@ static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion,
19021902 if (stack.size () >= 2 && !stack.back ().empty () && stack.back ()[0 ] == ANNEX_TAG) {
19031903 // Drop annex (this is non-standard; see IsWitnessStandard)
19041904 const valtype& annex = SpanPopBack (stack);
1905- execdata.m_annex_hash = (CHashWriter (SER_GETHASH, 0 ) << annex).GetSHA256 ();
1905+ execdata.m_annex_hash = (HashWriter{} << annex).GetSHA256 ();
19061906 execdata.m_annex_present = true ;
19071907 } else {
19081908 execdata.m_annex_present = false ;
0 commit comments