@@ -169,6 +169,17 @@ static bool SignTaprootScript(const SigningProvider& provider, const BaseSignatu
169
169
// <xonly pubkey> OP_CHECKSIG
170
170
if (script.size () == 34 && script[33 ] == OP_CHECKSIG && script[0 ] == 0x20 ) {
171
171
XOnlyPubKey pubkey{Span{script}.subspan (1 , 32 )};
172
+
173
+ KeyOriginInfo info;
174
+ if (provider.GetKeyOriginByXOnly (pubkey, info)) {
175
+ auto it = sigdata.taproot_misc_pubkeys .find (pubkey);
176
+ if (it == sigdata.taproot_misc_pubkeys .end ()) {
177
+ sigdata.taproot_misc_pubkeys .emplace (pubkey, std::make_pair (std::set<uint256>({leaf_hash}), info));
178
+ } else {
179
+ it->second .first .insert (leaf_hash);
180
+ }
181
+ }
182
+
172
183
std::vector<unsigned char > sig;
173
184
if (CreateTaprootScriptSig (creator, sigdata, provider, sig, pubkey, leaf_hash, sigversion)) {
174
185
result = Vector (std::move (sig));
@@ -213,6 +224,14 @@ static bool SignTaproot(const SigningProvider& provider, const BaseSignatureCrea
213
224
214
225
// Try key path spending.
215
226
{
227
+ KeyOriginInfo info;
228
+ if (provider.GetKeyOriginByXOnly (spenddata.internal_key , info)) {
229
+ auto it = sigdata.taproot_misc_pubkeys .find (spenddata.internal_key );
230
+ if (it == sigdata.taproot_misc_pubkeys .end ()) {
231
+ sigdata.taproot_misc_pubkeys .emplace (spenddata.internal_key , std::make_pair (std::set<uint256>(), info));
232
+ }
233
+ }
234
+
216
235
std::vector<unsigned char > sig;
217
236
if (sigdata.taproot_key_path_sig .size () == 0 ) {
218
237
if (creator.CreateSchnorrSig (provider, sig, spenddata.internal_key , nullptr , &spenddata.merkle_root , SigVersion::TAPROOT)) {
0 commit comments