7 #if defined(HAVE_CONSENSUS_LIB)
24 const int witnessversion = 0;
28 static const std::array<unsigned char, 32> vchKey = {
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
33 key.
Set(vchKey.begin(), vchKey.end(),
false);
45 witness.
stack.emplace_back();
54 txSpend.
vin[0].scriptSig,
55 txCredit.
vout[0].scriptPubKey,
56 &txSpend.
vin[0].scriptWitness,
63 #if defined(HAVE_CONSENSUS_LIB)
67 txCredit.
vout[0].scriptPubKey.data(),
68 txCredit.
vout[0].scriptPubKey.size(),
69 txCredit.
vout[0].nValue,
70 (
const unsigned char*)stream.
data(), stream.
size(), 0,
flags,
nullptr);
79 std::vector<std::vector<unsigned char>> stack;
81 for (
int i = 0; i < 100; ++i) {
84 for (
int i = 0; i < 1000; ++i) {
87 for (
int i = 0; i < 100; ++i) {
91 auto stack_copy = stack;
int bitcoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, const unsigned char *txTo, unsigned int txToLen, unsigned int nIn, unsigned int flags, bitcoinconsensus_error *err)
A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160).
void Finalize(Span< unsigned char > output)
CHash160 & Write(Span< const unsigned char > input)
An encapsulated private key.
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig, bool grind=true, uint32_t test_case=0) const
Create a DER-serialized signature.
CPubKey GetPubKey() const
Compute the public key from a private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
Double ended buffer combining vector and stream-like interfaces.
Main entry point to nanobench's benchmarking facility.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
uint256 SignatureHash(const CScript &scriptCode, const T &txTo, unsigned int nIn, int nHashType, const CAmount &amount, SigVersion sigversion, const PrecomputedTransactionData *cache)
bool EvalScript(std::vector< std::vector< unsigned char > > &stack, const CScript &script, unsigned int flags, const BaseSignatureChecker &checker, SigVersion sigversion, ScriptExecutionData &execdata, ScriptError *serror)
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
@ BASE
Bare scripts and BIP16 P2SH-wrapped redeemscripts.
@ WITNESS_V0
Witness v0 (P2WPKH and P2WSH); see BIP 141.
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code)
bool error(const char *fmt, const Args &... args)
static constexpr TransactionSerParams TX_WITH_WITNESS
std::vector< unsigned char > ToByteVector(const T &in)
enum ScriptError_t ScriptError
A mutable version of CTransaction.
std::vector< CTxOut > vout
std::vector< std::vector< unsigned char > > stack
CMutableTransaction BuildSpendingTransaction(const CScript &scriptSig, const CScriptWitness &scriptWitness, const CTransaction &txCredit)
CMutableTransaction BuildCreditingTransaction(const CScript &scriptPubKey, int nValue)
BENCHMARK(VerifyScriptBench, benchmark::PriorityLevel::HIGH)
static void VerifyScriptBench(benchmark::Bench &bench)
static void VerifyNestedIfScript(benchmark::Bench &bench)