| 358 | |
| 359 | template <typename Stream> |
| 360 | inline void Serialize(Stream& s) const { |
| 361 | // Write the utxo |
| 362 | if (non_witness_utxo) { |
| 363 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_NON_WITNESS_UTXO)); |
| 364 | SerializeToVector(s, TX_NO_WITNESS(non_witness_utxo)); |
| 365 | } |
| 366 | if (!witness_utxo.IsNull()) { |
| 367 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_WITNESS_UTXO)); |
| 368 | SerializeToVector(s, witness_utxo); |
| 369 | } |
| 370 | |
| 371 | if (final_script_sig.empty() && final_script_witness.IsNull()) { |
| 372 | // Write any partial signatures |
| 373 | for (const auto& sig_pair : partial_sigs) { |
| 374 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_PARTIAL_SIG), std::span{sig_pair.second.first}); |
| 375 | s << sig_pair.second.second; |
| 376 | } |
| 377 | |
| 378 | // Write the sighash type |
| 379 | if (sighash_type != std::nullopt) { |
| 380 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_SIGHASH)); |
| 381 | SerializeToVector(s, *sighash_type); |
| 382 | } |
| 383 | |
| 384 | // Write the redeem script |
| 385 | if (!redeem_script.empty()) { |
| 386 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_REDEEMSCRIPT)); |
| 387 | s << redeem_script; |
| 388 | } |
| 389 | |
| 390 | // Write the witness script |
| 391 | if (!witness_script.empty()) { |
| 392 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_WITNESSSCRIPT)); |
| 393 | s << witness_script; |
| 394 | } |
| 395 | |
| 396 | // Write any hd keypaths |
| 397 | SerializeHDKeypaths(s, hd_keypaths, CompactSizeWriter(PSBT_IN_BIP32_DERIVATION)); |
| 398 | |
| 399 | // Write any ripemd160 preimage |
| 400 | for (const auto& [hash, preimage] : ripemd160_preimages) { |
| 401 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_RIPEMD160), std::span{hash}); |
| 402 | s << preimage; |
| 403 | } |
| 404 | |
| 405 | // Write any sha256 preimage |
| 406 | for (const auto& [hash, preimage] : sha256_preimages) { |
| 407 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_SHA256), std::span{hash}); |
| 408 | s << preimage; |
| 409 | } |
| 410 | |
| 411 | // Write any hash160 preimage |
| 412 | for (const auto& [hash, preimage] : hash160_preimages) { |
| 413 | SerializeToVector(s, CompactSizeWriter(PSBT_IN_HASH160), std::span{hash}); |
| 414 | s << preimage; |
| 415 | } |
| 416 | |
| 417 | // Write any hash256 preimage |
nothing calls this directly
no test coverage detected