aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2021-07-19 15:29:55 -0400
committerAndrew Chow <achow101-github@achow101.com>2022-06-27 16:47:48 -0400
commit4d1223e5123e60be93b5ad42ba0aee72d0612ea7 (patch)
treeda4f395e6d693d2e1229a476e3f8c52d98144704 /src/script
parent52e3f2f88ef1ac7062e905bf2d745b70463ee3e9 (diff)
Fetch key origins for Taproot keys
Diffstat (limited to 'src/script')
-rw-r--r--src/script/sign.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 2d569d674a..e46d9be7d4 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -169,6 +169,17 @@ static bool SignTaprootScript(const SigningProvider& provider, const BaseSignatu
// <xonly pubkey> OP_CHECKSIG
if (script.size() == 34 && script[33] == OP_CHECKSIG && script[0] == 0x20) {
XOnlyPubKey pubkey{Span{script}.subspan(1, 32)};
+
+ KeyOriginInfo info;
+ if (provider.GetKeyOriginByXOnly(pubkey, info)) {
+ auto it = sigdata.taproot_misc_pubkeys.find(pubkey);
+ if (it == sigdata.taproot_misc_pubkeys.end()) {
+ sigdata.taproot_misc_pubkeys.emplace(pubkey, std::make_pair(std::set<uint256>({leaf_hash}), info));
+ } else {
+ it->second.first.insert(leaf_hash);
+ }
+ }
+
std::vector<unsigned char> sig;
if (CreateTaprootScriptSig(creator, sigdata, provider, sig, pubkey, leaf_hash, sigversion)) {
result = Vector(std::move(sig));
@@ -213,6 +224,14 @@ static bool SignTaproot(const SigningProvider& provider, const BaseSignatureCrea
// Try key path spending.
{
+ KeyOriginInfo info;
+ if (provider.GetKeyOriginByXOnly(spenddata.internal_key, info)) {
+ auto it = sigdata.taproot_misc_pubkeys.find(spenddata.internal_key);
+ if (it == sigdata.taproot_misc_pubkeys.end()) {
+ sigdata.taproot_misc_pubkeys.emplace(spenddata.internal_key, std::make_pair(std::set<uint256>(), info));
+ }
+ }
+
std::vector<unsigned char> sig;
if (sigdata.taproot_key_path_sig.size() == 0) {
if (creator.CreateSchnorrSig(provider, sig, spenddata.internal_key, nullptr, &spenddata.merkle_root, SigVersion::TAPROOT)) {