mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
refactor: define a UINT256_ONE global constant
Borrowed from https://github.com/bitcoin/bitcoin/pull/17261, commit 4977c30d59
This commit is contained in:
parent
d2d7febd0e
commit
93a01604c3
@ -1466,13 +1466,11 @@ uint256 SignatureHash(const CScript& scriptCode, const T& txTo, unsigned int nIn
|
||||
{
|
||||
assert(nIn < txTo.vin.size());
|
||||
|
||||
static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
|
||||
|
||||
// Check for invalid use of SIGHASH_SINGLE
|
||||
if ((nHashType & 0x1f) == SIGHASH_SINGLE) {
|
||||
if (nIn >= txTo.vout.size()) {
|
||||
// nOut out of range
|
||||
return one;
|
||||
return UINT256_ONE();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,10 +23,9 @@ extern UniValue read_json(const std::string& jsondata);
|
||||
// Old script.cpp SignatureHash function
|
||||
uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType)
|
||||
{
|
||||
static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
|
||||
if (nIn >= txTo.vin.size())
|
||||
{
|
||||
return one;
|
||||
return UINT256_ONE();
|
||||
}
|
||||
CMutableTransaction txTmp(txTo);
|
||||
|
||||
@ -56,7 +55,7 @@ uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, un
|
||||
unsigned int nOut = nIn;
|
||||
if (nOut >= txTmp.vout.size())
|
||||
{
|
||||
return one;
|
||||
return UINT256_ONE();
|
||||
}
|
||||
txTmp.vout.resize(nOut+1);
|
||||
for (unsigned int i = 0; i < nOut; i++)
|
||||
|
@ -80,3 +80,8 @@ template std::string base_blob<256>::GetHex() const;
|
||||
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 = new uint256(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
|
||||
return *one;
|
||||
}
|
||||
|
@ -148,6 +148,8 @@ inline uint256 uint256S(const std::string& str)
|
||||
return rv;
|
||||
}
|
||||
|
||||
uint256& UINT256_ONE();
|
||||
|
||||
/** 512-bit unsigned big integer. */
|
||||
class uint512 : public base_blob<512> {
|
||||
public:
|
||||
|
@ -327,7 +327,7 @@ WalletCreationStatus CreateWallet(interfaces::Chain& chain, const SecureString&
|
||||
return WalletCreationStatus::SUCCESS;
|
||||
}
|
||||
|
||||
const uint256 CWalletTx::ABANDON_HASH(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
|
||||
const uint256 CWalletTx::ABANDON_HASH(UINT256_ONE());
|
||||
|
||||
/** @defgroup mapWallet
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user