6#ifndef BITCOIN_PRIMITIVES_TRANSACTION_H
7#define BITCOIN_PRIMITIVES_TRANSACTION_H
32 static constexpr uint32_t
NULL_INDEX = std::numeric_limits<uint32_t>::max();
45 return cmp < 0 || (cmp == 0 && a.
n < b.
n);
187template<
typename Stream,
typename TxType>
192 unsigned char flags = 0;
197 if (tx.vin.size() == 0 && fAllowWitness) {
208 if ((
flags & 1) && fAllowWitness) {
211 for (
size_t i = 0; i < tx.vin.size(); i++) {
212 s >> tx.vin[i].scriptWitness.stack;
214 if (!tx.HasWitness()) {
216 throw std::ios_base::failure(
"Superfluous witness record");
221 throw std::ios_base::failure(
"Unknown transaction optional data");
226template<
typename Stream,
typename TxType>
231 unsigned char flags = 0;
235 if (tx.HasWitness()) {
241 std::vector<CTxIn> vinDummy;
248 for (
size_t i = 0; i < tx.vin.size(); i++) {
249 s << tx.vin[i].scriptWitness.stack;
270 const std::vector<CTxIn>
vin;
271 const std::vector<CTxOut>
vout;
288 template <
typename Stream>
295 template <
typename Stream>
299 return vin.empty() &&
vout.empty();
317 return (
vin.size() == 1 &&
vin[0].prevout.IsNull());
334 for (
size_t i = 0; i <
vin.size(); i++) {
354 template <
typename Stream>
360 template <
typename Stream>
365 template <
typename Stream>
377 for (
size_t i = 0; i <
vin.size(); i++) {
int64_t CAmount
Amount in satoshis (Can be negative)
An outpoint - a combination of a transaction hash and an index n into its vout.
COutPoint(const uint256 &hashIn, uint32_t nIn)
friend bool operator!=(const COutPoint &a, const COutPoint &b)
friend bool operator==(const COutPoint &a, const COutPoint &b)
SERIALIZE_METHODS(COutPoint, obj)
friend bool operator<(const COutPoint &a, const COutPoint &b)
std::string ToString() const
static constexpr uint32_t NULL_INDEX
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
const uint256 & GetWitnessHash() const
uint256 ComputeWitnessHash() const
friend bool operator==(const CTransaction &a, const CTransaction &b)
const uint256 & GetHash() const
CTransaction(deserialize_type, Stream &s)
This deserializing constructor is provided instead of an Unserialize method.
CTransaction(const CMutableTransaction &tx)
Convert a CMutableTransaction into a CTransaction.
void Serialize(Stream &s) const
const std::vector< CTxOut > vout
uint256 ComputeHash() const
std::string ToString() const
unsigned int GetTotalSize() const
Get the total transaction size in bytes, including witness data.
CAmount GetValueOut() const
friend bool operator!=(const CTransaction &a, const CTransaction &b)
const std::vector< CTxIn > vin
const uint256 hash
Memory only.
const uint256 m_witness_hash
static const int32_t CURRENT_VERSION
An input of a transaction.
friend bool operator==(const CTxIn &a, const CTxIn &b)
static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG
friend bool operator!=(const CTxIn &a, const CTxIn &b)
static const uint32_t SEQUENCE_LOCKTIME_MASK
static const uint32_t SEQUENCE_FINAL
std::string ToString() const
static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG
CScriptWitness scriptWitness
Only serialized through CTransaction.
static const int SEQUENCE_LOCKTIME_GRANULARITY
SERIALIZE_METHODS(CTxIn, obj)
An output of a transaction.
SERIALIZE_METHODS(CTxOut, obj)
friend bool operator==(const CTxOut &a, const CTxOut &b)
friend bool operator!=(const CTxOut &a, const CTxOut &b)
std::string ToString() const
A generic txid reference (txid or wtxid).
const uint256 & GetHash() const
friend bool operator<(const GenTxid &a, const GenTxid &b)
static GenTxid Wtxid(const uint256 &hash)
GenTxid(bool is_wtxid, const uint256 &hash)
friend bool operator==(const GenTxid &a, const GenTxid &b)
static GenTxid Txid(const uint256 &hash)
int Compare(const base_blob &other) const
static const int SERIALIZE_TRANSACTION_NO_WITNESS
A flag that is ORed into the protocol version to designate that a transaction should be (un)serialize...
void UnserializeTransaction(TxType &tx, Stream &s)
Basic transaction serialization format:
void SerializeTransaction(const TxType &tx, Stream &s)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
constexpr deserialize_type deserialize
A mutable version of CTransaction.
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
void Unserialize(Stream &s)
void Serialize(Stream &s) const
CMutableTransaction(deserialize_type, Stream &s)
std::vector< CTxOut > vout
Dummy data type to identify deserializing constructors.