From 3fd089d42570cd630e1854f8c9dc024b2bb22cb7 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 2 May 2014 00:46:33 +0100 Subject: [PATCH] Add API for getting address from secret. --- libqethereum/QEthereum.cpp | 5 +++++ libqethereum/QEthereum.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/libqethereum/QEthereum.cpp b/libqethereum/QEthereum.cpp index 1d2b96f58..4de1a89a1 100644 --- a/libqethereum/QEthereum.cpp +++ b/libqethereum/QEthereum.cpp @@ -208,6 +208,11 @@ QString padded(QString const& _s, unsigned _l, unsigned _r) //"0xff".bin().unbin() +QString QEthereum::secretToAddress(QString _s) const +{ + return toQJS(KeyPair(toSecret(_s)).address()); +} + QString padded(QString const& _s, unsigned _l) { if (_s.startsWith("0x") || !_s.contains(QRegExp("[^0-9]"))) diff --git a/libqethereum/QEthereum.h b/libqethereum/QEthereum.h index 4a00e1977..bc0e90467 100644 --- a/libqethereum/QEthereum.h +++ b/libqethereum/QEthereum.h @@ -366,6 +366,8 @@ public: Q_INVOKABLE QString ethTest() const { return "Hello world!"; } Q_INVOKABLE QEthereum* self() { return this; } + Q_INVOKABLE QString secretToAddress(QString _s) const; + Q_INVOKABLE QString pad(QString _s, unsigned _l) const { return padded(_s, _l); } Q_INVOKABLE QString pad(QString _s, unsigned _l, unsigned _r) const { return padded(_s, _l, _r); } Q_INVOKABLE QString unpad(QString _s) const { return unpadded(_s); }