diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-06-23 21:17:48 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-11-16 12:20:13 -0500 |
commit | 4868c9f1b39f03adee0009cd41d96598b43e8b78 (patch) | |
tree | 935806e5f4c0c71e1b2c2e6142365d18f5902950 | |
parent | d8abbe119c71f917e0fd2e80536c1e5d979b4dc6 (diff) | |
download | bitcoin-4868c9f1b39f03adee0009cd41d96598b43e8b78.tar.xz |
Extract Taproot internal keyid with GetKeyFromDestination
-rw-r--r-- | src/script/signingprovider.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/script/signingprovider.cpp b/src/script/signingprovider.cpp index b80fbe22ce..17f97fa30c 100644 --- a/src/script/signingprovider.cpp +++ b/src/script/signingprovider.cpp @@ -190,8 +190,8 @@ bool FillableSigningProvider::GetCScript(const CScriptID &hash, CScript& redeemS CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& dest) { - // Only supports destinations which map to single public keys, i.e. P2PKH, - // P2WPKH, and P2SH-P2WPKH. + // Only supports destinations which map to single public keys: + // P2PKH, P2WPKH, P2SH-P2WPKH, P2TR if (auto id = std::get_if<PKHash>(&dest)) { return ToKeyID(*id); } @@ -208,5 +208,15 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& } } } + if (auto output_key = std::get_if<WitnessV1Taproot>(&dest)) { + TaprootSpendData spenddata; + CPubKey pub; + if (store.GetTaprootSpendData(*output_key, spenddata) + && !spenddata.internal_key.IsNull() + && spenddata.merkle_root.IsNull() + && store.GetPubKeyByXOnly(spenddata.internal_key, pub)) { + return pub.GetID(); + } + } return CKeyID(); } |