Skip to content

Commit 323890d

Browse files
committed
sign: Fill in taproot pubkey info for all script path sigs
Taproot pubkey info was not being added for multi_a signing. The filling of this info is moved into the common function CreateTaprootScriptSig so that any signing of taproot scripts will include the pubkey info.
1 parent 8b05076 commit 323890d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/script/sign.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ static bool CreateSig(const BaseSignatureCreator& creator, SignatureData& sigdat
146146

147147
static bool CreateTaprootScriptSig(const BaseSignatureCreator& creator, SignatureData& sigdata, const SigningProvider& provider, std::vector<unsigned char>& sig_out, const XOnlyPubKey& pubkey, const uint256& leaf_hash, SigVersion sigversion)
148148
{
149+
KeyOriginInfo info;
150+
if (provider.GetKeyOriginByXOnly(pubkey, info)) {
151+
auto it = sigdata.taproot_misc_pubkeys.find(pubkey);
152+
if (it == sigdata.taproot_misc_pubkeys.end()) {
153+
sigdata.taproot_misc_pubkeys.emplace(pubkey, std::make_pair(std::set<uint256>({leaf_hash}), info));
154+
} else {
155+
it->second.first.insert(leaf_hash);
156+
}
157+
}
158+
149159
auto lookup_key = std::make_pair(pubkey, leaf_hash);
150160
auto it = sigdata.taproot_script_sigs.find(lookup_key);
151161
if (it != sigdata.taproot_script_sigs.end()) {
@@ -170,17 +180,6 @@ static bool SignTaprootScript(const SigningProvider& provider, const BaseSignatu
170180
// <xonly pubkey> OP_CHECKSIG
171181
if (script.size() == 34 && script[33] == OP_CHECKSIG && script[0] == 0x20) {
172182
XOnlyPubKey pubkey{Span{script}.subspan(1, 32)};
173-
174-
KeyOriginInfo info;
175-
if (provider.GetKeyOriginByXOnly(pubkey, info)) {
176-
auto it = sigdata.taproot_misc_pubkeys.find(pubkey);
177-
if (it == sigdata.taproot_misc_pubkeys.end()) {
178-
sigdata.taproot_misc_pubkeys.emplace(pubkey, std::make_pair(std::set<uint256>({leaf_hash}), info));
179-
} else {
180-
it->second.first.insert(leaf_hash);
181-
}
182-
}
183-
184183
std::vector<unsigned char> sig;
185184
if (CreateTaprootScriptSig(creator, sigdata, provider, sig, pubkey, leaf_hash, sigversion)) {
186185
result = Vector(std::move(sig));

0 commit comments

Comments
 (0)