diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -379,38 +379,13 @@ */ class CMerkleTx { public: - CTransactionRef tx; - BlockHash hashBlock; - - /** - * An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest - * block in the chain we know this or any in-wallet dependency conflicts - * with. Older clients interpret nIndex == -1 as unconfirmed for backward - * compatibility. - */ - int nIndex; - - CMerkleTx() { - SetTx(MakeTransactionRef()); - Init(); - } - - explicit CMerkleTx(CTransactionRef arg) { - SetTx(std::move(arg)); - Init(); - } - - void Init() { - hashBlock = BlockHash(); - nIndex = -1; - } - - void SetTx(CTransactionRef arg) { tx = std::move(arg); } - ADD_SERIALIZE_METHODS; template inline void SerializationOp(Stream &s, Operation ser_action) { + CTransactionRef tx; + BlockHash hashBlock; + int nIndex = 0; // For compatibility with older versions. std::vector vMerkleBranch; READWRITE(tx); @@ -429,7 +404,7 @@ * about. It includes any unrecorded transactions needed to link it back to the * block chain. */ -class CWalletTx : public CMerkleTx { +class CWalletTx { private: const CWallet *pwallet; @@ -503,7 +478,7 @@ mutable Amount nChangeCached; CWalletTx(const CWallet *pwalletIn, CTransactionRef arg) - : CMerkleTx(std::move(arg)) { + : tx(std::move(arg)), hashBlock(BlockHash()), nIndex(-1) { Init(pwalletIn); } @@ -521,6 +496,16 @@ nOrderPos = -1; } + CTransactionRef tx; + BlockHash hashBlock; + /** + * An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest + * block in the chain we know this or any in-wallet dependency conflicts + * with. Older clients interpret nIndex == -1 as unconfirmed for backward + * compatibility. + */ + int nIndex; + template void Serialize(Stream &s) const { char fSpent = false; mapValue_t mapValueCopy = mapValue; @@ -531,7 +516,9 @@ mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart); } - s << static_cast(*this); + //! Used to be vMerkleBranch + std::vector dummy_vector; + s << tx << hashBlock << dummy_vector << nIndex; //! Used to be vtxPrev std::vector vUnused; s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime @@ -542,7 +529,9 @@ Init(nullptr); char fSpent; - s >> static_cast(*this); + //! Used to be vMerkleBranch + std::vector dummy_vector; + s >> tx >> hashBlock >> dummy_vector >> nIndex; //! Used to be vtxPrev std::vector vUnused; s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> @@ -559,6 +548,8 @@ mapValue.erase("timesmart"); } + void SetTx(CTransactionRef arg) { tx = std::move(arg); } + //! make sure balances are recalculated void MarkDirty() { m_amounts[DEBIT].Reset();