mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
descriptors: Move FlatSigningProvider pubkey filling to GetPubKey
Instead of MakeScripts inconsistently filling the output FlatSigningProvider with the pubkeys involved, just do it in GetPubKey.
This commit is contained in:
parent
25a3b9b0f5
commit
4b0303197e
1 changed files with 5 additions and 6 deletions
|
@ -242,6 +242,7 @@ public:
|
|||
{
|
||||
std::optional<CPubKey> pub = m_provider->GetPubKey(pos, arg, out, read_cache, write_cache);
|
||||
if (!pub) return std::nullopt;
|
||||
Assert(out.pubkeys.contains(pub->GetID()));
|
||||
auto& [pubkey, suborigin] = out.origins[pub->GetID()];
|
||||
Assert(pubkey == *pub); // m_provider must have a valid origin by this point.
|
||||
std::copy(std::begin(m_origin.fingerprint), std::end(m_origin.fingerprint), suborigin.fingerprint);
|
||||
|
@ -305,6 +306,7 @@ public:
|
|||
CKeyID keyid = m_pubkey.GetID();
|
||||
std::copy(keyid.begin(), keyid.begin() + sizeof(info.fingerprint), info.fingerprint);
|
||||
out.origins.emplace(keyid, std::make_pair(m_pubkey, info));
|
||||
out.pubkeys.emplace(keyid, m_pubkey);
|
||||
return m_pubkey;
|
||||
}
|
||||
bool IsRange() const override { return false; }
|
||||
|
@ -439,6 +441,7 @@ public:
|
|||
if (!der) return std::nullopt;
|
||||
|
||||
out.origins.emplace(final_extkey.pubkey.GetID(), std::make_pair(final_extkey.pubkey, info));
|
||||
out.pubkeys.emplace(final_extkey.pubkey.GetID(), final_extkey.pubkey);
|
||||
|
||||
if (write_cache) {
|
||||
// Only cache parent if there is any unhardened derivation
|
||||
|
@ -874,10 +877,9 @@ public:
|
|||
class PKHDescriptor final : public DescriptorImpl
|
||||
{
|
||||
protected:
|
||||
std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, std::span<const CScript>, FlatSigningProvider& out) const override
|
||||
std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, std::span<const CScript>, FlatSigningProvider&) const override
|
||||
{
|
||||
CKeyID id = keys[0].GetID();
|
||||
out.pubkeys.emplace(id, keys[0]);
|
||||
return Vector(GetScriptForDestination(PKHash(id)));
|
||||
}
|
||||
public:
|
||||
|
@ -909,10 +911,9 @@ public:
|
|||
class WPKHDescriptor final : public DescriptorImpl
|
||||
{
|
||||
protected:
|
||||
std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, std::span<const CScript>, FlatSigningProvider& out) const override
|
||||
std::vector<CScript> MakeScripts(const std::vector<CPubKey>& keys, std::span<const CScript>, FlatSigningProvider&) const override
|
||||
{
|
||||
CKeyID id = keys[0].GetID();
|
||||
out.pubkeys.emplace(id, keys[0]);
|
||||
return Vector(GetScriptForDestination(WitnessV0KeyHash(id)));
|
||||
}
|
||||
public:
|
||||
|
@ -948,7 +949,6 @@ protected:
|
|||
{
|
||||
std::vector<CScript> ret;
|
||||
CKeyID id = keys[0].GetID();
|
||||
out.pubkeys.emplace(id, keys[0]);
|
||||
ret.emplace_back(GetScriptForRawPubKey(keys[0])); // P2PK
|
||||
ret.emplace_back(GetScriptForDestination(PKHash(id))); // P2PKH
|
||||
if (keys[0].IsCompressed()) {
|
||||
|
@ -1175,7 +1175,6 @@ protected:
|
|||
builder.Finalize(xpk);
|
||||
WitnessV1Taproot output = builder.GetOutput();
|
||||
out.tr_trees[output] = builder;
|
||||
out.pubkeys.emplace(keys[0].GetID(), keys[0]);
|
||||
return Vector(GetScriptForDestination(output));
|
||||
}
|
||||
bool ToStringSubScriptHelper(const SigningProvider* arg, std::string& ret, const StringType type, const DescriptorCache* cache = nullptr) const override
|
||||
|
|
Loading…
Add table
Reference in a new issue