5 #include <script/script.h> 6 #include <utils/serialize.h> 7 #include <structs/amount.h> 8 #include <structs/uint256.h> 20 ADD_SERIALIZE_METHODS;
22 template <
typename Stream,
typename Operation>
23 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
24 READWRITE(FLATDATA(*
this));
27 void SetNull() { hash = 0; n = (uint32_t) -1; }
28 bool IsNull()
const {
return (hash == 0 && n == (uint32_t) -1); }
32 return (a.hash < b.hash || (a.hash == b.hash && a.n < b.n));
37 return (a.hash == b.hash && a.n == b.n);
45 std::string ToString()
const;
61 nSequence = std::numeric_limits<unsigned int>::max();
65 CTxIn(
uint256 hashPrevTx, uint32_t nOut,
CScript scriptSigIn=
CScript(), uint32_t nSequenceIn=std::numeric_limits<uint32_t>::max());
67 ADD_SERIALIZE_METHODS;
69 template <
typename Stream,
typename Operation>
70 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
78 return (nSequence == std::numeric_limits<uint32_t>::max());
81 friend bool operator==(
const CTxIn& a,
const CTxIn& b)
83 return (a.prevout == b.prevout &&
84 a.scriptSig == b.scriptSig &&
85 a.nSequence == b.nSequence);
88 friend bool operator!=(
const CTxIn& a,
const CTxIn& b)
93 std::string ToString()
const;
112 ADD_SERIALIZE_METHODS;
114 template <
typename Stream,
typename Operation>
115 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
117 READWRITE(scriptPubKey);
123 scriptPubKey.clear();
128 return (nValue == -1);
133 CAmount GetDustThreshold(
const CFeeRate &minRelayTxFee)
const 136 static int64_t MCP_MINIMUM_PER_OUTPUT = 0;
137 int64_t minOutput=MCP_MINIMUM_PER_OUTPUT;
142 size_t nSize = GetSerializeSize(SER_DISK,0)+148u;
143 return 3*minRelayTxFee.GetFee(nSize);
146 bool IsDust(
CFeeRate minRelayTxFee)
const 165 return (nValue < GetDustThreshold(minRelayTxFee));
168 friend bool operator==(
const CTxOut& a,
const CTxOut& b)
170 return (a.nValue == b.nValue &&
171 a.scriptPubKey == b.scriptPubKey);
174 friend bool operator!=(
const CTxOut& a,
const CTxOut& b)
179 std::string ToString()
const;
192 void UpdateHash()
const;
195 static const int32_t CURRENT_VERSION=1;
202 const int32_t nVersion;
203 const std::vector<CTxIn> vin;
204 const std::vector<CTxOut> vout;
205 const uint32_t nLockTime;
215 ADD_SERIALIZE_METHODS;
217 template <
typename Stream,
typename Operation>
218 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
219 READWRITE(*const_cast<int32_t*>(&this->nVersion));
220 nVersion = this->nVersion;
221 READWRITE(*
const_cast<std::vector<CTxIn>*
>(&vin));
222 READWRITE(*
const_cast<std::vector<CTxOut>*
>(&vout));
223 READWRITE(*const_cast<uint32_t*>(&nLockTime));
224 if (ser_action.ForRead())
228 bool IsNull()
const {
229 return vin.empty() && vout.empty();
232 const uint256& GetHash()
const {
237 CAmount GetValueOut()
const;
242 double ComputePriority(
double dPriorityInputs,
unsigned int nTxSize=0)
const;
245 unsigned int CalculateModifiedSize(
unsigned int nTxSize=0)
const;
247 bool IsCoinBase()
const 249 return (vin.size() == 1 && vin[0].prevout.IsNull());
254 return a.hash == b.hash;
259 return a.hash != b.hash;
262 std::string ToString()
const;
269 std::vector<CTxIn> vin;
270 std::vector<CTxOut> vout;
276 ADD_SERIALIZE_METHODS;
278 template <
typename Stream,
typename Operation>
279 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
280 READWRITE(this->nVersion);
281 nVersion = this->nVersion;
284 READWRITE(nLockTime);
294 bool DecodeHexTx(
CTransaction& tx,
const std::string& strHexTx);
296 #endif // TRANSACTION_H Definition: transaction.h:52
Definition: transaction.h:99
Definition: transaction.h:11
Definition: uint256.h:294
Definition: transaction.h:266
Definition: transaction.h:187