Пример #1
0
        private bool VerifyScript(TransactionValidator validator, int inputIndex, out ScriptError?error)
        {
#if !NOCONSENSUSLIB
            if (!UseConsensusLib)
#endif
            {
                var res = validator.ValidateInput(inputIndex);
                if (res.Error is ScriptError err)
                {
                    error = err;
                    return(false);
                }
                error = null;
                return(true);
            }
#if !NOCONSENSUSLIB
            else
            {
                var scriptVerify = validator.ScriptVerify;
                if (validator.Transaction is IHasForkId)
                {
                    scriptVerify |= (NBitcoin.ScriptVerify)(1U << 16);
                }
                var ok = Script.VerifyScriptConsensus(validator.SpentOutputs[inputIndex].ScriptPubKey, validator.Transaction, (uint)inputIndex, scriptVerify);
                if (!ok)
                {
                    if (!validator.TryValidateInput(inputIndex, out var res) && res.Error is ScriptError err)
                    {
                        error = err;
                    }
                    else
                    {
                        error = ScriptError.UnknownError;
                    }
                    return(false);
                }
                else
                {
                    error = ScriptError.OK;
                }
                return(true);
            }
#endif
        }