mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Merge #19136: wallet: add parent_desc to getaddressinfo
de6b389d5dtests: Test getaddressinfo parent_desc (Andrew Chow)e4ac869a0arpc: Add parent descriptor to getaddressinfo output (Andrew Chow)bbe4a36152wallet: Add GetDescriptorString to DescriptorScriptPubKeyMan (Andrew Chow)9be1437c49descriptors: Add ToNormalizedString and tests (Andrew Chow) Pull request description: Adds `parent_desc` field to the `getaddressinfo` RPC to export a public descriptor. Using the given address, `getaddressinfo` will look up which `DescriptorScriptPubKeyMan` can be used to produce that address. It will then return the descriptor for that `DescriptorScriptPubKeyMan` in the `parent_desc` field. The descriptor will be in a normalized form where the xpub at the last hardened step is derived so that the descriptor can be imported to other wallets. Tests are added to check that the correct descriptor is being returned for the wallet's addresses and that these descriptors can be imported and used in other wallets. As part of this PR, a `ToNormalizedString` function is added to the descriptor classes. This really only has an effect on `BIP32PubkeyProvider`s that have hardened derivation steps. Tests are added to check that normalized descriptors are returned. ACKs for top commit: Sjors: utACKde6b389d5dS3RK: Tested ACKde6b389jonatack: Tested ACKde6b389d5dmodulo a few minor comments fjahr: Code review ACKde6b389d5dmeshcollider: Tested ACKde6b389d5dTree-SHA512: a633e4a39f2abbd95afd7488484cfa66fdd2651dac59fe59f2b80a0940a2a4a13acf889c534a6948903d701484a2ba1218e3081feafe0b9a720dccfa9e43ca2b
This commit is contained in:
@@ -2264,3 +2264,16 @@ const std::vector<CScript> DescriptorScriptPubKeyMan::GetScriptPubKeys() const
|
||||
}
|
||||
return script_pub_keys;
|
||||
}
|
||||
|
||||
bool DescriptorScriptPubKeyMan::GetDescriptorString(std::string& out, bool priv) const
|
||||
{
|
||||
LOCK(cs_desc_man);
|
||||
if (m_storage.IsLocked()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FlatSigningProvider provider;
|
||||
provider.keys = GetKeys();
|
||||
|
||||
return m_wallet_descriptor.descriptor->ToNormalizedString(provider, out, priv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user