18 TxInputStream(
int nTypeIn,
int nVersionIn,
const uint8_t *txTo,
20 : m_type(nTypeIn), m_version(nVersionIn), m_data(txTo),
21 m_remaining(txToLen) {}
24 if (dst.
size() > m_remaining) {
25 throw std::ios_base::failure(std::string(__func__) +
29 if (dst.
data() ==
nullptr) {
30 throw std::ios_base::failure(std::string(__func__) +
31 ": bad destination buffer");
34 if (m_data ==
nullptr) {
35 throw std::ios_base::failure(std::string(__func__) +
36 ": bad source buffer");
39 memcpy(dst.
data(), m_data, dst.
size());
40 m_remaining -= dst.
size();
44 template <
typename T> TxInputStream &operator>>(T &&obj) {
49 int GetVersion()
const {
return m_version; }
50 int GetType()
const {
return m_type; }
55 const uint8_t *m_data;
68struct ECCryptoClosure {
72ECCryptoClosure instance_of_eccryptoclosure;
81 unsigned int scriptPubKeyLen,
Amount amount,
82 const uint8_t *txTo,
unsigned int txToLen,
83 unsigned int nIn,
unsigned int flags,
91 if (nIn >= tx.
vin.size()) {
104 tx.
vin[nIn].scriptSig,
105 CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen),
flags,
107 }
catch (
const std::exception &) {
114 const uint8_t *scriptPubKey,
unsigned int scriptPubKeyLen, int64_t amount,
115 const uint8_t *txTo,
unsigned int txToLen,
unsigned int nIn,
123 unsigned int scriptPubKeyLen,
124 const uint8_t *txTo,
unsigned int txToLen,
125 unsigned int nIn,
unsigned int flags,
133 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
constexpr deserialize_type deserialize
void Unserialize(Stream &, char)=delete
size_t GetSerializeSize(const T &t, int nVersion=0)
static constexpr Amount zero() noexcept
Precompute sighash midstate to avoid quadratic hashing.
static const int PROTOCOL_VERSION
network protocol versioning