mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
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.
Github-Pull: #26418
Rebased-From: 323890d0d7
This commit is contained in:
parent
bb1fabda30
commit
754eefd21c
1 changed files with 10 additions and 11 deletions
|
@ -146,6 +146,16 @@ static bool CreateSig(const BaseSignatureCreator& creator, SignatureData& sigdat
|
||||||
|
|
||||||
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)
|
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)
|
||||||
{
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto lookup_key = std::make_pair(pubkey, leaf_hash);
|
auto lookup_key = std::make_pair(pubkey, leaf_hash);
|
||||||
auto it = sigdata.taproot_script_sigs.find(lookup_key);
|
auto it = sigdata.taproot_script_sigs.find(lookup_key);
|
||||||
if (it != sigdata.taproot_script_sigs.end()) {
|
if (it != sigdata.taproot_script_sigs.end()) {
|
||||||
|
@ -170,17 +180,6 @@ static bool SignTaprootScript(const SigningProvider& provider, const BaseSignatu
|
||||||
// <xonly pubkey> OP_CHECKSIG
|
// <xonly pubkey> OP_CHECKSIG
|
||||||
if (script.size() == 34 && script[33] == OP_CHECKSIG && script[0] == 0x20) {
|
if (script.size() == 34 && script[33] == OP_CHECKSIG && script[0] == 0x20) {
|
||||||
XOnlyPubKey pubkey{Span{script}.subspan(1, 32)};
|
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;
|
std::vector<unsigned char> sig;
|
||||||
if (CreateTaprootScriptSig(creator, sigdata, provider, sig, pubkey, leaf_hash, sigversion)) {
|
if (CreateTaprootScriptSig(creator, sigdata, provider, sig, pubkey, leaf_hash, sigversion)) {
|
||||||
result = Vector(std::move(sig));
|
result = Vector(std::move(sig));
|
||||||
|
|
Loading…
Add table
Reference in a new issue