mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
Split up and sanitize CWalletTx serialization
This commit is contained in:
parent
29fad97c32
commit
029ecac1bc
1 changed files with 22 additions and 28 deletions
|
@ -390,42 +390,36 @@ public:
|
||||||
nOrderPos = -1;
|
nOrderPos = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
template<typename Stream>
|
||||||
|
void Serialize(Stream& s) const
|
||||||
template <typename Stream, typename Operation>
|
{
|
||||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
||||||
if (ser_action.ForRead())
|
|
||||||
Init(nullptr);
|
|
||||||
char fSpent = false;
|
char fSpent = false;
|
||||||
|
mapValue_t mapValueCopy = mapValue;
|
||||||
|
|
||||||
if (!ser_action.ForRead())
|
mapValueCopy["fromaccount"] = strFromAccount;
|
||||||
{
|
WriteOrderPos(nOrderPos, mapValueCopy);
|
||||||
mapValue["fromaccount"] = strFromAccount;
|
if (nTimeSmart) {
|
||||||
|
mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
|
||||||
WriteOrderPos(nOrderPos, mapValue);
|
|
||||||
|
|
||||||
if (nTimeSmart)
|
|
||||||
mapValue["timesmart"] = strprintf("%u", nTimeSmart);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
READWRITE(*static_cast<CMerkleTx*>(this));
|
s << *static_cast<const CMerkleTx*>(this);
|
||||||
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
||||||
READWRITE(vUnused);
|
s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << fSpent;
|
||||||
READWRITE(mapValue);
|
}
|
||||||
READWRITE(vOrderForm);
|
|
||||||
READWRITE(fTimeReceivedIsTxTime);
|
|
||||||
READWRITE(nTimeReceived);
|
|
||||||
READWRITE(fFromMe);
|
|
||||||
READWRITE(fSpent);
|
|
||||||
|
|
||||||
if (ser_action.ForRead())
|
template<typename Stream>
|
||||||
{
|
void Unserialize(Stream& s)
|
||||||
strFromAccount = mapValue["fromaccount"];
|
{
|
||||||
|
Init(nullptr);
|
||||||
|
char fSpent;
|
||||||
|
|
||||||
ReadOrderPos(nOrderPos, mapValue);
|
s >> *static_cast<CMerkleTx*>(this);
|
||||||
|
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev
|
||||||
|
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent;
|
||||||
|
|
||||||
nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;
|
strFromAccount = std::move(mapValue["fromaccount"]);
|
||||||
}
|
ReadOrderPos(nOrderPos, mapValue);
|
||||||
|
nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;
|
||||||
|
|
||||||
mapValue.erase("fromaccount");
|
mapValue.erase("fromaccount");
|
||||||
mapValue.erase("spent");
|
mapValue.erase("spent");
|
||||||
|
|
Loading…
Reference in a new issue