Skip to content

Commit

Permalink
Allow validateaddress to print hdkeypath for exchange addresses (#1405)
Browse files Browse the repository at this point in the history
  • Loading branch information
psolstice authored Jan 28, 2024
1 parent 807db78 commit 07c6e12
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/base58.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,17 @@ bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const
return true;
}

bool CBitcoinAddress::GetKeyIDExt(CKeyID& keyID) const
{
if (!IsValid() || !(vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS) ||
vchVersion == Params().Base58Prefix(CChainParams::EXCHANGE_PUBKEY_ADDRESS)))
return false;
uint160 id;
memcpy(&id, &vchData[0], 20);
keyID = CKeyID(id);
return true;
}

bool CBitcoinAddress::IsScript() const
{
return IsValid() && vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
Expand Down
1 change: 1 addition & 0 deletions src/base58.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class CBitcoinAddress : public CBase58Data {
CTxDestination Get() const;
bool GetIndexKey(uint160& hashBytes, AddressType & type) const;
bool GetKeyID(CKeyID &keyID) const;
bool GetKeyIDExt(CKeyID &keyID) const; // same as GetKeyID() but also works in case of exchange address
bool IsScript() const;
};

Expand Down
2 changes: 1 addition & 1 deletion src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ UniValue validateaddress(const JSONRPCRequest& request)
CKeyID keyID;
if (pwallet) {
const auto& meta = pwallet->mapKeyMetadata;
auto it = address.GetKeyID(keyID) ? meta.find(keyID) : meta.end();
auto it = address.GetKeyIDExt(keyID) ? meta.find(keyID) : meta.end();
if (it == meta.end()) {
it = meta.find(CScriptID(scriptPubKey));
}
Expand Down

0 comments on commit 07c6e12

Please sign in to comment.