Skip to content

Commit

Permalink
Add public_key to the "vl" method response:
Browse files Browse the repository at this point in the history
The "/vl" HTTP endpoint can be used to request a particular
UNL from a rippled instance.

This commit, if merged, includes the public key of the requested
list in the response.

This commit fixes #3392
  • Loading branch information
natenichols authored and nbougalis committed Sep 1, 2020
1 parent 271e790 commit b1d47c6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ripple/app/misc/impl/ValidatorList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,11 @@ ValidatorList::getAvailable(boost::beast::string_view const& pubKey)

Json::Value value(Json::objectValue);

value["manifest"] = iter->second.rawManifest;
value["blob"] = iter->second.rawBlob;
value["signature"] = iter->second.rawSignature;
value["version"] = iter->second.rawVersion;
value[jss::public_key] = std::string{pubKey};
value[jss::manifest] = iter->second.rawManifest;
value[jss::blob] = iter->second.rawBlob;
value[jss::signature] = iter->second.rawSignature;
value[jss::version] = iter->second.rawVersion;

return value;
}
Expand Down
1 change: 1 addition & 0 deletions src/ripple/protocol/jss.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ JSS(base_fee_xrp); // out: NetworkOPs
JSS(bids); // out: Subscribe
JSS(binary); // in: AccountTX, LedgerEntry,
// AccountTxOld, Tx LedgerData
JSS(blob); // out: ValidatorList
JSS(books); // in: Subscribe, Unsubscribe
JSS(both); // in: Subscribe, Unsubscribe
JSS(both_sides); // in: Subscribe, Unsubscribe
Expand Down
16 changes: 16 additions & 0 deletions src/test/app/ValidatorList_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <ripple/protocol/SecretKey.h>
#include <ripple/protocol/Sign.h>
#include <ripple/protocol/digest.h>
#include <ripple/protocol/jss.h>
#include <test/jtx.h>

namespace ripple {
Expand Down Expand Up @@ -570,6 +571,21 @@ class ValidatorList_test : public beast::unit_test::suite
BEAST_EXPECT(trustedKeys->listed(val.signingPublic));
}

const auto hexPublic =
strHex(publisherPublic.begin(), publisherPublic.end());

const auto available = trustedKeys->getAvailable(hexPublic);

if (BEAST_EXPECT(available))
{
auto const& a = *available;
BEAST_EXPECT(a[jss::public_key] == hexPublic);
BEAST_EXPECT(a[jss::blob] == blob2);
BEAST_EXPECT(a[jss::manifest] == manifest1);
BEAST_EXPECT(a[jss::version] == version);
BEAST_EXPECT(a[jss::signature] == sig2);
}

// do not re-apply lists with past or current sequence numbers
BEAST_EXPECT(
ListDisposition::stale ==
Expand Down

0 comments on commit b1d47c6

Please sign in to comment.