MCPcopy Create free account
hub / github.com/LUX-Core/lux / verify_script

Function verify_script

src/script/bitcoinconsensus.cpp:73–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71} // anon namespace
72
73static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, CAmount amount,
74 const unsigned char *txTo , unsigned int txToLen,
75 unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
76{
77 try {
78 TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen);
79 CTransaction tx;
80 stream >> tx;
81 if (nIn >= tx.vin.size())
82 return set_error(err, bitcoinconsensus_ERR_TX_INDEX);
83 if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) != txToLen)
84 return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH);
85
86 // Regardless of the verification result, the tx did not error.
87 set_error(err, bitcoinconsensus_ERR_OK);
88 PrecomputedTransactionData txdata(tx);
89 return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), nIn < tx.wit.vtxinwit.size() ? &tx.wit.vtxinwit[nIn].scriptWitness : NULL, flags, TransactionSignatureChecker(&tx, nIn, amount, txdata), NULL);
90 } catch (const std::exception&) {
91 return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
92 }
93}
94
95int bitcoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount,
96 const unsigned char *txTo , unsigned int txToLen,

Calls 6

VerifyScriptFunction · 0.85
set_errorFunction · 0.70
CScriptClass · 0.70
sizeMethod · 0.45
GetSerializeSizeMethod · 0.45

Tested by

no test coverage detected