7 #ifndef BITCOIN_PRIMITIVES_TRANSACTION_H 8 #define BITCOIN_PRIMITIVES_TRANSACTION_H 28 static constexpr uint32_t
NULL_INDEX = std::numeric_limits<uint32_t>::max();
35 template <
typename Stream,
typename Operation>
44 uint32_t
GetN()
const {
return n; }
48 return cmp < 0 || (cmp == 0 && a.
n < b.
n);
77 static const uint32_t SEQUENCE_FINAL = 0xffffffff;
84 static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG = (1U << 31);
91 static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22);
97 static const uint32_t SEQUENCE_LOCKTIME_MASK = 0x0000ffff;
107 static const int SEQUENCE_LOCKTIME_GRANULARITY = 9;
109 CTxIn() { nSequence = SEQUENCE_FINAL; }
112 uint32_t nSequenceIn = SEQUENCE_FINAL)
113 : prevout(prevoutIn), scriptSig(scriptSigIn), nSequence(nSequenceIn) {}
115 uint32_t nSequenceIn = SEQUENCE_FINAL)
120 template <
typename Stream,
typename Operation>
149 : nValue(nValueIn), scriptPubKey(scriptPubKeyIn) {}
153 template <
typename Stream,
typename Operation>
161 scriptPubKey.
clear();
186 template <
typename Stream,
typename TxType>
199 template <
typename Stream,
typename TxType>
214 static const int32_t CURRENT_VERSION = 2;
220 static const int32_t MAX_STANDARD_VERSION = 2;
227 const std::vector<CTxIn>
vin;
228 const std::vector<CTxOut>
vout;
246 template <
typename Stream>
inline void Serialize(Stream &s)
const {
255 template <
typename Stream>
259 bool IsNull()
const {
return vin.empty() && vout.empty(); }
265 Amount GetValueOut()
const;
273 unsigned int GetTotalSize()
const;
276 return (vin.size() == 1 && vin[0].prevout.IsNull());
289 #if defined(__x86_64__) 291 "sizeof CTransaction is expected to be 88 bytes");
307 template <
typename Stream>
inline void Serialize(Stream &s)
const {
315 template <
typename Stream>
333 #if defined(__x86_64__) 335 "sizeof CMutableTransaction is expected to be 56 bytes");
340 return std::make_shared<const CTransaction>();
342 template <
typename Tx>
344 return std::make_shared<const CTransaction>(std::forward<Tx>(txIn));
352 : hashPrevouts(), hashSequence(), hashOutputs() {}
360 #endif // BITCOIN_PRIMITIVES_TRANSACTION_H std::shared_ptr< const CTransaction > CTransactionRef
friend bool operator!=(const COutPoint &a, const COutPoint &b)
void Unserialize(Stream &s)
CTxIn(TxId prevTxId, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL)
Precompute sighash midstate to avoid quadratic hashing.
constexpr deserialize_type deserialize
static CTransactionRef MakeTransactionRef()
friend bool operator==(const CTxOut &a, const CTxOut &b)
const TxId & GetTxId() const
const TxHash GetHash() const
static constexpr Amount SATOSHI
void SerializationOp(Stream &s, Operation ser_action)
std::vector< CTxOut > vout
PrecomputedTransactionData()
std::string ToString() const
friend bool operator!=(const CTxOut &a, const CTxOut &b)
const uint256 hash
Memory only.
Dummy data type to identify deserializing constructors.
const std::vector< CTxIn > vin
friend bool operator==(const COutPoint &a, const COutPoint &b)
CMutableTransaction(deserialize_type, Stream &s)
CTxOut(Amount nValueIn, CScript scriptPubKeyIn)
int Compare(const base_blob &other) const
static const int SERIALIZE_TRANSACTION
An input of a transaction.
CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL)
void SerializationOp(Stream &s, Operation ser_action)
A TxHash is the double sha256 hash of the full transaction data.
const std::vector< CTxOut > vout
friend bool operator==(const CMutableTransaction &a, const CMutableTransaction &b)
void SerializeTransaction(const TxType &tx, Stream &s)
An output of a transaction.
static constexpr uint32_t NULL_INDEX
An outpoint - a combination of a transaction hash and an index n into its vout.
COutPoint(TxId txidIn, uint32_t nIn)
CTransaction(deserialize_type, Stream &s)
This deserializing constructor is provided instead of an Unserialize method.
void SerializationOp(Stream &s, Operation ser_action)
Serialized script, used inside transaction inputs and outputs.
A TxId is the identifier of a transaction.
void Serialize(Stream &s) const
void Serialize(Stream &s) const
A mutable version of CTransaction.
void Unserialize(Stream &s, char &a)
friend bool operator<(const COutPoint &a, const COutPoint &b)
The basic transaction that is broadcasted on the network and contained in blocks. ...
friend bool operator==(const CTxIn &a, const CTxIn &b)
void UnserializeTransaction(TxType &tx, Stream &s)
Basic transaction serialization format:
friend bool operator!=(const CTxIn &a, const CTxIn &b)
friend bool operator==(const CTransaction &a, const CTransaction &b)
friend bool operator!=(const CTransaction &a, const CTransaction &b)