18 TxInputStream(
const unsigned char *txTo,
size_t txToLen) :
25 if (dst.
size() > m_remaining) {
26 throw std::ios_base::failure(std::string(__func__) +
": end of data");
29 if (dst.
data() ==
nullptr) {
30 throw std::ios_base::failure(std::string(__func__) +
": bad destination buffer");
33 if (m_data ==
nullptr) {
34 throw std::ios_base::failure(std::string(__func__) +
": bad source buffer");
37 memcpy(dst.
data(), m_data, dst.
size());
38 m_remaining -= dst.
size();
50 const unsigned char* m_data;
70 const unsigned char *txTo ,
unsigned int txToLen,
71 const UTXO *spentOutputs,
unsigned int spentOutputsLen,
83 TxInputStream stream(txTo, txToLen);
86 std::vector<CTxOut> spent_outputs;
87 if (spentOutputs !=
nullptr) {
88 if (spentOutputsLen != tx.
vin.size()) {
91 for (
size_t i = 0; i < spentOutputsLen; i++) {
92 CScript spk =
CScript(spentOutputs[i].scriptPubKey, spentOutputs[i].scriptPubKey + spentOutputs[i].scriptPubKeySize);
95 spent_outputs.push_back(tx_out);
99 if (nIn >= tx.
vin.size())
110 txdata.
Init(tx, std::move(spent_outputs));
113 return VerifyScript(tx.
vin[nIn].scriptSig,
CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), &tx.
vin[nIn].scriptWitness,
flags,
TransactionSignatureChecker(&tx, nIn, amount, txdata,
MissingDataBehavior::FAIL),
nullptr);
114 }
catch (
const std::exception&) {
120 const unsigned char *txTo ,
unsigned int txToLen,
121 const UTXO *spentOutputs,
unsigned int spentOutputsLen,
129 const unsigned char *txTo ,
unsigned int txToLen,
133 UTXO *spentOutputs =
nullptr;
134 unsigned int spentOutputsLen = 0;
140 const unsigned char *txTo ,
unsigned int txToLen,
148 UTXO *spentOutputs =
nullptr;
149 unsigned int spentOutputsLen = 0;
int64_t CAmount
Amount in satoshis (Can be negative)
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 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...
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)
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)
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)
enum bitcoinconsensus_error_t bitcoinconsensus_error
@ bitcoinconsensus_ERR_OK
@ bitcoinconsensus_ERR_SPENT_OUTPUTS_MISMATCH
@ bitcoinconsensus_ERR_TX_DESERIALIZE
@ bitcoinconsensus_ERR_AMOUNT_REQUIRED
@ bitcoinconsensus_ERR_TX_INDEX
@ bitcoinconsensus_ERR_INVALID_FLAGS
@ bitcoinconsensus_ERR_TX_SIZE_MISMATCH
@ bitcoinconsensus_ERR_SPENT_OUTPUTS_REQUIRED
@ bitcoinconsensus_SCRIPT_FLAGS_VERIFY_ALL
@ bitcoinconsensus_SCRIPT_FLAGS_VERIFY_TAPROOT
@ bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS
#define BITCOINCONSENSUS_API_VER
QDataStream & operator>>(QDataStream &in, BitcoinUnit &unit)
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
An output of a transaction.
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, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
@ FAIL
Just act as if the signature was invalid.
static constexpr TransactionSerParams TX_WITH_WITNESS
size_t GetSerializeSize(const T &t)
constexpr deserialize_type deserialize
void Unserialize(Stream &, V)=delete
void Init(const T &tx, std::vector< CTxOut > &&spent_outputs, bool force=false)
Initialize this PrecomputedTransactionData with transaction data.