@@ -1342,7 +1342,7 @@ class CTransactionSignatureSerializer
1342
1342
template <class T >
1343
1343
uint256 GetPrevoutsSHA256 (const T& txTo)
1344
1344
{
1345
- CHashWriter ss (SER_GETHASH, 0 ) ;
1345
+ HashWriter ss{} ;
1346
1346
for (const auto & txin : txTo.vin ) {
1347
1347
ss << txin.prevout ;
1348
1348
}
@@ -1353,7 +1353,7 @@ uint256 GetPrevoutsSHA256(const T& txTo)
1353
1353
template <class T >
1354
1354
uint256 GetSequencesSHA256 (const T& txTo)
1355
1355
{
1356
- CHashWriter ss (SER_GETHASH, 0 ) ;
1356
+ HashWriter ss{} ;
1357
1357
for (const auto & txin : txTo.vin ) {
1358
1358
ss << txin.nSequence ;
1359
1359
}
@@ -1364,7 +1364,7 @@ uint256 GetSequencesSHA256(const T& txTo)
1364
1364
template <class T >
1365
1365
uint256 GetOutputsSHA256 (const T& txTo)
1366
1366
{
1367
- CHashWriter ss (SER_GETHASH, 0 ) ;
1367
+ HashWriter ss{} ;
1368
1368
for (const auto & txout : txTo.vout ) {
1369
1369
ss << txout;
1370
1370
}
@@ -1374,7 +1374,7 @@ uint256 GetOutputsSHA256(const T& txTo)
1374
1374
/* * Compute the (single) SHA256 of the concatenation of all amounts spent by a tx. */
1375
1375
uint256 GetSpentAmountsSHA256 (const std::vector<CTxOut>& outputs_spent)
1376
1376
{
1377
- CHashWriter ss (SER_GETHASH, 0 ) ;
1377
+ HashWriter ss{} ;
1378
1378
for (const auto & txout : outputs_spent) {
1379
1379
ss << txout.nValue ;
1380
1380
}
@@ -1384,7 +1384,7 @@ uint256 GetSpentAmountsSHA256(const std::vector<CTxOut>& outputs_spent)
1384
1384
/* * Compute the (single) SHA256 of the concatenation of all scriptPubKeys spent by a tx. */
1385
1385
uint256 GetSpentScriptsSHA256 (const std::vector<CTxOut>& outputs_spent)
1386
1386
{
1387
- CHashWriter ss (SER_GETHASH, 0 ) ;
1387
+ HashWriter ss{} ;
1388
1388
for (const auto & txout : outputs_spent) {
1389
1389
ss << txout.scriptPubKey ;
1390
1390
}
@@ -1458,9 +1458,9 @@ template void PrecomputedTransactionData::Init(const CMutableTransaction& txTo,
1458
1458
template PrecomputedTransactionData::PrecomputedTransactionData(const CTransaction& txTo);
1459
1459
template PrecomputedTransactionData::PrecomputedTransactionData(const CMutableTransaction& txTo);
1460
1460
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" )} ;
1464
1464
1465
1465
static bool HandleMissingData (MissingDataBehavior mdb)
1466
1466
{
@@ -1499,7 +1499,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
1499
1499
return HandleMissingData (mdb);
1500
1500
}
1501
1501
1502
- CHashWriter ss = HASHER_TAPSIGHASH;
1502
+ HashWriter ss{ HASHER_TAPSIGHASH} ;
1503
1503
1504
1504
// Epoch
1505
1505
static constexpr uint8_t EPOCH = 0 ;
@@ -1544,7 +1544,7 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
1544
1544
if (output_type == SIGHASH_SINGLE) {
1545
1545
if (in_pos >= tx_to.vout .size ()) return false ;
1546
1546
if (!execdata.m_output_hash ) {
1547
- CHashWriter sha_single_output (SER_GETHASH, 0 ) ;
1547
+ HashWriter sha_single_output{} ;
1548
1548
sha_single_output << tx_to.vout [in_pos];
1549
1549
execdata.m_output_hash = sha_single_output.GetSHA256 ();
1550
1550
}
@@ -1587,12 +1587,12 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
1587
1587
if ((nHashType & 0x1f ) != SIGHASH_SINGLE && (nHashType & 0x1f ) != SIGHASH_NONE) {
1588
1588
hashOutputs = cacheready ? cache->hashOutputs : SHA256Uint256 (GetOutputsSHA256 (txTo));
1589
1589
} else if ((nHashType & 0x1f ) == SIGHASH_SINGLE && nIn < txTo.vout .size ()) {
1590
- CHashWriter ss (SER_GETHASH, 0 ) ;
1590
+ HashWriter ss{} ;
1591
1591
ss << txTo.vout [nIn];
1592
1592
hashOutputs = ss.GetHash ();
1593
1593
}
1594
1594
1595
- CHashWriter ss (SER_GETHASH, 0 ) ;
1595
+ HashWriter ss{} ;
1596
1596
// Version
1597
1597
ss << txTo.nVersion ;
1598
1598
// Input prevouts/nSequence (none/all, depending on flags)
@@ -1627,7 +1627,7 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
1627
1627
CTransactionSignatureSerializer<T> txTmp (txTo, scriptCode, nIn, nHashType);
1628
1628
1629
1629
// Serialize and hash
1630
- CHashWriter ss (SER_GETHASH, 0 ) ;
1630
+ HashWriter ss{} ;
1631
1631
ss << txTmp << nHashType;
1632
1632
return ss.GetHash ();
1633
1633
}
@@ -1827,7 +1827,7 @@ static bool ExecuteWitnessScript(const Span<const valtype>& stack_span, const CS
1827
1827
1828
1828
uint256 ComputeTapleafHash (uint8_t leaf_version, const CScript& script)
1829
1829
{
1830
- return (CHashWriter ( HASHER_TAPLEAF) << leaf_version << script).GetSHA256 ();
1830
+ return (HashWriter{ HASHER_TAPLEAF} << leaf_version << script).GetSHA256 ();
1831
1831
}
1832
1832
1833
1833
uint256 ComputeTaprootMerkleRoot (Span<const unsigned char > control, const uint256& tapleaf_hash)
@@ -1839,7 +1839,7 @@ uint256 ComputeTaprootMerkleRoot(Span<const unsigned char> control, const uint25
1839
1839
const int path_len = (control.size () - TAPROOT_CONTROL_BASE_SIZE) / TAPROOT_CONTROL_NODE_SIZE;
1840
1840
uint256 k = tapleaf_hash;
1841
1841
for (int i = 0 ; i < path_len; ++i) {
1842
- CHashWriter ss_branch{HASHER_TAPBRANCH};
1842
+ HashWriter ss_branch{HASHER_TAPBRANCH};
1843
1843
Span node{Span{control}.subspan (TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * i, TAPROOT_CONTROL_NODE_SIZE)};
1844
1844
if (std::lexicographical_compare (k.begin (), k.end (), node.begin (), node.end ())) {
1845
1845
ss_branch << k << node;
@@ -1902,7 +1902,7 @@ static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion,
1902
1902
if (stack.size () >= 2 && !stack.back ().empty () && stack.back ()[0 ] == ANNEX_TAG) {
1903
1903
// Drop annex (this is non-standard; see IsWitnessStandard)
1904
1904
const valtype& annex = SpanPopBack (stack);
1905
- execdata.m_annex_hash = (CHashWriter (SER_GETHASH, 0 ) << annex).GetSHA256 ();
1905
+ execdata.m_annex_hash = (HashWriter{} << annex).GetSHA256 ();
1906
1906
execdata.m_annex_present = true ;
1907
1907
} else {
1908
1908
execdata.m_annex_present = false ;
0 commit comments