Skip to content

Commit

Permalink
Make print-xdr display account IDs properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidenori authored and Hidenori committed Jun 5, 2020
1 parent c4d29c3 commit 9128f7d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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);
}

5 comments on commit 9128f7d

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from MonsieurNicolas
at hidenori-shinohara@9128f7d

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging hidenori-shinohara/stellar-core/printxdr = 9128f7d into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hidenori-shinohara/stellar-core/printxdr = 9128f7d merged ok, testing candidate = 9cecd4e

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 9cecd4e

Please sign in to comment.