From f05f0b73c3db6a4841b8d18e5fdb0757c838366a Mon Sep 17 00:00:00 2001 From: Jaquee Date: Thu, 23 Mar 2017 22:50:57 +0100 Subject: [PATCH 1/2] add WalletManager::useForkRules() --- src/libwalletqt/WalletManager.cpp | 10 ++++++++++ src/libwalletqt/WalletManager.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index ad77ad48..95fa0b77 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -338,6 +338,16 @@ QString WalletManager::checkUpdates(const QString &software, const QString &subd return QString::fromStdString(std::get<1>(result) + "|" + std::get<2>(result) + "|" + std::get<3>(result) + "|" + std::get<4>(result)); } +bool WalletManager::useForkRules(quint8 required_version) const +{ + quint64 earliest_height; + quint8 version; + m_pimpl->hardForkInfo(version, earliest_height); + return version >= required_version; +} + + + WalletManager::WalletManager(QObject *parent) : QObject(parent) { m_pimpl = Monero::WalletManagerFactory::getWalletManager(); diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index 01afc064..592c7920 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -136,6 +136,8 @@ public: Q_INVOKABLE bool saveQrCode(const QString &, const QString &) const; Q_INVOKABLE QString checkUpdates(const QString &software, const QString &subdir) const; + Q_INVOKABLE bool useForkRules(quint8 version) const; + signals: void walletOpened(Wallet * wallet); From 9c4c34d502e7179964061c6af72470e37f9257af Mon Sep 17 00:00:00 2001 From: Jaquee Date: Thu, 23 Mar 2017 22:54:35 +0100 Subject: [PATCH 2/2] Use new fee multipliers after v5 fork requires #1915 --- main.qml | 3 +++ pages/Transfer.qml | 25 ++++++++++++++++++++++++- src/libwalletqt/Wallet.cpp | 5 +++++ src/libwalletqt/Wallet.h | 3 +++ src/libwalletqt/WalletManager.cpp | 10 ---------- src/libwalletqt/WalletManager.h | 2 -- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/main.qml b/main.qml index 3e3faf2d..267461d1 100644 --- a/main.qml +++ b/main.qml @@ -286,6 +286,9 @@ ApplicationWindow { leftPanel.networkStatus.connected = status leftPanel.progressBar.visible = (status === Wallet.ConnectionStatus_Connected) && !daemonSynced + // Update fee multiplier dropdown on transfer page + middlePanel.transferView.updatePriorityDropdown(); + // If wallet isnt connected and no daemon is running - Ask if(!walletInitialized && status === Wallet.ConnectionStatus_Disconnected && !daemonManager.running(persistentSettings.testnet)){ daemonManagerDialog.open(); diff --git a/pages/Transfer.qml b/pages/Transfer.qml index ef3a1f3b..d84f26d5 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -195,6 +195,17 @@ Rectangle { ListElement { column1: qsTr("High (x166 fee)") ; column2: ""; priority: PendingTransaction.Priority_High } } + // Priorites after v5 + ListModel { + id: priorityModelV5 + + ListElement { column1: qsTr("Low (x1 fee)") ; column2: ""; priority: 1} + ListElement { column1: qsTr("Default (x4 fee)") ; column2: ""; priority: 2 } + ListElement { column1: qsTr("Medium (x20 fee)") ; column2: ""; priority: 3 } + ListElement { column1: qsTr("High (x166 fee)") ; column2: ""; priority: 4 } + + } + StandardDropdown { id: priorityDropdown anchors.top: transactionPriority.bottom @@ -206,7 +217,6 @@ Rectangle { shadowPressedColor: "#B32D00" releasedColor: "#FF6C3C" pressedColor: "#FF4304" - dataModel: priorityModel z: 1 } @@ -700,6 +710,19 @@ Rectangle { console.log("transfer page loaded") updateStatus(); updateMixin(); + updatePriorityDropdown() + } + + function updatePriorityDropdown() { + // Use new fee multipliers after v5 fork + if (typeof currentWallet != "undefined" && currentWallet.useForkRules(5)) { + priorityDropdown.dataModel = priorityModelV5; + priorityDropdown.currentIndex = 1 + } else { + priorityDropdown.dataModel = priorityModel; + priorityDropdown.currentIndex = 0 + } + } //TODO: Add daemon sync status diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 96990050..6f397766 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -587,6 +587,11 @@ bool Wallet::rescanSpent() return m_walletImpl->rescanSpent(); } +bool Wallet::useForkRules(quint8 required_version, quint64 earlyBlocks) const +{ + return m_walletImpl->useForkRules(required_version,earlyBlocks); +} + Wallet::Wallet(Monero::Wallet *w, QObject *parent) : QObject(parent) , m_walletImpl(w) diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index e947ecd0..187df16f 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -228,6 +228,9 @@ public: // Rescan spent outputs Q_INVOKABLE bool rescanSpent(); + // check if fork rules should be used + Q_INVOKABLE bool useForkRules(quint8 version, quint64 earlyBlocks) const; + // TODO: setListenter() when it implemented in API signals: // emitted on every event happened with wallet diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index 95fa0b77..ad77ad48 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -338,16 +338,6 @@ QString WalletManager::checkUpdates(const QString &software, const QString &subd return QString::fromStdString(std::get<1>(result) + "|" + std::get<2>(result) + "|" + std::get<3>(result) + "|" + std::get<4>(result)); } -bool WalletManager::useForkRules(quint8 required_version) const -{ - quint64 earliest_height; - quint8 version; - m_pimpl->hardForkInfo(version, earliest_height); - return version >= required_version; -} - - - WalletManager::WalletManager(QObject *parent) : QObject(parent) { m_pimpl = Monero::WalletManagerFactory::getWalletManager(); diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index 592c7920..01afc064 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -136,8 +136,6 @@ public: Q_INVOKABLE bool saveQrCode(const QString &, const QString &) const; Q_INVOKABLE QString checkUpdates(const QString &software, const QString &subdir) const; - Q_INVOKABLE bool useForkRules(quint8 version) const; - signals: void walletOpened(Wallet * wallet);