Browse Source
Add deserializing constructors to CTransaction and CMutableTransaction
pull/4/head
Pieter Wuille
8 years ago
committed by
Jack Grigg
No known key found for this signature in database
GPG Key ID: 665DBCD284F7DAFF
2 changed files with
17 additions and
0 deletions
-
src/primitives/transaction.cpp
-
src/primitives/transaction.h
|
|
@ -184,6 +184,14 @@ CTransaction::CTransaction( |
|
|
|
assert(evilDeveloperFlag); |
|
|
|
} |
|
|
|
|
|
|
|
CTransaction::CTransaction(CMutableTransaction &&tx) : nVersion(tx.nVersion), fOverwintered(tx.fOverwintered), nVersionGroupId(tx.nVersionGroupId), |
|
|
|
vin(std::move(tx.vin)), vout(std::move(tx.vout)), nLockTime(tx.nLockTime), nExpiryHeight(tx.nExpiryHeight), |
|
|
|
vjoinsplit(std::move(tx.vjoinsplit)), |
|
|
|
joinSplitPubKey(std::move(tx.joinSplitPubKey)), joinSplitSig(std::move(tx.joinSplitSig)) |
|
|
|
{ |
|
|
|
UpdateHash(); |
|
|
|
} |
|
|
|
|
|
|
|
CTransaction& CTransaction::operator=(const CTransaction &tx) { |
|
|
|
*const_cast<bool*>(&fOverwintered) = tx.fOverwintered; |
|
|
|
*const_cast<int*>(&nVersion) = tx.nVersion; |
|
|
|
|
|
@ -366,6 +366,7 @@ public: |
|
|
|
|
|
|
|
/** Convert a CMutableTransaction into a CTransaction. */ |
|
|
|
CTransaction(const CMutableTransaction &tx); |
|
|
|
CTransaction(CMutableTransaction &&tx); |
|
|
|
|
|
|
|
CTransaction& operator=(const CTransaction& tx); |
|
|
|
|
|
|
@ -411,6 +412,9 @@ public: |
|
|
|
UpdateHash(); |
|
|
|
} |
|
|
|
|
|
|
|
template <typename Stream> |
|
|
|
CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {} |
|
|
|
|
|
|
|
bool IsNull() const { |
|
|
|
return vin.empty() && vout.empty(); |
|
|
|
} |
|
|
@ -523,6 +527,11 @@ struct CMutableTransaction |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
template <typename Stream> |
|
|
|
CMutableTransaction(deserialize_type, Stream& s) { |
|
|
|
Unserialize(s); |
|
|
|
} |
|
|
|
|
|
|
|
/** Compute the hash of this CMutableTransaction. This is computed on the
|
|
|
|
* fly, as opposed to GetHash() in CTransaction, which uses a cached result. |
|
|
|
*/ |
|
|
|