@@ -1258,34 +1258,37 @@ class CTransactionSignatureSerializer
1258
1258
}
1259
1259
};
1260
1260
1261
+ /* * Compute the (single) SHA256 of the concatenation of all prevouts of a tx. */
1261
1262
template <class T >
1262
- uint256 GetPrevoutHash (const T& txTo)
1263
+ uint256 GetPrevoutsSHA256 (const T& txTo)
1263
1264
{
1264
1265
CHashWriter ss (SER_GETHASH, 0 );
1265
1266
for (const auto & txin : txTo.vin ) {
1266
1267
ss << txin.prevout ;
1267
1268
}
1268
- return ss.GetHash ();
1269
+ return ss.GetSHA256 ();
1269
1270
}
1270
1271
1272
+ /* * Compute the (single) SHA256 of the concatenation of all nSequences of a tx. */
1271
1273
template <class T >
1272
- uint256 GetSequenceHash (const T& txTo)
1274
+ uint256 GetSequencesSHA256 (const T& txTo)
1273
1275
{
1274
1276
CHashWriter ss (SER_GETHASH, 0 );
1275
1277
for (const auto & txin : txTo.vin ) {
1276
1278
ss << txin.nSequence ;
1277
1279
}
1278
- return ss.GetHash ();
1280
+ return ss.GetSHA256 ();
1279
1281
}
1280
1282
1283
+ /* * Compute the (single) SHA256 of the concatenation of all txouts of a tx. */
1281
1284
template <class T >
1282
- uint256 GetOutputsHash (const T& txTo)
1285
+ uint256 GetOutputsSHA256 (const T& txTo)
1283
1286
{
1284
1287
CHashWriter ss (SER_GETHASH, 0 );
1285
1288
for (const auto & txout : txTo.vout ) {
1286
1289
ss << txout;
1287
1290
}
1288
- return ss.GetHash ();
1291
+ return ss.GetSHA256 ();
1289
1292
}
1290
1293
1291
1294
} // namespace
@@ -1297,9 +1300,9 @@ void PrecomputedTransactionData::Init(const T& txTo)
1297
1300
1298
1301
// Cache is calculated only for transactions with witness
1299
1302
if (txTo.HasWitness ()) {
1300
- hashPrevouts = GetPrevoutHash ( txTo);
1301
- hashSequence = GetSequenceHash ( txTo);
1302
- hashOutputs = GetOutputsHash ( txTo);
1303
+ hashPrevouts = SHA256Uint256 ( GetPrevoutsSHA256 ( txTo) );
1304
+ hashSequence = SHA256Uint256 ( GetSequencesSHA256 ( txTo) );
1305
+ hashOutputs = SHA256Uint256 ( GetOutputsSHA256 ( txTo) );
1303
1306
}
1304
1307
1305
1308
m_ready = true ;
@@ -1329,16 +1332,16 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
1329
1332
const bool cacheready = cache && cache->m_ready ;
1330
1333
1331
1334
if (!(nHashType & SIGHASH_ANYONECANPAY)) {
1332
- hashPrevouts = cacheready ? cache->hashPrevouts : GetPrevoutHash ( txTo);
1335
+ hashPrevouts = cacheready ? cache->hashPrevouts : SHA256Uint256 ( GetPrevoutsSHA256 ( txTo) );
1333
1336
}
1334
1337
1335
1338
if (!(nHashType & SIGHASH_ANYONECANPAY) && (nHashType & 0x1f ) != SIGHASH_SINGLE && (nHashType & 0x1f ) != SIGHASH_NONE) {
1336
- hashSequence = cacheready ? cache->hashSequence : GetSequenceHash ( txTo);
1339
+ hashSequence = cacheready ? cache->hashSequence : SHA256Uint256 ( GetSequencesSHA256 ( txTo) );
1337
1340
}
1338
1341
1339
1342
1340
1343
if ((nHashType & 0x1f ) != SIGHASH_SINGLE && (nHashType & 0x1f ) != SIGHASH_NONE) {
1341
- hashOutputs = cacheready ? cache->hashOutputs : GetOutputsHash ( txTo);
1344
+ hashOutputs = cacheready ? cache->hashOutputs : SHA256Uint256 ( GetOutputsSHA256 ( txTo) );
1342
1345
} else if ((nHashType & 0x1f ) == SIGHASH_SINGLE && nIn < txTo.vout .size ()) {
1343
1346
CHashWriter ss (SER_GETHASH, 0 );
1344
1347
ss << txTo.vout [nIn];
0 commit comments