Fix parsing of node public keys in manifest CLI:

The existing code attempts to validate the provided node public key
using a function that assumes that the encoded public key is for an
account. This causes the parsing to fail.

This commit fixes #3317 by letting the caller specify the type of
the public key being checked.
This commit is contained in:
Nik Bougalis
2021-01-13 03:09:39 -08:00
parent f74b469e68
commit 012bbcfe36
2 changed files with 6 additions and 3 deletions

View File

@@ -1915,6 +1915,7 @@ NetworkOPsImp::pubManifest(Manifest const& mo)
jvObj[jss::master_signature] = strHex(mo.getMasterSignature());
if (!mo.domain.empty())
jvObj[jss::domain] = mo.domain;
jvObj[jss::manifest] = strHex(mo.serialized);
for (auto i = mStreamMaps[sManifests].begin();
i != mStreamMaps[sManifests].end();)

View File

@@ -151,9 +151,11 @@ private:
}
static bool
validPublicKey(std::string const& strPk)
validPublicKey(
std::string const& strPk,
TokenType type = TokenType::AccountPublic)
{
if (parseBase58<PublicKey>(TokenType::AccountPublic, strPk))
if (parseBase58<PublicKey>(type, strPk))
return true;
auto pkHex = strUnHex(strPk);
@@ -235,7 +237,7 @@ private:
Json::Value jvRequest(Json::objectValue);
std::string const strPk = jvParams[0u].asString();
if (!validPublicKey(strPk))
if (!validPublicKey(strPk, TokenType::NodePublic))
return rpcError(rpcPUBLIC_MALFORMED);
jvRequest[jss::public_key] = strPk;