| 291 | |
| 292 | template <typename Stream> |
| 293 | inline void Serialize(Stream& s) const { |
| 294 | // Write the utxo |
| 295 | if (non_witness_utxo) { |
| 296 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_NON_WITNESS_UTXO)); |
| 297 | OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS); |
| 298 | SerializeToVector(os, non_witness_utxo); |
| 299 | } |
| 300 | if (!witness_utxo.IsNull()) { |
| 301 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_WITNESS_UTXO)); |
| 302 | SerializeToVector(s, witness_utxo); |
| 303 | } |
| 304 | |
| 305 | if (final_script_sig.empty() && final_script_witness.IsNull()) { |
| 306 | // Write any partial signatures |
| 307 | for (auto sig_pair : partial_sigs) { |
| 308 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_PARTIAL_SIG), Span{sig_pair.second.first}); |
| 309 | s << sig_pair.second.second; |
| 310 | } |
| 311 | |
| 312 | // Write the sighash type |
| 313 | if (sighash_type != std::nullopt) { |
| 314 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_SIGHASH)); |
| 315 | SerializeToVector(s, *sighash_type); |
| 316 | } |
| 317 | |
| 318 | // Write the redeem script |
| 319 | if (!redeem_script.empty()) { |
| 320 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_REDEEMSCRIPT)); |
| 321 | s << redeem_script; |
| 322 | } |
| 323 | |
| 324 | // Write the witness script |
| 325 | if (!witness_script.empty()) { |
| 326 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_WITNESSSCRIPT)); |
| 327 | s << witness_script; |
| 328 | } |
| 329 | |
| 330 | // Write any hd keypaths |
| 331 | SerializeHDKeypaths(s, hd_keypaths, CompactSizeWriter(PSBT_IN_BIP32_DERIVATION)); |
| 332 | |
| 333 | // Write any ripemd160 preimage |
| 334 | for (const auto& [hash, preimage] : ripemd160_preimages) { |
| 335 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_RIPEMD160), Span{hash}); |
| 336 | s << preimage; |
| 337 | } |
| 338 | |
| 339 | // Write any sha256 preimage |
| 340 | for (const auto& [hash, preimage] : sha256_preimages) { |
| 341 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_SHA256), Span{hash}); |
| 342 | s << preimage; |
| 343 | } |
| 344 | |
| 345 | // Write any hash160 preimage |
| 346 | for (const auto& [hash, preimage] : hash160_preimages) { |
| 347 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_HASH160), Span{hash}); |
| 348 | s << preimage; |
| 349 | } |
| 350 |
nothing calls this directly
no test coverage detected