mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 23:42:33 +02:00
Ability to ignore AreInputsStandard rejection reasons
This commit is contained in:
parent
d5b82da92c
commit
d07c82ce6a
@ -194,7 +194,7 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat
|
||||
*
|
||||
* Note that only the non-witness portion of the transaction is checked here.
|
||||
*/
|
||||
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const std::string& reason_prefix, std::string& out_reason)
|
||||
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const std::string& reason_prefix, std::string& out_reason, const ignore_rejects_type& ignore_rejects)
|
||||
{
|
||||
if (tx.IsCoinBase()) {
|
||||
return true; // Coinbases don't use vin normally
|
||||
@ -206,32 +206,37 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs,
|
||||
std::vector<std::vector<unsigned char> > vSolutions;
|
||||
TxoutType whichType = Solver(prev.scriptPubKey, vSolutions);
|
||||
if (whichType == TxoutType::NONSTANDARD) {
|
||||
out_reason = reason_prefix + "script-unknown";
|
||||
return false;
|
||||
MaybeReject("script-unknown");
|
||||
} else if (whichType == TxoutType::WITNESS_UNKNOWN) {
|
||||
// WITNESS_UNKNOWN failures are typically also caught with a policy
|
||||
// flag in the script interpreter, but it can be helpful to catch
|
||||
// this type of NONSTANDARD transaction earlier in transaction
|
||||
// validation.
|
||||
out_reason = reason_prefix + "witness-unknown";
|
||||
return false;
|
||||
MaybeReject("witness-unknown");
|
||||
} else if (whichType == TxoutType::SCRIPTHASH) {
|
||||
if (!tx.vin[i].scriptSig.IsPushOnly()) {
|
||||
// The only way we got this far, is if the user ignored scriptsig-not-pushonly.
|
||||
// However, this case is invalid, and will be caught later on.
|
||||
// But for now, we don't want to run the [possibly expensive] script here.
|
||||
continue;
|
||||
}
|
||||
std::vector<std::vector<unsigned char> > stack;
|
||||
// convert the scriptSig into a stack, so we can inspect the redeemScript
|
||||
if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE))
|
||||
{
|
||||
// This case is also invalid or a bug
|
||||
out_reason = reason_prefix + "scriptsig-failure";
|
||||
return false;
|
||||
}
|
||||
if (stack.empty())
|
||||
{
|
||||
// Also invalid
|
||||
out_reason = reason_prefix + "scriptcheck-missing";
|
||||
return false;
|
||||
}
|
||||
CScript subscript(stack.back().begin(), stack.back().end());
|
||||
if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) {
|
||||
out_reason = reason_prefix + "scriptcheck-sigops";
|
||||
return false;
|
||||
MaybeReject("scriptcheck-sigops");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ bool IsStandardTx(const CTransaction& tx, const std::optional<unsigned>& max_dat
|
||||
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
|
||||
* @return True if all inputs (scriptSigs) use only standard transaction forms
|
||||
*/
|
||||
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const std::string& reason_prefix, std::string& out_reason);
|
||||
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs, const std::string& reason_prefix, std::string& out_reason, const ignore_rejects_type& ignore_rejects=empty_ignore_rejects);
|
||||
|
||||
inline bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) {
|
||||
std::string reason;
|
||||
|
@ -841,7 +841,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
||||
return false; // state filled in by CheckTxInputs
|
||||
}
|
||||
|
||||
if (m_pool.m_require_standard && !AreInputsStandard(tx, m_view, "bad-txns-input-", reason)) {
|
||||
if (m_pool.m_require_standard && !AreInputsStandard(tx, m_view, "bad-txns-input-", reason, ignore_rejects)) {
|
||||
return state.Invalid(TxValidationResult::TX_INPUTS_NOT_STANDARD, reason);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user