From 9baff05e494443cd82708490f384aa3034ad43bd Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 4 Mar 2024 17:53:37 -0500 Subject: [PATCH] sign: Include taproot output key's KeyOriginInfo in sigdata --- src/script/sign.cpp | 14 +++++++++++--- src/script/sign.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 1e40d5328fc..8575c0b90da 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -355,11 +355,19 @@ static bool SignTaproot(const SigningProvider& provider, const BaseSignatureCrea // Try key path spending. { - KeyOriginInfo info; - if (provider.GetKeyOriginByXOnly(sigdata.tr_spenddata.internal_key, info)) { + KeyOriginInfo internal_key_info; + if (provider.GetKeyOriginByXOnly(sigdata.tr_spenddata.internal_key, internal_key_info)) { auto it = sigdata.taproot_misc_pubkeys.find(sigdata.tr_spenddata.internal_key); if (it == sigdata.taproot_misc_pubkeys.end()) { - sigdata.taproot_misc_pubkeys.emplace(sigdata.tr_spenddata.internal_key, std::make_pair(std::set(), info)); + sigdata.taproot_misc_pubkeys.emplace(sigdata.tr_spenddata.internal_key, std::make_pair(std::set(), internal_key_info)); + } + } + + KeyOriginInfo output_key_info; + if (provider.GetKeyOriginByXOnly(output, output_key_info)) { + auto it = sigdata.taproot_misc_pubkeys.find(output); + if (it == sigdata.taproot_misc_pubkeys.end()) { + sigdata.taproot_misc_pubkeys.emplace(output, std::make_pair(std::set(), output_key_info)); } } diff --git a/src/script/sign.h b/src/script/sign.h index 5af6392b128..fea937108ba 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -80,7 +80,7 @@ struct SignatureData { std::map> misc_pubkeys; std::vector taproot_key_path_sig; /// Schnorr signature for key path spending std::map, std::vector> taproot_script_sigs; ///< (Partial) schnorr signatures, indexed by XOnlyPubKey and leaf_hash. - std::map, 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::map, 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 and output keys (may have no leaf script hashes). std::map tap_pubkeys; ///< Misc Taproot pubkeys involved in this input, by hash. (Equivalent of misc_pubkeys but for Taproot.) std::vector missing_pubkeys; ///< KeyIDs of pubkeys which could not be found std::vector missing_sigs; ///< KeyIDs of pubkeys for signatures which could not be found