Skip to content

Commit 14319cf

Browse files
committed
[Backport] Replace uint256(1) with static constant.
SignatureHash and its test function SignatureHashOld return uint256(1) as a special error signaling value. Return a local static constant with the same value instead.
1 parent d96eab9 commit 14319cf

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/script/interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,14 +1091,14 @@ uint256 SignatureHash(const CScript& scriptCode, const CTransaction& txTo, unsig
10911091
{
10921092
if (nIn >= txTo.vin.size()) {
10931093
// nIn out of range
1094-
return 1;
1094+
return UINT256_ONE;
10951095
}
10961096

10971097
// Check for invalid use of SIGHASH_SINGLE
10981098
if ((nHashType & 0x1f) == SIGHASH_SINGLE) {
10991099
if (nIn >= txTo.vout.size()) {
11001100
// nOut out of range
1101-
return 1;
1101+
return UINT256_ONE;
11021102
}
11031103
}
11041104

src/test/sighash_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, un
2828
if (nIn >= txTo.vin.size())
2929
{
3030
printf("ERROR: SignatureHash() : nIn=%d out of range\n", nIn);
31-
return 1;
31+
return UINT256_ONE;
3232
}
3333
CMutableTransaction txTmp(txTo);
3434

@@ -59,7 +59,7 @@ uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, un
5959
if (nOut >= txTmp.vout.size())
6060
{
6161
printf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut);
62-
return 1;
62+
return UINT256_ONE;
6363
}
6464
txTmp.vout.resize(nOut+1);
6565
for (unsigned int i = 0; i < nOut; i++)

src/uint256.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,5 +418,6 @@ inline uint512 uint512S(const std::string& str)
418418

419419
/** constant uint256 instances */
420420
const uint256 UINT256_ZERO = uint256();
421+
const uint256 UINT256_ONE = uint256("0000000000000000000000000000000000000000000000000000000000000001");
421422

422423
#endif // PIVX_UINT256_H

0 commit comments

Comments
 (0)