18 TxInputStream(
int nTypeIn,
int nVersionIn,
const uint8_t *txTo,
20 : m_type(nTypeIn), m_version(nVersionIn), m_data(txTo),
21 m_remaining(txToLen) {}
23 void read(
char *pch,
size_t nSize) {
24 if (nSize > m_remaining) {
25 throw std::ios_base::failure(std::string(__func__) +
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(pch, m_data, nSize);
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;
68 struct ECCryptoClosure {
72 ECCryptoClosure 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 zero()
unsigned int bitcoinconsensus_version()
Precompute sighash midstate to avoid quadratic hashing.
constexpr deserialize_type deserialize
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.
static constexpr Amount SATOSHI
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)
const std::vector< CTxIn > vin
size_t GetSerializeSize(const T &t, int nVersion=0)
#define BITCOINCONSENSUS_API_VER
Users of this module must hold an ECCVerifyHandle.
enum bitcoinconsensus_error_t bitcoinconsensus_error
Serialized script, used inside transaction inputs and outputs.
static const int PROTOCOL_VERSION
network protocol versioning
GenericTransactionSignatureChecker< CTransaction > TransactionSignatureChecker
void Unserialize(Stream &s, char &a)
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)
The basic transaction that is broadcasted on the network and contained in blocks. ...
static bool verify_flags(unsigned int flags)
Check that all specified flags are part of the libconsensus interface.