MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / verify_script

Function verify_script

src/script/bitcoinconsensus.cpp:79–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, CAmount amount,
80 const unsigned char *txTo , unsigned int txToLen,
81 unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
82{
83 if (!verify_flags(flags)) {
84 return set_error(err, bitcoinconsensus_ERR_INVALID_FLAGS);
85 }
86 try {
87 TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen);
88 CTransaction tx(deserialize, stream);
89 if (nIn >= tx.vin.size())
90 return set_error(err, bitcoinconsensus_ERR_TX_INDEX);
91 if (GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) != txToLen)
92 return set_error(err, bitcoinconsensus_ERR_TX_SIZE_MISMATCH);
93
94 // Regardless of the verification result, the tx did not error.
95 set_error(err, bitcoinconsensus_ERR_OK);
96
97 PrecomputedTransactionData txdata(tx);
98 return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), &tx.vin[nIn].scriptWitness, flags, TransactionSignatureChecker(&tx, nIn, amount, txdata), nullptr);
99 } catch (const std::exception&) {
100 return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
101 }
102}
103
104int bitcoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount,
105 const unsigned char *txTo , unsigned int txToLen,

Calls 6

verify_flagsFunction · 0.85
GetSerializeSizeFunction · 0.85
VerifyScriptFunction · 0.85
set_errorFunction · 0.70
CScriptClass · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected