17 TxInputStream(
const uint8_t *txTo,
size_t txToLen)
18 : m_data(txTo), m_remaining(txToLen) {}
21 if (dst.
size() > m_remaining) {
22 throw std::ios_base::failure(std::string(__func__) +
26 if (dst.
data() ==
nullptr) {
27 throw std::ios_base::failure(std::string(__func__) +
28 ": bad destination buffer");
31 if (m_data ==
nullptr) {
32 throw std::ios_base::failure(std::string(__func__) +
33 ": bad source buffer");
36 memcpy(dst.
data(), m_data, dst.
size());
37 m_remaining -= dst.
size();
41 template <
typename T> TxInputStream &operator>>(T &&obj) {
47 const uint8_t *m_data;
60struct ECCryptoClosure {
64ECCryptoClosure instance_of_eccryptoclosure;
73 unsigned int scriptPubKeyLen,
Amount amount,
74 const uint8_t *txTo,
unsigned int txToLen,
75 unsigned int nIn,
unsigned int flags,
81 TxInputStream stream{txTo, txToLen};
83 if (nIn >= tx.
vin.size()) {
96 tx.
vin[nIn].scriptSig,
97 CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen),
flags,
99 }
catch (
const std::exception &) {
106 const uint8_t *scriptPubKey,
unsigned int scriptPubKeyLen, int64_t amount,
107 const uint8_t *txTo,
unsigned int txToLen,
unsigned int nIn,
115 unsigned int scriptPubKeyLen,
116 const uint8_t *txTo,
unsigned int txToLen,
117 unsigned int nIn,
unsigned int flags,
125 txToLen, nIn,
flags, err);
static constexpr Amount SATOSHI
static bool verify_flags(unsigned int flags)
Check that all specified flags are part of the libconsensus interface.
unsigned int bitcoinconsensus_version()
int bitcoinconsensus_verify_script(const uint8_t *scriptPubKey, unsigned int scriptPubKeyLen, const uint8_t *txTo, unsigned int txToLen, unsigned int nIn, unsigned int flags, bitcoinconsensus_error *err)
Returns 1 if the input nIn of the serialized transaction pointed to by txTo correctly spends the scri...
int bitcoinconsensus_verify_script_with_amount(const uint8_t *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, const uint8_t *txTo, unsigned int txToLen, unsigned int nIn, unsigned int flags, bitcoinconsensus_error *err)
static int verify_script(const uint8_t *scriptPubKey, unsigned int scriptPubKeyLen, Amount amount, const uint8_t *txTo, unsigned int txToLen, unsigned int nIn, unsigned int flags, bitcoinconsensus_error *err)
enum bitcoinconsensus_error_t bitcoinconsensus_error
@ bitcoinconsensus_SCRIPT_ENABLE_SIGHASH_FORKID
@ bitcoinconsensus_SCRIPT_FLAGS_VERIFY_ALL
@ bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS_DEPRECATED
@ bitcoinconsensus_ERR_OK
@ bitcoinconsensus_ERR_TX_DESERIALIZE
@ bitcoinconsensus_ERR_AMOUNT_REQUIRED
@ bitcoinconsensus_ERR_TX_INDEX
@ bitcoinconsensus_ERR_INVALID_FLAGS
@ bitcoinconsensus_ERR_TX_SIZE_MISMATCH
#define BITCOINCONSENSUS_API_VER
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxIn > vin
Users of this module must hold an ECCVerifyHandle.
A Span is an object that can refer to a contiguous sequence of objects.
constexpr std::size_t size() const noexcept
constexpr C * data() const noexcept
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, uint32_t flags, const BaseSignatureChecker &checker, ScriptExecutionMetrics &metricsOut, ScriptError *serror)
Execute an unlocking and locking script together.
GenericTransactionSignatureChecker< CTransaction > TransactionSignatureChecker
size_t GetSerializeSize(const T &t)
constexpr deserialize_type deserialize
void Unserialize(Stream &, V)=delete
static constexpr Amount zero() noexcept
Precompute sighash midstate to avoid quadratic hashing.