From 87d07515a8570caaad0eeda7e74152e67ab7db45 Mon Sep 17 00:00:00 2001 From: "moneromooo.monero" Date: Thu, 24 Nov 2016 11:14:46 +0000 Subject: [PATCH] libwalletqt: add a few daemon read access routines --- main.qml | 2 ++ src/libwalletqt/WalletManager.cpp | 30 ++++++++++++++++++++++++++++++ src/libwalletqt/WalletManager.h | 8 ++++++++ 3 files changed, 40 insertions(+) diff --git a/main.qml b/main.qml index 5f28e415..3f4e4aea 100644 --- a/main.qml +++ b/main.qml @@ -176,6 +176,8 @@ ApplicationWindow { } + walletManager.setDaemonAddress(persistentSettings.daemon_address) + // wallet already opened with wizard, we just need to initialize it if (typeof wizard.settings['wallet'] !== 'undefined') { console.log("using wizard wallet") diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index de800776..a5f4818a 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -174,6 +174,36 @@ QString WalletManager::checkPayment(const QString &address, const QString &txid, return QString::fromStdString(result); } +void WalletManager::setDaemonAddress(const QString &address) +{ + m_pimpl->setDaemonAddress(address.toStdString()); +} + +bool WalletManager::connected() const +{ + return m_pimpl->connected(); +} + +quint64 WalletManager::networkDifficulty() const +{ + return m_pimpl->networkDifficulty(); +} + +quint64 WalletManager::blockchainHeight() const +{ + return m_pimpl->blockchainHeight(); +} + +quint64 WalletManager::blockchainTargetHeight() const +{ + return m_pimpl->blockchainTargetHeight(); +} + +double WalletManager::miningHashRate() const +{ + return m_pimpl->miningHashRate(); +} + void WalletManager::setLogLevel(int logLevel) { Bitmonero::WalletManagerFactory::setLogLevel(logLevel); diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index 8e63050a..687008e9 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -13,6 +13,7 @@ namespace Bitmonero { class WalletManager : public QObject { Q_OBJECT + Q_PROPERTY(bool connected READ connected) public: enum LogLevel { @@ -95,6 +96,13 @@ public: Q_INVOKABLE QString checkPayment(const QString &address, const QString &txid, const QString &txkey, const QString &daemon_address) const; + Q_INVOKABLE void setDaemonAddress(const QString &address); + Q_INVOKABLE bool connected() const; + Q_INVOKABLE quint64 networkDifficulty() const; + Q_INVOKABLE quint64 blockchainHeight() const; + Q_INVOKABLE quint64 blockchainTargetHeight() const; + Q_INVOKABLE double miningHashRate() const; + // QML missing such functionality, implementing these helpers here Q_INVOKABLE QString urlToLocalPath(const QUrl &url) const; Q_INVOKABLE QUrl localPathToUrl(const QString &path) const;