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

Make print-xdr display account IDs properly #2546

Merged
merged 1 commit into from
Jun 6, 2020
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
21 changes: 20 additions & 1 deletion src/main/dumpxdr.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "main/dumpxdr.h"
#include "crypto/Hex.h"
#include "crypto/SecretKey.h"
#include "crypto/StrKey.h"
#include "transactions/SignatureUtils.h"
#include "transactions/TransactionBridge.h"
#include "transactions/TransactionUtils.h"
#include "util/Decoder.h"
#include "util/Fs.h"
#include "util/XDROperators.h"
Expand Down Expand Up @@ -111,11 +113,28 @@ namespace stellar
{

std::string
xdr_printer(const PublicKey& pk)
xdr_printer(PublicKey const& pk)
{
return KeyUtils::toStrKey<PublicKey>(pk);
}

std::string
xdr_printer(MuxedAccount const& muxedAccount)
{
switch (muxedAccount.type())
{
case KEY_TYPE_ED25519:
return KeyUtils::toStrKey(toAccountID(muxedAccount));
case KEY_TYPE_MUXED_ED25519:
return fmt::format("{{ id = {}, accountID = {} }}",
muxedAccount.med25519().id,
KeyUtils::toStrKey(toAccountID(muxedAccount)));
default:
// this would be a bug
abort();
}
}

template <typename T>
void
dumpstream(XDRInputFileStream& in, bool json)
Expand Down
3 changes: 2 additions & 1 deletion src/overlay/StellarXDR.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
namespace stellar
{

std::string xdr_printer(const PublicKey& pk);
std::string xdr_printer(PublicKey const& pk);
std::string xdr_printer(MuxedAccount const& ma);
}