 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
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);
207 template<
typename Stream,
typename TxType>
212 unsigned char flags = 0;
217 if (tx.vin.size() == 0 && fAllowWitness) {
228 if ((
flags & 1) && fAllowWitness) {
231 for (
size_t i = 0; i < tx.vin.size(); i++) {
232 s >> tx.vin[i].scriptWitness.stack;
234 if (!tx.HasWitness()) {
236 throw std::ios_base::failure(
"Superfluous witness record");
241 throw std::ios_base::failure(
"Unknown transaction optional data");
246 template<
typename Stream,
typename TxType>
251 unsigned char flags = 0;
255 if (tx.HasWitness()) {
261 std::vector<CTxIn> vinDummy;
268 for (
size_t i = 0; i < tx.vin.size(); i++) {
269 s << tx.vin[i].scriptWitness.stack;
290 const std::vector<CTxIn>
vin;
291 const std::vector<CTxOut>
vout;
308 template <
typename Stream>
315 template <
typename Stream>
319 return vin.empty() &&
vout.empty();
337 return (
vin.size() == 1 &&
vin[0].prevout.IsNull());
354 for (
size_t i = 0; i <
vin.size(); i++) {
374 template <
typename Stream>
380 template <
typename Stream>
385 template <
typename Stream>
397 for (
size_t i = 0; i <
vin.size(); i++) {
425 #endif // BITCOIN_PRIMITIVES_TRANSACTION_H
An input of a transaction.
friend bool operator<(const COutPoint &a, const COutPoint &b)
const std::vector< CTxIn > vin
Dummy data type to identify deserializing constructors.
GenTxid(bool is_wtxid, const uint256 &hash)
A generic txid reference (txid or wtxid).
void Serialize(Stream &s) const
friend bool operator!=(const CTxOut &a, const CTxOut &b)
friend bool operator==(const COutPoint &a, const COutPoint &b)
SERIALIZE_METHODS(CTxOut, obj)
static GenTxid Wtxid(const uint256 &hash)
friend bool operator!=(const CTransaction &a, const CTransaction &b)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
static const uint32_t MAX_SEQUENCE_NONFINAL
This is the maximum sequence number that enables both nLockTime and OP_CHECKLOCKTIMEVERIFY (BIP 65).
CAmount GetValueOut() const
static GenTxid Txid(const uint256 &hash)
std::shared_ptr< const CTransaction > CTransactionRef
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...
The basic transaction that is broadcasted on the network and contained in blocks.
static const uint32_t SEQUENCE_FINAL
Setting nSequence to this value for every input in a transaction disables nLockTime/IsFinalTx().
CScriptWitness scriptWitness
Only serialized through CTransaction.
friend bool operator!=(const CTxIn &a, const CTxIn &b)
int Compare(const base_blob &other) const
An output of a transaction.
static constexpr uint32_t NULL_INDEX
CTransaction(const CMutableTransaction &tx)
Convert a CMutableTransaction into a CTransaction.
friend bool operator==(const GenTxid &a, const GenTxid &b)
const std::vector< CTxOut > vout
void UnserializeTransaction(TxType &tx, Stream &s)
Basic transaction serialization format:
friend bool operator==(const CTxIn &a, const CTxIn &b)
int64_t CAmount
Amount in satoshis (Can be negative)
static const int SEQUENCE_LOCKTIME_GRANULARITY
In order to use the same number of bits to encode roughly the same wall-clock duration,...
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...
friend bool operator!=(const COutPoint &a, const COutPoint &b)
unsigned int GetTotalSize() const
Get the total transaction size in bytes, including witness data.
CMutableTransaction(deserialize_type, Stream &s)
const uint256 m_witness_hash
SERIALIZE_METHODS(CTxIn, obj)
SERIALIZE_METHODS(COutPoint, obj)
friend bool operator<(const GenTxid &a, const GenTxid &b)
Serialized script, used inside transaction inputs and outputs.
static const int32_t CURRENT_VERSION
void Unserialize(Stream &s)
std::vector< CTxOut > vout
friend bool operator==(const CTransaction &a, const CTransaction &b)
std::string ToString() const
const uint256 & GetHash() const
uint256 ComputeWitnessHash() const
std::string ToString() const
friend bool operator==(const CTxOut &a, const CTxOut &b)
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...
std::string ToString() const
CTransaction(deserialize_type, Stream &s)
This deserializing constructor is provided instead of an Unserialize method.
const uint256 & GetWitnessHash() const
std::string ToString() const
const uint256 & GetHash() const
An outpoint - a combination of a transaction hash and an index n into its vout.
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
A mutable version of CTransaction.
void SerializeTransaction(const TxType &tx, Stream &s)
uint256 ComputeHash() const
constexpr deserialize_type deserialize
const uint256 hash
Memory only.
void Serialize(Stream &s) const
static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG
If this flag is set, CTxIn::nSequence is NOT interpreted as a relative lock-time.
COutPoint(const uint256 &hashIn, uint32_t nIn)