@@ -84,7 +84,8 @@ class CAuxPow
8484 CAuxPow (const CAuxPow&) = delete ;
8585 void operator = (const CAuxPow&) = delete ;
8686
87- SERIALIZE_METHODS (CAuxPow, obj)
87+ template <typename Stream>
88+ void Serialize (Stream& s) const
8889 {
8990 /* The coinbase Merkle tx' hashBlock field is never actually verified
9091 or used in the code for an auxpow (and never was). The parent block
@@ -96,12 +97,38 @@ class CAuxPow
9697 /* The index of the parent coinbase tx is always zero. */
9798 int nIndex = 0 ;
9899
99- /* Data from the coinbase transaction as Merkle tx. */
100- READWRITE (Sidechain::Bitcoin::TX_WITH_WITNESS (obj.coinbaseTx ), hashBlock,
101- obj.vMerkleBranch , nIndex);
100+ /* Serialize the coinbase transaction with witness data. */
101+ s << Sidechain::Bitcoin::TX_WITH_WITNESS (*coinbaseTx);
102+ s << hashBlock;
103+ s << vMerkleBranch;
104+ s << nIndex;
102105
103106 /* Additional data for the auxpow itself. */
104- READWRITE (obj.vChainMerkleBranch , obj.nChainIndex , obj.parentBlock );
107+ s << vChainMerkleBranch;
108+ s << nChainIndex;
109+ s << parentBlock;
110+ }
111+
112+ template <typename Stream>
113+ void Unserialize (Stream& s)
114+ {
115+ uint256 hashBlock;
116+ int nIndex = 0 ;
117+
118+ /* Deserialize the coinbase transaction.
119+ We read into a mutable transaction first, then convert to CTransactionRef. */
120+ Sidechain::Bitcoin::CMutableTransaction mtx;
121+ s >> Sidechain::Bitcoin::TX_WITH_WITNESS (mtx);
122+ coinbaseTx = Sidechain::Bitcoin::MakeTransactionRef (std::move (mtx));
123+
124+ s >> hashBlock;
125+ s >> vMerkleBranch;
126+ s >> nIndex;
127+
128+ /* Additional data for the auxpow itself. */
129+ s >> vChainMerkleBranch;
130+ s >> nChainIndex;
131+ s >> parentBlock;
105132 }
106133
107134 /* *
0 commit comments