diff --git a/src/callrpc.cpp b/src/callrpc.cpp index 07c918292f..e7c912839e 100644 --- a/src/callrpc.cpp +++ b/src/callrpc.cpp @@ -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"); diff --git a/src/callrpc.h b/src/callrpc.h index ec2801d177..8557aa23ca 100644 --- a/src/callrpc.h +++ b/src/callrpc.h @@ -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 diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index d63e8285d9..2e97f6f3c6 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1580,7 +1580,7 @@ bool EvalScript(vector >& 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 diff --git a/src/script/interpreter.h b/src/script/interpreter.h index 308041866a..ff3ac36ead 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -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;