Skip to content

Commit 05b56d1

Browse files
committed
[wallet] Remove CMerkleTx serialization logic
CMerkleTx is only used for deserialization of old wallet files. Remove the serialization logic, and tidy up CWalletTx serialization logic.
1 parent 783a76f commit 05b56d1

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

src/wallet/wallet.h

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -372,20 +372,16 @@ struct COutputEntry
372372
class CMerkleTx
373373
{
374374
public:
375-
ADD_SERIALIZE_METHODS;
376-
377-
template <typename Stream, typename Operation>
378-
inline void SerializationOp(Stream& s, Operation ser_action) {
375+
template<typename Stream>
376+
void Unserialize(Stream& s)
377+
{
379378
CTransactionRef tx;
380379
uint256 hashBlock;
380+
std::vector<uint256> vMerkleBranch;
381381
int nIndex;
382-
std::vector<uint256> vMerkleBranch; // For compatibility with older versions.
383-
READWRITE(tx);
384-
READWRITE(hashBlock);
385-
READWRITE(vMerkleBranch);
386-
READWRITE(nIndex);
387-
}
388382

383+
s >> tx >> hashBlock >> vMerkleBranch >> nIndex;
384+
}
389385
};
390386

391387
//Get the marginal bytes of spending the specified output
@@ -495,7 +491,6 @@ class CWalletTx
495491
template<typename Stream>
496492
void Serialize(Stream& s) const
497493
{
498-
char fSpent = false;
499494
mapValue_t mapValueCopy = mapValue;
500495

501496
mapValueCopy["fromaccount"] = "";
@@ -504,22 +499,21 @@ class CWalletTx
504499
mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
505500
}
506501

507-
std::vector<uint256> dummy_vector; //!< Used to be vMerkleBranch
508-
s << tx << hashBlock << dummy_vector << nIndex;
509-
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
510-
s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << fSpent;
502+
std::vector<char> dummy_vector1; //!< Used to be vMerkleBranch
503+
std::vector<char> dummy_vector2; //!< Used to be vtxPrev
504+
char dummy_char = false; //!< Used to be fSpent
505+
s << tx << hashBlock << dummy_vector1 << nIndex << dummy_vector2 << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << dummy_char;
511506
}
512507

513508
template<typename Stream>
514509
void Unserialize(Stream& s)
515510
{
516511
Init(nullptr);
517-
char fSpent;
518512

519-
std::vector<uint256> dummy_vector; //!< Used to be vMerkleBranch
520-
s >> tx >> hashBlock >> dummy_vector >> nIndex;
521-
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
522-
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent;
513+
std::vector<uint256> dummy_vector1; //!< Used to be vMerkleBranch
514+
std::vector<CMerkleTx> dummy_vector2; //!< Used to be vtxPrev
515+
char dummy_char; //! Used to be fSpent
516+
s >> tx >> hashBlock >> dummy_vector1 >> nIndex >> dummy_vector2 >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> dummy_char;
523517

524518
ReadOrderPos(nOrderPos, mapValue);
525519
nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;

0 commit comments

Comments
 (0)