| 77 | } |
| 78 | |
| 79 | static 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 | |
| 104 | int bitcoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, |
| 105 | const unsigned char *txTo , unsigned int txToLen, |
no test coverage detected