6 #ifndef BITCOIN_PRIMITIVES_TRANSACTION_H 7 #define BITCOIN_PRIMITIVES_TRANSACTION_H 15 static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000;
29 template <
typename Stream,
typename Operation>
41 return cmp < 0 || (cmp == 0 && a.
n < b.
n);
106 template <
typename Stream,
typename Operation>
146 template <
typename Stream,
typename Operation>
196 template<
typename Stream,
typename TxType>
198 const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);
201 unsigned char flags = 0;
206 if (tx.vin.size() == 0 && fAllowWitness) {
217 if ((
flags & 1) && fAllowWitness) {
220 for (
size_t i = 0; i < tx.vin.size(); i++) {
221 s >> tx.vin[i].scriptWitness.stack;
226 throw std::ios_base::failure(
"Unknown transaction optional data");
231 template<
typename Stream,
typename TxType>
233 const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);
236 unsigned char flags = 0;
240 if (tx.HasWitness()) {
246 std::vector<CTxIn> vinDummy;
253 for (
size_t i = 0; i < tx.vin.size(); i++) {
254 s << tx.vin[i].scriptWitness.stack;
281 const std::vector<CTxIn>
vin;
282 const std::vector<CTxOut>
vout;
302 template <
typename Stream>
309 template <
typename Stream>
313 return vin.empty() &&
vout.empty();
333 return (
vin.size() == 1 &&
vin[0].prevout.IsNull());
350 for (
size_t i = 0; i <
vin.size(); i++) {
370 template <
typename Stream>
376 template <
typename Stream>
381 template <
typename Stream>
393 for (
size_t i = 0; i <
vin.size(); i++) {
403 static inline CTransactionRef MakeTransactionRef() {
return std::make_shared<const CTransaction>(); }
404 template <
typename Tx>
static inline CTransactionRef MakeTransactionRef(Tx&& txIn) {
return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
406 #endif // BITCOIN_PRIMITIVES_TRANSACTION_H
static const int32_t MAX_STANDARD_VERSION
friend bool operator!=(const COutPoint &a, const COutPoint &b)
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
friend bool operator==(const CTxOut &a, const CTxOut &b)
void SerializationOp(Stream &s, Operation ser_action)
static const int SEQUENCE_LOCKTIME_GRANULARITY
std::string ToString() const
std::string ToString() const
std::string ToString() const
friend bool operator!=(const CTxOut &a, const CTxOut &b)
void UnserializeTransaction(TxType &tx, Stream &s)
Basic transaction serialization format:
const uint256 hash
Memory only.
std::shared_ptr< const CTransaction > CTransactionRef
Dummy data type to identify deserializing constructors.
const std::vector< CTxIn > vin
friend bool operator==(const COutPoint &a, const COutPoint &b)
CAmount GetValueOut() const
void SerializeTransaction(const TxType &tx, Stream &s)
int Compare(const base_blob &other) const
int64_t CAmount
Amount in satoshis (Can be negative)
An input of a transaction.
const uint256 & GetWitnessHash() const
const uint256 & GetHash() const
void Unserialize(Stream &s)
void SerializationOp(Stream &s, Operation ser_action)
const std::vector< CTxOut > vout
An output of a transaction.
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
CTransaction(deserialize_type, Stream &s)
This deserializing constructor is provided instead of an Unserialize method.
const uint256 m_witness_hash
uint256 ComputeHash() const
uint256 ComputeWitnessHash() const
void SerializationOp(Stream &s, Operation ser_action)
CMutableTransaction(deserialize_type, Stream &s)
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
static const uint32_t SEQUENCE_LOCKTIME_MASK
Serialized script, used inside transaction inputs and outputs.
CTransaction()
Construct a CTransaction that qualifies as IsNull()
void Serialize(Stream &s) const
std::string ToString() const
void Serialize(Stream &s) const
A mutable version of CTransaction.
unsigned int GetTotalSize() const
Get the total transaction size in bytes, including witness data.
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)
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)