MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / Serialize

Method Serialize

src/script/sign.h:225–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223
224 template <typename Stream>
225 inline void Serialize(Stream& s) const {
226 // Write the utxo
227 // If there is a non-witness utxo, then don't add the witness one.
228 if (non_witness_utxo) {
229 SerializeToVector(s, PSBT_IN_NON_WITNESS_UTXO);
230 OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
231 SerializeToVector(os, non_witness_utxo);
232 } else if (!witness_utxo.IsNull()) {
233 SerializeToVector(s, PSBT_IN_WITNESS_UTXO);
234 SerializeToVector(s, witness_utxo);
235 }
236
237 if (final_script_sig.empty() && final_script_witness.IsNull()) {
238 // Write any partial signatures
239 for (auto sig_pair : partial_sigs) {
240 SerializeToVector(s, PSBT_IN_PARTIAL_SIG, MakeSpan(sig_pair.second.first));
241 s << sig_pair.second.second;
242 }
243
244 // Write the sighash type
245 if (sighash_type > 0) {
246 SerializeToVector(s, PSBT_IN_SIGHASH);
247 SerializeToVector(s, sighash_type);
248 }
249
250 // Write the redeem script
251 if (!redeem_script.empty()) {
252 SerializeToVector(s, PSBT_IN_REDEEMSCRIPT);
253 s << redeem_script;
254 }
255
256 // Write the witness script
257 if (!witness_script.empty()) {
258 SerializeToVector(s, PSBT_IN_WITNESSSCRIPT);
259 s << witness_script;
260 }
261
262 // Write any hd keypaths
263 SerializeHDKeypaths(s, hd_keypaths, PSBT_IN_BIP32_DERIVATION);
264 }
265
266 // Write script sig
267 if (!final_script_sig.empty()) {
268 SerializeToVector(s, PSBT_IN_SCRIPTSIG);
269 s << final_script_sig;
270 }
271 // write script witness
272 if (!final_script_witness.IsNull()) {
273 SerializeToVector(s, PSBT_IN_SCRIPTWITNESS);
274 SerializeToVector(s, final_script_witness.stack);
275 }
276
277 // Write unknown things
278 for (auto& entry : unknown) {
279 s << entry.first;
280 s << entry.second;
281 }
282

Callers

nothing calls this directly

Calls 7

SerializeToVectorFunction · 0.85
MakeSpanFunction · 0.85
SerializeHDKeypathsFunction · 0.85
GetTypeMethod · 0.45
GetVersionMethod · 0.45
IsNullMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected