diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1547,14 +1547,11 @@ return ss.GetHash(); } - static const uint256 one(uint256S( - "0000000000000000000000000000000000000000000000000000000000000001")); - // Check for invalid use of SIGHASH_SINGLE if ((sigHashType.getBaseType() == BaseSigHashType::SINGLE) && (nIn >= txTo.vout.size())) { // nOut out of range - return one; + return UINT256_ONE(); } // Wrapper to serialize only the necessary parts of the transaction being diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -26,10 +26,8 @@ // Old script.cpp SignatureHash function static uint256 SignatureHashOld(CScript scriptCode, const CTransaction &txTo, unsigned int nIn, uint32_t nHashType) { - static const uint256 one(uint256S( - "0000000000000000000000000000000000000000000000000000000000000001")); if (nIn >= txTo.vin.size()) { - return one; + return UINT256_ONE(); } CMutableTransaction txTmp(txTo); @@ -58,7 +56,7 @@ // Only lock-in the txout payee at same index as txin unsigned int nOut = nIn; if (nOut >= txTmp.vout.size()) { - return one; + return UINT256_ONE(); } txTmp.vout.resize(nOut + 1); for (size_t i = 0; i < nOut; i++) { diff --git a/src/uint256.h b/src/uint256.h --- a/src/uint256.h +++ b/src/uint256.h @@ -157,4 +157,6 @@ return rv; } +uint256 &UINT256_ONE(); + #endif // BITCOIN_UINT256_H diff --git a/src/uint256.cpp b/src/uint256.cpp --- a/src/uint256.cpp +++ b/src/uint256.cpp @@ -66,3 +66,9 @@ template std::string base_blob<256>::ToString() const; template void base_blob<256>::SetHex(const char *); template void base_blob<256>::SetHex(const std::string &); + +uint256 &UINT256_ONE() { + static uint256 one = uint256S( + "0000000000000000000000000000000000000000000000000000000000000001"); + return one; +} diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -271,8 +271,7 @@ return WalletCreationStatus::SUCCESS; } -const BlockHash CWalletTx::ABANDON_HASH(uint256S( - "0000000000000000000000000000000000000000000000000000000000000001")); +const BlockHash CWalletTx::ABANDON_HASH(UINT256_ONE()); /** @defgroup mapWallet *