diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index a05c7062bd08d..056583c7e8ea9 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -141,29 +141,37 @@ class CKeyPool bool IsExternal() const { return type == HDChain::ChangeType::EXTERNAL; } bool IsStaking() const { return type == HDChain::ChangeType::STAKING; } - ADD_SERIALIZE_METHODS; + template + void Serialize(Stream& s) const + { + int nVersion = s.GetVersion(); + if (!(s.GetType() & SER_GETHASH)) { + s << nVersion; + } + s << nTime << vchPubKey << Span((unsigned char*)&type, 1) << m_pre_split; + } - template - inline void SerializationOp(Stream& s, Operation ser_action) + template + void Unserialize(Stream& s) { int nVersion = s.GetVersion(); - if (!(s.GetType() & SER_GETHASH)) - READWRITE(nVersion); - READWRITE(nTime); - READWRITE(vchPubKey); - if (ser_action.ForRead()) { - try { - READWRITE(Span((unsigned char*)&type, 1)); - READWRITE(m_pre_split); - } catch (std::ios_base::failure&) { - /* Set as external address if we can't read the type boolean - (this will be the case for any wallet before the HD chain) */ - type = HDChain::ChangeType::EXTERNAL; - m_pre_split = true; - } - } else { - READWRITE(Span((unsigned char*)&type, 1)); - READWRITE(m_pre_split); + if (!(s.GetType() & SER_GETHASH)) { + s >> nVersion; + } + s >> nTime >> vchPubKey; + try { + s >> Span((unsigned char*)&type, 1); + } catch (std::ios_base::failure&) { + /* flag as external address if we can't read the internal boolean + (this will be the case for any wallet before the HD chain split version) */ + type = HDChain::ChangeType::EXTERNAL; + } + try { + s >> m_pre_split; + } catch (std::ios_base::failure&) { + /* flag as pre-split address if we can't read the m_pre_split boolean + (this will be the case for any wallet prior to the HD chain upgrade) */ + m_pre_split = true; } } }; diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 281bba2045084..7ca3bc88adb92 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -80,16 +80,11 @@ class CKeyMetadata nCreateTime = nCreateTime_; } - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) + SERIALIZE_METHODS(CKeyMetadata, obj) { - READWRITE(nVersion); - READWRITE(nCreateTime); - if (HasKeyOrigin()) { - READWRITE(hd_seed_id); - READWRITE(key_origin); + READWRITE(obj.nVersion, obj.nCreateTime); + if (obj.HasKeyOrigin()) { + READWRITE(obj.hd_seed_id, obj.key_origin); } }