mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Remove unnecessary genesis hash check in IsConfirmedBitcoinBlock
This commit is contained in:
parent
42b6330e14
commit
25c8a49b32
4 changed files with 9 additions and 21 deletions
|
|
@ -178,27 +178,15 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params, bool conn
|
|||
return reply;
|
||||
}
|
||||
|
||||
bool IsConfirmedBitcoinBlock(const uint256& genesishash, const uint256& hash, int nMinConfirmationDepth)
|
||||
bool IsConfirmedBitcoinBlock(const uint256& hash, int nMinConfirmationDepth)
|
||||
{
|
||||
|
||||
try {
|
||||
UniValue params(UniValue::VARR);
|
||||
params.push_back(UniValue(0));
|
||||
UniValue reply = CallRPC("getblockhash", params, true);
|
||||
params.push_back(hash.GetHex());
|
||||
UniValue reply = CallRPC("getblockheader", params, true);
|
||||
if (!find_value(reply, "error").isNull())
|
||||
return false;
|
||||
UniValue result = find_value(reply, "result");
|
||||
if (!result.isStr())
|
||||
return false;
|
||||
if (result.get_str() != genesishash.GetHex())
|
||||
return false;
|
||||
|
||||
params = UniValue(UniValue::VARR);
|
||||
params.push_back(hash.GetHex());
|
||||
reply = CallRPC("getblockheader", params, true);
|
||||
if (!find_value(reply, "error").isNull())
|
||||
return false;
|
||||
result = find_value(reply, "result");
|
||||
if (!result.isObject())
|
||||
return false;
|
||||
result = find_value(result.get_obj(), "confirmations");
|
||||
|
|
|
|||
|
|
@ -35,6 +35,6 @@ public:
|
|||
};
|
||||
|
||||
UniValue CallRPC(const std::string& strMethod, const UniValue& params, bool connectToMainchain=false);
|
||||
bool IsConfirmedBitcoinBlock(const uint256& genesishash, const uint256& hash, int nMinConfirmationDepth);
|
||||
bool IsConfirmedBitcoinBlock(const uint256& hash, int nMinConfirmationDepth);
|
||||
|
||||
#endif // BITCOIN_CALLRPC_H
|
||||
|
|
|
|||
|
|
@ -1580,7 +1580,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
|||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_OUTPUT_SCRIPT);
|
||||
|
||||
#ifndef BITCOIN_SCRIPT_NO_CALLRPC
|
||||
if (GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN) && !checker.IsConfirmedBitcoinBlock(genesishash, merkleBlock.header.GetHash(), flags & SCRIPT_VERIFY_INCREASE_CONFIRMATIONS_REQUIRED, GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH)))
|
||||
if (GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN) && !checker.IsConfirmedBitcoinBlock(merkleBlock.header.GetHash(), flags & SCRIPT_VERIFY_INCREASE_CONFIRMATIONS_REQUIRED, GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH)))
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_BLOCKCONFIRMED);
|
||||
#endif
|
||||
} catch (std::exception& e) {
|
||||
|
|
@ -1975,10 +1975,10 @@ CConfidentialValue TransactionSignatureChecker::GetValueInPrevIn() const
|
|||
return amountPreviousInput;
|
||||
}
|
||||
|
||||
bool TransactionSignatureChecker::IsConfirmedBitcoinBlock(const uint256& genesishash, const uint256& hash, bool fConservativeConfirmationRequirements, uint32_t nConfirmationsRequired) const
|
||||
bool TransactionSignatureChecker::IsConfirmedBitcoinBlock(const uint256& hash, bool fConservativeConfirmationRequirements, uint32_t nConfirmationsRequired) const
|
||||
{
|
||||
#ifndef BITCOIN_SCRIPT_NO_CALLRPC
|
||||
return ::IsConfirmedBitcoinBlock(genesishash, hash, nConfirmationsRequired + (fConservativeConfirmationRequirements ? 2 : 0));
|
||||
return ::IsConfirmedBitcoinBlock(hash, nConfirmationsRequired + (fConservativeConfirmationRequirements ? 2 : 0));
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ public:
|
|||
return -1;
|
||||
}
|
||||
|
||||
virtual bool IsConfirmedBitcoinBlock(const uint256& genesishash, const uint256& hash, bool fConservativeConfirmationRequirements, uint32_t nConfirmationsRequired) const
|
||||
virtual bool IsConfirmedBitcoinBlock(const uint256& hash, bool fConservativeConfirmationRequirements, uint32_t nConfirmationsRequired) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -219,7 +219,7 @@ public:
|
|||
COutPoint GetPrevOut() const;
|
||||
CConfidentialValue GetValueIn() const;
|
||||
CConfidentialValue GetValueInPrevIn() const;
|
||||
bool IsConfirmedBitcoinBlock(const uint256& genesishash, const uint256& hash, bool fConservativeConfirmationRequirements, uint32_t nConfirmationsRequired) const;
|
||||
bool IsConfirmedBitcoinBlock(const uint256& hash, bool fConservativeConfirmationRequirements, uint32_t nConfirmationsRequired) const;
|
||||
virtual CScript GetFedpegScript() const
|
||||
{
|
||||
return fedpegScript;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue