Skip to content

Commit 9baff05

Browse files
committed
sign: Include taproot output key's KeyOriginInfo in sigdata
1 parent 4b24bfe commit 9baff05

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/script/sign.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,19 @@ static bool SignTaproot(const SigningProvider& provider, const BaseSignatureCrea
355355

356356
// Try key path spending.
357357
{
358-
KeyOriginInfo info;
359-
if (provider.GetKeyOriginByXOnly(sigdata.tr_spenddata.internal_key, info)) {
358+
KeyOriginInfo internal_key_info;
359+
if (provider.GetKeyOriginByXOnly(sigdata.tr_spenddata.internal_key, internal_key_info)) {
360360
auto it = sigdata.taproot_misc_pubkeys.find(sigdata.tr_spenddata.internal_key);
361361
if (it == sigdata.taproot_misc_pubkeys.end()) {
362-
sigdata.taproot_misc_pubkeys.emplace(sigdata.tr_spenddata.internal_key, std::make_pair(std::set<uint256>(), info));
362+
sigdata.taproot_misc_pubkeys.emplace(sigdata.tr_spenddata.internal_key, std::make_pair(std::set<uint256>(), internal_key_info));
363+
}
364+
}
365+
366+
KeyOriginInfo output_key_info;
367+
if (provider.GetKeyOriginByXOnly(output, output_key_info)) {
368+
auto it = sigdata.taproot_misc_pubkeys.find(output);
369+
if (it == sigdata.taproot_misc_pubkeys.end()) {
370+
sigdata.taproot_misc_pubkeys.emplace(output, std::make_pair(std::set<uint256>(), output_key_info));
363371
}
364372
}
365373

src/script/sign.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct SignatureData {
8080
std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> misc_pubkeys;
8181
std::vector<unsigned char> taproot_key_path_sig; /// Schnorr signature for key path spending
8282
std::map<std::pair<XOnlyPubKey, uint256>, std::vector<unsigned char>> taproot_script_sigs; ///< (Partial) schnorr signatures, indexed by XOnlyPubKey and leaf_hash.
83-
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).
83+
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 and output keys (may have no leaf script hashes).
8484
std::map<CKeyID, XOnlyPubKey> tap_pubkeys; ///< Misc Taproot pubkeys involved in this input, by hash. (Equivalent of misc_pubkeys but for Taproot.)
8585
std::vector<CKeyID> missing_pubkeys; ///< KeyIDs of pubkeys which could not be found
8686
std::vector<CKeyID> missing_sigs; ///< KeyIDs of pubkeys for signatures which could not be found

0 commit comments

Comments
 (0)