| 295 | } |
| 296 | |
| 297 | void PSBTInput::FillSignatureData(SignatureData& sigdata) const |
| 298 | { |
| 299 | if (!final_script_sig.empty()) { |
| 300 | sigdata.scriptSig = final_script_sig; |
| 301 | sigdata.complete = true; |
| 302 | } |
| 303 | if (!final_script_witness.IsNull()) { |
| 304 | sigdata.scriptWitness = final_script_witness; |
| 305 | sigdata.complete = true; |
| 306 | } |
| 307 | if (sigdata.complete) { |
| 308 | return; |
| 309 | } |
| 310 | |
| 311 | sigdata.signatures.insert(partial_sigs.begin(), partial_sigs.end()); |
| 312 | if (!redeem_script.empty()) { |
| 313 | sigdata.redeem_script = redeem_script; |
| 314 | } |
| 315 | if (!witness_script.empty()) { |
| 316 | sigdata.witness_script = witness_script; |
| 317 | } |
| 318 | for (const auto& key_pair : hd_keypaths) { |
| 319 | sigdata.misc_pubkeys.emplace(key_pair.first.GetID(), key_pair); |
| 320 | } |
| 321 | if (!m_tap_key_sig.empty()) { |
| 322 | sigdata.taproot_key_path_sig = m_tap_key_sig; |
| 323 | } |
| 324 | for (const auto& [pubkey_leaf, sig] : m_tap_script_sigs) { |
| 325 | sigdata.taproot_script_sigs.emplace(pubkey_leaf, sig); |
| 326 | } |
| 327 | if (!m_tap_internal_key.IsNull()) { |
| 328 | sigdata.tr_spenddata.internal_key = m_tap_internal_key; |
| 329 | } |
| 330 | if (!m_tap_merkle_root.IsNull()) { |
| 331 | sigdata.tr_spenddata.merkle_root = m_tap_merkle_root; |
| 332 | } |
| 333 | for (const auto& [leaf_script, control_block] : m_tap_scripts) { |
| 334 | sigdata.tr_spenddata.scripts.emplace(leaf_script, control_block); |
| 335 | } |
| 336 | for (const auto& [pubkey, leaf_origin] : m_tap_bip32_paths) { |
| 337 | sigdata.taproot_misc_pubkeys.emplace(pubkey, leaf_origin); |
| 338 | sigdata.tap_pubkeys.emplace(Hash160(pubkey), pubkey); |
| 339 | } |
| 340 | for (const auto& [hash, preimage] : ripemd160_preimages) { |
| 341 | sigdata.ripemd160_preimages.emplace(std::vector<unsigned char>(hash.begin(), hash.end()), preimage); |
| 342 | } |
| 343 | for (const auto& [hash, preimage] : sha256_preimages) { |
| 344 | sigdata.sha256_preimages.emplace(std::vector<unsigned char>(hash.begin(), hash.end()), preimage); |
| 345 | } |
| 346 | for (const auto& [hash, preimage] : hash160_preimages) { |
| 347 | sigdata.hash160_preimages.emplace(std::vector<unsigned char>(hash.begin(), hash.end()), preimage); |
| 348 | } |
| 349 | for (const auto& [hash, preimage] : hash256_preimages) { |
| 350 | sigdata.hash256_preimages.emplace(std::vector<unsigned char>(hash.begin(), hash.end()), preimage); |
| 351 | } |
| 352 | sigdata.musig2_pubkeys.insert(m_musig2_participants.begin(), m_musig2_participants.end()); |
| 353 | for (const auto& [agg_key_lh, pubnonces] : m_musig2_pubnonces) { |
| 354 | sigdata.musig2_pubnonces[agg_key_lh].insert(pubnonces.begin(), pubnonces.end()); |