diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -222,9 +222,9 @@ // actually immutable; deserialization and assignment are implemented, // and bypass the constness. This is safe, as they update the entire // structure, including the hash. - const int32_t nVersion; const std::vector vin; const std::vector vout; + const int32_t nVersion; const uint32_t nLockTime; private: @@ -292,15 +292,16 @@ std::string ToString() const; }; +static_assert(sizeof(CTransaction) == 88); /** * A mutable version of CTransaction. */ class CMutableTransaction { public: - int32_t nVersion; std::vector vin; std::vector vout; + int32_t nVersion; uint32_t nLockTime; CMutableTransaction(); @@ -332,6 +333,7 @@ return a.GetId() == b.GetId(); } }; +static_assert(sizeof(CMutableTransaction) == 56); typedef std::shared_ptr CTransactionRef; static inline CTransactionRef MakeTransactionRef() { diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -38,7 +38,7 @@ CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {} CMutableTransaction::CMutableTransaction(const CTransaction &tx) - : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), + : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime) {} static uint256 ComputeCMutableTransactionHash(const CMutableTransaction &tx) { @@ -62,13 +62,13 @@ * TODO: remove the need for this default constructor entirely. */ CTransaction::CTransaction() - : nVersion(CTransaction::CURRENT_VERSION), vin(), vout(), nLockTime(0), + : vin(), vout(), nVersion(CTransaction::CURRENT_VERSION), nLockTime(0), hash() {} CTransaction::CTransaction(const CMutableTransaction &tx) - : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), + : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash(ComputeHash()) {} CTransaction::CTransaction(CMutableTransaction &&tx) - : nVersion(tx.nVersion), vin(std::move(tx.vin)), vout(std::move(tx.vout)), + : vin(std::move(tx.vin)), vout(std::move(tx.vout)), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash(ComputeHash()) {} Amount CTransaction::GetValueOut() const {