7#ifndef BITCOIN_PRIMITIVES_TRANSACTION_H
8#define BITCOIN_PRIMITIVES_TRANSACTION_H
26 static constexpr uint32_t
NULL_INDEX = std::numeric_limits<uint32_t>::max();
36 uint32_t
GetN()
const {
return n; }
40 return cmp < 0 || (cmp == 0 && a.
n < b.
n);
111 READWRITE(obj.prevout, obj.scriptSig, obj.nSequence);
167template <
typename Stream,
typename TxType>
180template <
typename Stream,
typename TxType>
206 const std::vector<CTxIn>
vin;
207 const std::vector<CTxOut>
vout;
225 template <
typename Stream>
inline void Serialize(Stream &s)
const {
234 template <
typename Stream>
253 return (
vin.size() == 1 &&
vin[0].prevout.IsNull());
266#if defined(__x86_64__)
268 "sizeof CTransaction is expected to be 88 bytes");
284 template <
typename Stream>
inline void Serialize(Stream &s)
const {
292 template <
typename Stream>
310#if defined(__x86_64__)
312 "sizeof CMutableTransaction is expected to be 56 bytes");
317 return std::make_shared<const CTransaction>();
319template <
typename Tx>
321 return std::make_shared<const CTransaction>(std::forward<Tx>(txIn));
static constexpr Amount SATOSHI
A mutable version of CTransaction.
friend bool operator==(const CMutableTransaction &a, const CMutableTransaction &b)
void Unserialize(Stream &s)
void Serialize(Stream &s) const
TxId GetId() const
Compute the id and hash of this CMutableTransaction.
CMutableTransaction(deserialize_type, Stream &s)
std::vector< CTxOut > vout
An outpoint - a combination of a transaction hash and an index n into its vout.
friend bool operator!=(const COutPoint &a, const COutPoint &b)
friend bool operator==(const COutPoint &a, const COutPoint &b)
SERIALIZE_METHODS(COutPoint, obj)
const TxId & GetTxId() const
friend bool operator<(const COutPoint &a, const COutPoint &b)
COutPoint(TxId txidIn, uint32_t nIn)
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.
friend bool operator==(const CTransaction &a, const CTransaction &b)
static constexpr int32_t MAX_VERSION
CTransaction()
Construct a CTransaction that qualifies as IsNull()
CTransaction(deserialize_type, Stream &s)
This deserializing constructor is provided instead of an Unserialize method.
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.
Amount GetValueOut() const
friend bool operator!=(const CTransaction &a, const CTransaction &b)
const TxHash GetHash() const
const std::vector< CTxIn > vin
static constexpr int32_t MIN_VERSION
const uint256 hash
Memory only.
static constexpr 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
If this flag set, CTxIn::nSequence is NOT interpreted as a relative lock-time.
friend bool operator!=(const CTxIn &a, const CTxIn &b)
static const uint32_t SEQUENCE_LOCKTIME_MASK
If CTxIn::nSequence encodes a relative lock-time, this mask is applied to extract that lock-time from...
static const uint32_t SEQUENCE_FINAL
Setting nSequence to this value for every input in a transaction disables nLockTime.
CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL)
CTxIn(TxId prevTxId, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL)
std::string ToString() const
static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG
If CTxIn::nSequence encodes a relative lock-time and this flag is set, the relative lock-time has uni...
static const int SEQUENCE_LOCKTIME_GRANULARITY
In order to use the same number of bits to encode roughly the same wall-clock duration,...
SERIALIZE_METHODS(CTxIn, obj)
An output of a transaction.
SERIALIZE_METHODS(CTxOut, obj)
CTxOut(Amount nValueIn, CScript scriptPubKeyIn)
friend bool operator==(const CTxOut &a, const CTxOut &b)
friend bool operator!=(const CTxOut &a, const CTxOut &b)
std::string ToString() const
int Compare(const base_blob &other) const
void UnserializeTransaction(TxType &tx, Stream &s)
Basic transaction serialization format:
void SerializeTransaction(const TxType &tx, Stream &s)
static CTransactionRef MakeTransactionRef()
std::shared_ptr< const CTransaction > CTransactionRef
constexpr deserialize_type deserialize
Precompute sighash midstate to avoid quadratic hashing.
PrecomputedTransactionData & operator=(const PrecomputedTransactionData &txdata)=default
PrecomputedTransactionData()
PrecomputedTransactionData(const PrecomputedTransactionData &txdata)=default
A TxHash is the double sha256 hash of the full transaction data.
A TxId is the identifier of a transaction.
Dummy data type to identify deserializing constructors.