7 #ifndef RAVEN_PRIMITIVES_TRANSACTION_H 8 #define RAVEN_PRIMITIVES_TRANSACTION_H 16 static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000;
33 template <
typename Stream,
typename Operation>
40 bool IsNull()
const {
return (hash.
IsNull() && n == (uint32_t) -1); }
45 return cmp < 0 || (cmp == 0 && a.
n < b.
n);
77 static const uint32_t SEQUENCE_FINAL = 0xffffffff;
82 static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG = (1 << 31);
87 static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22);
91 static const uint32_t SEQUENCE_LOCKTIME_MASK = 0x0000ffff;
100 static const int SEQUENCE_LOCKTIME_GRANULARITY = 9;
104 nSequence = SEQUENCE_FINAL;
112 template <
typename Stream,
typename Operation>
152 template <
typename Stream,
typename Operation>
161 scriptPubKey.
clear();
166 return (nValue == -1);
202 template<
typename Stream,
typename TxType>
204 const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);
207 unsigned char flags = 0;
212 if (tx.vin.size() == 0 && fAllowWitness) {
223 if ((flags & 1) && fAllowWitness) {
226 for (
size_t i = 0; i < tx.vin.size(); i++) {
227 s >> tx.vin[i].scriptWitness.stack;
232 throw std::ios_base::failure(
"Unknown transaction optional data");
237 template<
typename Stream,
typename TxType>
239 const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);
242 unsigned char flags = 0;
246 if (tx.HasWitness()) {
252 std::vector<CTxIn> vinDummy;
259 for (
size_t i = 0; i < tx.vin.size(); i++) {
260 s << tx.vin[i].scriptWitness.stack;
274 static const int32_t CURRENT_VERSION=2;
280 static const int32_t MAX_STANDARD_VERSION=2;
287 const std::vector<CTxIn>
vin;
288 const std::vector<CTxOut>
vout;
306 template <
typename Stream>
313 template <
typename Stream>
317 return vin.empty() && vout.empty();
325 uint256 GetWitnessHash()
const;
333 bool IsNewAsset()
const;
334 bool VerifyNewAsset(std::string& strError)
const;
335 bool IsNewUniqueAsset()
const;
336 bool VerifyNewUniqueAsset(std::string& strError)
const;
337 bool IsReissueAsset()
const;
338 bool VerifyReissueAsset(std::string& strError)
const;
339 bool IsNewMsgChannelAsset()
const;
340 bool VerifyNewMsgChannelAsset(std::string& strError)
const;
341 bool IsNewQualifierAsset()
const;
342 bool VerifyNewQualfierAsset(std::string &strError)
const;
343 bool IsNewRestrictedAsset()
const;
344 bool VerifyNewRestrictedAsset(std::string& strError)
const;
346 bool CheckAddingTagBurnFee(
const int& count)
const;
358 unsigned int GetTotalSize()
const;
362 return (vin.size() == 1 && vin[0].prevout.IsNull());
379 for (
size_t i = 0; i < vin.size(); i++) {
380 if (!vin[i].scriptWitness.IsNull()) {
399 template <
typename Stream>
405 template <
typename Stream>
410 template <
typename Stream>
427 for (
size_t i = 0; i < vin.size(); i++) {
428 if (!vin[i].scriptWitness.IsNull()) {
437 static inline CTransactionRef MakeTransactionRef() {
return std::make_shared<const CTransaction>(); }
438 template <
typename Tx>
static inline CTransactionRef MakeTransactionRef(Tx&& txIn) {
return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
440 #endif // RAVEN_PRIMITIVES_TRANSACTION_H
friend bool operator!=(const COutPoint &a, const COutPoint &b)
COutPoint(const uint256 &hashIn, uint32_t nIn)
CScriptWitness scriptWitness
std::string ToSerializedString() const
constexpr deserialize_type deserialize
friend bool operator==(const CTxOut &a, const CTxOut &b)
void SerializationOp(Stream &s, Operation ser_action)
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)
void SerializeTransaction(const TxType &tx, Stream &s)
int Compare(const base_blob &other) const
int64_t CAmount
Amount in corbies (Can be negative)
An input of a transaction.
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.
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.
friend bool operator==(const CMutableTransaction &a, const CMutableTransaction &b)
void SerializationOp(Stream &s, Operation ser_action)
CMutableTransaction(deserialize_type, Stream &s)
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
Serialized script, used inside transaction inputs and outputs.
void Serialize(Stream &s) const
void Unserialize(Stream &s, char &a)
void Serialize(Stream &s) const
A mutable version of CTransaction.
friend bool operator<(const COutPoint &a, const COutPoint &b)
The basic transaction that is broadcasted on the network and contained in blocks. ...
CCoinsView that adds a memory cache for transactions to another CCoinsView.
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)