mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Fill PSBT Taproot input data to/from SignatureData
This commit is contained in:
parent
05e2cc9a30
commit
52e3f2f88e
2 changed files with 37 additions and 0 deletions
36
src/psbt.cpp
36
src/psbt.cpp
|
@ -113,6 +113,24 @@ void PSBTInput::FillSignatureData(SignatureData& sigdata) const
|
|||
for (const auto& key_pair : hd_keypaths) {
|
||||
sigdata.misc_pubkeys.emplace(key_pair.first.GetID(), key_pair);
|
||||
}
|
||||
if (!m_tap_key_sig.empty()) {
|
||||
sigdata.taproot_key_path_sig = m_tap_key_sig;
|
||||
}
|
||||
for (const auto& [pubkey_leaf, sig] : m_tap_script_sigs) {
|
||||
sigdata.taproot_script_sigs.emplace(pubkey_leaf, sig);
|
||||
}
|
||||
if (!m_tap_internal_key.IsNull()) {
|
||||
sigdata.tr_spenddata.internal_key = m_tap_internal_key;
|
||||
}
|
||||
if (!m_tap_merkle_root.IsNull()) {
|
||||
sigdata.tr_spenddata.merkle_root = m_tap_merkle_root;
|
||||
}
|
||||
for (const auto& [leaf_script, control_block] : m_tap_scripts) {
|
||||
sigdata.tr_spenddata.scripts.emplace(leaf_script, control_block);
|
||||
}
|
||||
for (const auto& [pubkey, leaf_origin] : m_tap_bip32_paths) {
|
||||
sigdata.taproot_misc_pubkeys.emplace(pubkey, leaf_origin);
|
||||
}
|
||||
}
|
||||
|
||||
void PSBTInput::FromSignatureData(const SignatureData& sigdata)
|
||||
|
@ -142,6 +160,24 @@ void PSBTInput::FromSignatureData(const SignatureData& sigdata)
|
|||
for (const auto& entry : sigdata.misc_pubkeys) {
|
||||
hd_keypaths.emplace(entry.second);
|
||||
}
|
||||
if (!sigdata.taproot_key_path_sig.empty()) {
|
||||
m_tap_key_sig = sigdata.taproot_key_path_sig;
|
||||
}
|
||||
for (const auto& [pubkey_leaf, sig] : sigdata.taproot_script_sigs) {
|
||||
m_tap_script_sigs.emplace(pubkey_leaf, sig);
|
||||
}
|
||||
if (!sigdata.tr_spenddata.internal_key.IsNull()) {
|
||||
m_tap_internal_key = sigdata.tr_spenddata.internal_key;
|
||||
}
|
||||
if (!sigdata.tr_spenddata.merkle_root.IsNull()) {
|
||||
m_tap_merkle_root = sigdata.tr_spenddata.merkle_root;
|
||||
}
|
||||
for (const auto& [leaf_script, control_block] : sigdata.tr_spenddata.scripts) {
|
||||
m_tap_scripts.emplace(leaf_script, control_block);
|
||||
}
|
||||
for (const auto& [pubkey, leaf_origin] : sigdata.taproot_misc_pubkeys) {
|
||||
m_tap_bip32_paths.emplace(pubkey, leaf_origin);
|
||||
}
|
||||
}
|
||||
|
||||
void PSBTInput::Merge(const PSBTInput& input)
|
||||
|
|
|
@ -74,6 +74,7 @@ struct SignatureData {
|
|||
std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> misc_pubkeys;
|
||||
std::vector<unsigned char> taproot_key_path_sig; /// Schnorr signature for key path spending
|
||||
std::map<std::pair<XOnlyPubKey, uint256>, std::vector<unsigned char>> taproot_script_sigs; ///< (Partial) schnorr signatures, indexed by XOnlyPubKey and leaf_hash.
|
||||
std::map<XOnlyPubKey, std::pair<std::set<uint256>, KeyOriginInfo>> taproot_misc_pubkeys; ///< Miscellaneous Taproot pubkeys involved in this input along with their leaf script hashes and key origin data. Also includes the Taproot internal key (may have no leaf script hashes).
|
||||
std::vector<CKeyID> missing_pubkeys; ///< KeyIDs of pubkeys which could not be found
|
||||
std::vector<CKeyID> missing_sigs; ///< KeyIDs of pubkeys for signatures which could not be found
|
||||
uint160 missing_redeem_script; ///< ScriptID of the missing redeemScript (if any)
|
||||
|
|
Loading…
Add table
Reference in a new issue