Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow validateaddress to print hdkeypath information for exchange addresses #1405

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading