Skip to content

Commit e4ac869

Browse files
committed
rpc: Add parent descriptor to getaddressinfo output
Adds parent_desc field to getaddressinfo output which contains the descriptor that was used to derive the address if it is available.
1 parent bbe4a36 commit e4ac869

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3663,6 +3663,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
36633663
{RPCResult::Type::BOOL, "iswatchonly", "If the address is watchonly."},
36643664
{RPCResult::Type::BOOL, "solvable", "If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
36653665
{RPCResult::Type::STR, "desc", /* optional */ true, "A descriptor for spending coins sent to this address (only when solvable)."},
3666+
{RPCResult::Type::STR, "parent_desc", /* optional */ true, "The descriptor used to derive this address if this is a descriptor wallet"},
36663667
{RPCResult::Type::BOOL, "isscript", "If the key is a script."},
36673668
{RPCResult::Type::BOOL, "ischange", "If the address was used for change output."},
36683669
{RPCResult::Type::BOOL, "iswitness", "If the address is a witness address."},
@@ -3732,6 +3733,14 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
37323733
ret.pushKV("desc", InferDescriptor(scriptPubKey, *provider)->ToString());
37333734
}
37343735

3736+
DescriptorScriptPubKeyMan* desc_spk_man = dynamic_cast<DescriptorScriptPubKeyMan*>(pwallet->GetScriptPubKeyMan(scriptPubKey));
3737+
if (desc_spk_man) {
3738+
std::string desc_str;
3739+
if (desc_spk_man->GetDescriptorString(desc_str, false)) {
3740+
ret.pushKV("parent_desc", desc_str);
3741+
}
3742+
}
3743+
37353744
ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY));
37363745

37373746
UniValue detail = DescribeWalletAddress(pwallet, dest);

0 commit comments

Comments
 (0)