19 TxInputStream(
int nVersionIn,
const unsigned char *txTo,
size_t txToLen) :
20 m_version(nVersionIn),
27 if (dst.
size() > m_remaining) {
28 throw std::ios_base::failure(std::string(__func__) +
": end of data");
31 if (dst.
data() ==
nullptr) {
32 throw std::ios_base::failure(std::string(__func__) +
": bad destination buffer");
35 if (m_data ==
nullptr) {
36 throw std::ios_base::failure(std::string(__func__) +
": bad source buffer");
39 memcpy(dst.
data(), m_data, dst.
size());
40 m_remaining -= dst.
size();
51 int GetVersion()
const {
return m_version; }
54 const unsigned char* m_data;
74 const unsigned char *txTo ,
unsigned int txToLen,
75 const UTXO *spentOutputs,
unsigned int spentOutputsLen,
90 std::vector<CTxOut> spent_outputs;
91 if (spentOutputs !=
nullptr) {
92 if (spentOutputsLen != tx.
vin.size()) {
95 for (
size_t i = 0; i < spentOutputsLen; i++) {
96 CScript spk =
CScript(spentOutputs[i].scriptPubKey, spentOutputs[i].scriptPubKey + spentOutputs[i].scriptPubKeySize);
99 spent_outputs.push_back(tx_out);
103 if (nIn >= tx.
vin.size())
114 txdata.
Init(tx, std::move(spent_outputs));
117 return VerifyScript(tx.
vin[nIn].scriptSig,
CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), &tx.
vin[nIn].scriptWitness,
flags,
TransactionSignatureChecker(&tx, nIn, amount, txdata,
MissingDataBehavior::FAIL),
nullptr);
118 }
catch (
const std::exception&) {
124 const unsigned char *txTo ,
unsigned int txToLen,
125 const UTXO *spentOutputs,
unsigned int spentOutputsLen,
133 const unsigned char *txTo ,
unsigned int txToLen,
137 UTXO *spentOutputs =
nullptr;
138 unsigned int spentOutputsLen = 0;
144 const unsigned char *txTo ,
unsigned int txToLen,
152 UTXO *spentOutputs =
nullptr;
153 unsigned int spentOutputsLen = 0;
unsigned int bitcoinconsensus_version()
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
void Unserialize(Stream &, char)=delete
constexpr deserialize_type deserialize
constexpr std::size_t size() const noexcept
int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, const unsigned char *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...
QDataStream & operator>>(QDataStream &in, BitcoinUnit &unit)
const std::vector< CTxIn > vin
size_t GetSerializeSize(const T &t, int nVersion=0)
#define BITCOINCONSENSUS_API_VER
int bitcoinconsensus_verify_script_with_spent_outputs(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, const unsigned char *txTo, unsigned int txToLen, const UTXO *spentOutputs, unsigned int spentOutputsLen, unsigned int nIn, unsigned int flags, bitcoinconsensus_error *err)
int64_t CAmount
Amount in satoshis (Can be negative)
enum bitcoinconsensus_error_t bitcoinconsensus_error
void Init(const T &tx, std::vector< CTxOut > &&spent_outputs, bool force=false)
Initialize this PrecomputedTransactionData with transaction data.
static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, CAmount amount, const unsigned char *txTo, unsigned int txToLen, const UTXO *spentOutputs, unsigned int spentOutputsLen, unsigned int nIn, unsigned int flags, bitcoinconsensus_error *err)
Just act as if the signature was invalid.
An output of a transaction.
int bitcoinconsensus_verify_script_with_amount(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, int64_t amount, const unsigned char *txTo, unsigned int txToLen, unsigned int nIn, unsigned int flags, bitcoinconsensus_error *err)
constexpr C * data() const noexcept
Serialized script, used inside transaction inputs and outputs.
static const int PROTOCOL_VERSION
network protocol versioning
A Span is an object that can refer to a contiguous sequence of objects.
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.