7#ifndef BITCOIN_PRIMITIVES_TRANSACTION_H
8#define BITCOIN_PRIMITIVES_TRANSACTION_H
39 int cmp =
a.txid.Compare(
b.txid);
40 return cmp < 0 || (
cmp == 0 &&
a.n <
b.n);
44 return (
a.txid ==
b.txid &&
a.n ==
b.n);
115 return (
a.prevout ==
b.prevout &&
a.scriptSig ==
b.scriptSig &&
116 a.nSequence ==
b.nSequence);
148 return (
a.nValue ==
b.nValue &&
a.scriptPubKey ==
b.scriptPubKey);
167template <
typename Stream,
typename TxType>
180template <
typename Stream,
typename TxType>
206 const std::vector<CTxIn>
vin;
207 const std::vector<CTxOut>
vout;
234 template <
typename Stream>
253 return (
vin.size() == 1 &&
vin[0].prevout.IsNull());
257 return a.GetHash() ==
b.GetHash();
266#if defined(__x86_64__)
268 "sizeof CTransaction is expected to be 88 bytes");
292 template <
typename Stream>
307 return a.GetHash() ==
b.GetHash();
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
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
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
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.