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);
146 scriptPubKey.
clear();
151 return (nValue == -1);
187 template<
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");
226 template<
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;
276 const std::vector<CTxIn>
vin;
277 const std::vector<CTxOut>
vout;
297 template <
typename Stream>
304 template <
typename Stream>
308 return vin.empty() && vout.empty();
326 return (vin.size() == 1 && vin[0].prevout.IsNull());
343 for (
size_t i = 0; i < vin.size(); i++) {
344 if (!vin[i].scriptWitness.
IsNull()) {
363 template <
typename Stream>
369 template <
typename Stream>
374 template <
typename Stream>
386 for (
size_t i = 0; i < vin.size(); i++) {
387 if (!vin[i].scriptWitness.
IsNull()) {
396 static inline CTransactionRef
MakeTransactionRef() {
return std::make_shared<const CTransaction>(); }
397 template <
typename Tx>
static inline CTransactionRef
MakeTransactionRef(Tx&& txIn) {
return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
405 GenTxid(
bool is_wtxid,
const uint256& hash) : m_is_wtxid(is_wtxid), m_hash(hash) {}
412 #endif // BITCOIN_PRIMITIVES_TRANSACTION_H
std::shared_ptr< const CTransaction > CTransactionRef
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...
unsigned int GetTotalSize() const
Get the total transaction size in bytes, including witness data.
static const int32_t MAX_STANDARD_VERSION
friend bool operator!=(const COutPoint &a, const COutPoint &b)
friend bool operator<(const GenTxid &a, const GenTxid &b)
uint256 ComputeHash() const
COutPoint(const uint256 &hashIn, uint32_t nIn)
CScriptWitness scriptWitness
Only serialized through CTransaction.
static const uint32_t SEQUENCE_FINAL
static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG
constexpr deserialize_type deserialize
static CTransactionRef MakeTransactionRef()
friend bool operator==(const CTxOut &a, const CTxOut &b)
static const int SEQUENCE_LOCKTIME_GRANULARITY
void Serialize(Stream &s) const
friend bool operator!=(const CTxOut &a, const CTxOut &b)
const uint256 hash
Memory only.
Dummy data type to identify deserializing constructors.
std::string ToString() const
uint256 ComputeWitnessHash() const
SERIALIZE_METHODS(CTxOut, obj)
const std::vector< CTxIn > vin
friend bool operator==(const COutPoint &a, const COutPoint &b)
int64_t CAmount
Amount in satoshis (Can be negative)
An input of a transaction.
void Unserialize(Stream &s)
CAmount GetValueOut() const
const std::vector< CTxOut > vout
void SerializeTransaction(const TxType &tx, Stream &s)
An output of a transaction.
static constexpr uint32_t NULL_INDEX
static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
const uint256 & GetWitnessHash() const
CTransaction(deserialize_type, Stream &s)
This deserializing constructor is provided instead of an Unserialize method.
std::string ToString() const
const uint256 m_witness_hash
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
std::string ToString() const
const uint256 & GetHash() const
friend bool operator==(const GenTxid &a, const GenTxid &b)
std::string ToString() const
CMutableTransaction(deserialize_type, Stream &s)
static const uint32_t SEQUENCE_LOCKTIME_MASK
Serialized script, used inside transaction inputs and outputs.
SERIALIZE_METHODS(CTxIn, obj)
CTransaction()
Construct a CTransaction that qualifies as IsNull()
SERIALIZE_METHODS(COutPoint, obj)
int Compare(const base_blob &other) const
void Serialize(Stream &s) const
A mutable version of CTransaction.
const uint256 & GetHash() const
friend bool operator<(const COutPoint &a, const COutPoint &b)
The basic transaction that is broadcasted on the network and contained in blocks. ...
static const int32_t CURRENT_VERSION
friend bool operator==(const CTxIn &a, const CTxIn &b)
void UnserializeTransaction(TxType &tx, Stream &s)
Basic transaction serialization format:
GenTxid(bool is_wtxid, const uint256 &hash)
friend bool operator!=(const CTxIn &a, const CTxIn &b)
A generic txid reference (txid or wtxid).
friend bool operator==(const CTransaction &a, const CTransaction &b)
friend bool operator!=(const CTransaction &a, const CTransaction &b)