Serialize Sapling data in CWalletTx

If 2.0.0 nodes upgrade to 2.0.1 after Sapling has activated, the v4 Sapling
transactions in their wallet will be treated as corrupt, and a rescan will be
triggered which will overwrite the old-format transactions with the new
Sapling-aware format.
This commit is contained in:
mdr0id 2018-09-17 12:41:26 -07:00 committed by Jack Grigg
parent 2fcf06077f
commit 48a93fd2e0
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
1 changed files with 18 additions and 2 deletions

View File

@ -283,6 +283,20 @@ public:
libzcash::SaplingIncomingViewingKey ivk;
boost::optional<uint256> nullifier;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
int nVersion = s.GetVersion();
if (!(s.GetType() & SER_GETHASH)) {
READWRITE(nVersion);
}
READWRITE(ivk);
READWRITE(nullifier);
READWRITE(witnesses);
READWRITE(witnessHeight);
}
friend bool operator==(const SaplingNoteData& a, const SaplingNoteData& b) {
return (a.ivk == b.ivk && a.nullifier == b.nullifier && a.witnessHeight == b.witnessHeight);
}
@ -509,8 +523,10 @@ public:
READWRITE(nTimeReceived);
READWRITE(fFromMe);
READWRITE(fSpent);
// TODO:
//READWRITE(mapSaplingNoteData);
if (fOverwintered && nVersion >= SAPLING_TX_VERSION) {
READWRITE(mapSaplingNoteData);
}
if (ser_action.ForRead())
{