mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
Extract Taproot internal keyid with GetKeyFromDestination
This commit is contained in:
parent
d8abbe119c
commit
4868c9f1b3
1 changed files with 12 additions and 2 deletions
|
@ -190,8 +190,8 @@ bool FillableSigningProvider::GetCScript(const CScriptID &hash, CScript& redeemS
|
||||||
|
|
||||||
CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& dest)
|
CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination& dest)
|
||||||
{
|
{
|
||||||
// Only supports destinations which map to single public keys, i.e. P2PKH,
|
// Only supports destinations which map to single public keys:
|
||||||
// P2WPKH, and P2SH-P2WPKH.
|
// P2PKH, P2WPKH, P2SH-P2WPKH, P2TR
|
||||||
if (auto id = std::get_if<PKHash>(&dest)) {
|
if (auto id = std::get_if<PKHash>(&dest)) {
|
||||||
return ToKeyID(*id);
|
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();
|
return CKeyID();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue