MCPcopy Create free account
hub / github.com/ElementsProject/elements / Serialize

Method Serialize

src/primitives/transaction.h:166–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164 // ELEMENTS: explicit serialization methods for selective asset/pegin encoding
165 template <typename Stream>
166 inline void Serialize(Stream& s) const {
167 bool fHasAssetIssuance;
168 COutPoint outpoint;
169 if (!g_con_elementsmode || prevout.n == (uint32_t) -1) {
170 // Coinbase inputs do not have asset issuances attached
171 // to them.
172 fHasAssetIssuance = false;
173 outpoint = prevout;
174 } else {
175 // The issuance and pegin bits can't be set as it is used to indicate
176 // the presence of the asset issuance or pegin objects. They should
177 // never be set anyway as that would require a parent
178 // transaction with over one billion outputs.
179 assert(!(prevout.n & ~COutPoint::OUTPOINT_INDEX_MASK));
180 // The assetIssuance object is used to represent both new
181 // asset generation and reissuance of existing asset types.
182 fHasAssetIssuance = !assetIssuance.IsNull();
183 // The mode is placed in the upper bits of the outpoint's
184 // index field. The IssuanceMode enum values are chosen to
185 // make this as simple as a bitwise-OR.
186 outpoint.hash = prevout.hash;
187 outpoint.n = prevout.n & COutPoint::OUTPOINT_INDEX_MASK;
188 if (fHasAssetIssuance) {
189 outpoint.n |= COutPoint::OUTPOINT_ISSUANCE_FLAG;
190 }
191 if (m_is_pegin) {
192 outpoint.n |= COutPoint::OUTPOINT_PEGIN_FLAG;
193 }
194 }
195
196 // These are the same as bitcoin...
197 s << outpoint;
198 s << scriptSig;
199 s << nSequence;
200 // ...but then we add asset issuance data for issuances
201 if (fHasAssetIssuance) {
202 s << assetIssuance;
203 }
204 }
205
206 template <typename Stream>
207 inline void Unserialize(Stream& s) {

Callers

nothing calls this directly

Calls 1

IsNullMethod · 0.45

Tested by

no test coverage detected