mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
partial Merge bitcoin/bitcoin#27920: wallet: bugfix, always use apostrophe for spkm descriptor ID
BACKPORT NOTICE It includes only this commit: 97a965d98f1582ea1b1377bd258c9088380e1b8b refactor: extract descriptor ID calculation from spkm GetID() This allows us to verify the descriptor ID on the descriptors unit tests in different software versions without requiring to use the entire DescriptorScriptPubKeyMan machinery. Note: The unit test changes are introduced after the bugfix commit but this commit + the unit test commit can be cherry-picked on top of the v25 branch to verify IDs correctness. IDs must be the same for v25 and after the bugfix commit.
This commit is contained in:
parent
f675fcbd25
commit
05e5966199
@ -1162,6 +1162,14 @@ std::unique_ptr<Descriptor> InferDescriptor(const CScript& script, const Signing
|
|||||||
return InferScript(script, ParseScriptContext::TOP, provider);
|
return InferScript(script, ParseScriptContext::TOP, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256 DescriptorID(const Descriptor& desc)
|
||||||
|
{
|
||||||
|
std::string desc_str = desc.ToString();
|
||||||
|
uint256 id;
|
||||||
|
CSHA256().Write((unsigned char*)desc_str.data(), desc_str.size()).Finalize(id.begin());
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
void DescriptorCache::CacheParentExtPubKey(uint32_t key_exp_pos, const CExtPubKey& xpub)
|
void DescriptorCache::CacheParentExtPubKey(uint32_t key_exp_pos, const CExtPubKey& xpub)
|
||||||
{
|
{
|
||||||
m_parent_xpubs[key_exp_pos] = xpub;
|
m_parent_xpubs[key_exp_pos] = xpub;
|
||||||
|
@ -182,4 +182,9 @@ std::string GetDescriptorChecksum(const std::string& descriptor);
|
|||||||
*/
|
*/
|
||||||
std::unique_ptr<Descriptor> InferDescriptor(const CScript& script, const SigningProvider& provider);
|
std::unique_ptr<Descriptor> InferDescriptor(const CScript& script, const SigningProvider& provider);
|
||||||
|
|
||||||
|
/** Unique identifier that may not change over time, unless explicitly marked as not backwards compatible.
|
||||||
|
* This is not part of BIP 380, not guaranteed to be interoperable and should not be exposed to the user.
|
||||||
|
*/
|
||||||
|
uint256 DescriptorID(const Descriptor& desc);
|
||||||
|
|
||||||
#endif // BITCOIN_SCRIPT_DESCRIPTOR_H
|
#endif // BITCOIN_SCRIPT_DESCRIPTOR_H
|
||||||
|
@ -2309,10 +2309,7 @@ std::unique_ptr<CKeyMetadata> DescriptorScriptPubKeyMan::GetMetadata(const CTxDe
|
|||||||
uint256 DescriptorScriptPubKeyMan::GetID() const
|
uint256 DescriptorScriptPubKeyMan::GetID() const
|
||||||
{
|
{
|
||||||
LOCK(cs_desc_man);
|
LOCK(cs_desc_man);
|
||||||
std::string desc_str = m_wallet_descriptor.descriptor->ToString();
|
return DescriptorID(*m_wallet_descriptor.descriptor);
|
||||||
uint256 id;
|
|
||||||
CSHA256().Write((unsigned char*)desc_str.data(), desc_str.size()).Finalize(id.begin());
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorScriptPubKeyMan::SetInternal(bool internal)
|
void DescriptorScriptPubKeyMan::SetInternal(bool internal)
|
||||||
|
Loading…
Reference in New Issue
Block a user