Merge pull request #1015

da32161 Use wallet2_api isAddressLocal utils method for isDaemonLocal check
This commit is contained in:
luigi1111 2018-03-13 16:14:08 -04:00
commit 689123fa95
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
4 changed files with 10 additions and 23 deletions

View file

@ -326,7 +326,7 @@ ApplicationWindow {
middlePanel.transferView.updatePriorityDropdown();
// If wallet isnt connected and no daemon is running - Ask
if(!isMobile && isDaemonLocal() && !walletInitialized && status === Wallet.ConnectionStatus_Disconnected && !daemonManager.running(persistentSettings.testnet)){
if(!isMobile && walletManager.isDaemonLocal(appWindow.persistentSettings.daemon_address) && !walletInitialized && status === Wallet.ConnectionStatus_Disconnected && !daemonManager.running(persistentSettings.testnet)){
daemonManagerDialog.open();
}
// initialize transaction history once wallet is initialized first time;
@ -1692,16 +1692,6 @@ ApplicationWindow {
onTriggered: checkUpdates()
}
function isDaemonLocal() {
var daemonAddress = appWindow.persistentSettings.daemon_address
if (daemonAddress === "")
return false
var daemonHost = daemonAddress.split(":")[0]
if (daemonHost === "127.0.0.1" || daemonHost === "localhost")
return true
return false
}
function releaseFocus() {
// Workaround to release focus from textfield when scrolling (https://bugreports.qt.io/browse/QTBUG-34867)
if(isAndroid) {

View file

@ -37,15 +37,6 @@ Rectangle {
color: "#F0EEEE"
property var currentHashRate: 0
function isDaemonLocal() {
if (appWindow.currentDaemonAddress === "")
return false
var daemonHost = appWindow.currentDaemonAddress.split(":")[0]
if (daemonHost === "127.0.0.1" || daemonHost === "localhost")
return true
return false
}
/* main layout */
ColumnLayout {
id: mainLayout
@ -75,7 +66,7 @@ Rectangle {
fontSize: 18
color: "#D02020"
text: qsTr("(only available for local daemons)")
visible: !isDaemonLocal()
visible: !walletManager.isDaemonLocal(appWindow.currentDaemonAddress)
}
Text {
@ -157,7 +148,7 @@ Rectangle {
} else {
errorPopup.title = qsTr("Error starting mining") + translationManager.emptyString;
errorPopup.text = qsTr("Couldn't start mining.<br>")
if (!isDaemonLocal())
if (!walletManager.isDaemonLocal(appWindow.currentDaemonAddress))
errorPopup.text += qsTr("Mining is only available on local daemons. Run a local daemon to be able to mine.<br>")
errorPopup.icon = StandardIcon.Critical
errorPopup.open()
@ -225,7 +216,7 @@ Rectangle {
console.log("Mining page loaded");
update()
timer.running = isDaemonLocal()
timer.running = walletManager.isDaemonLocal(appWindow.currentDaemonAddress)
}
function onPageClosed() {

View file

@ -270,6 +270,11 @@ bool WalletManager::localDaemonSynced() const
return blockchainHeight() > 1 && blockchainHeight() >= blockchainTargetHeight();
}
bool WalletManager::isDaemonLocal(const QString &daemon_address) const
{
return Monero::Utils::isAddressLocal(daemon_address.toStdString());
}
QString WalletManager::resolveOpenAlias(const QString &address) const
{
bool dnssec_valid = false;

View file

@ -111,6 +111,7 @@ public:
Q_INVOKABLE quint64 blockchainTargetHeight() const;
Q_INVOKABLE double miningHashRate() const;
Q_INVOKABLE bool localDaemonSynced() const;
Q_INVOKABLE bool isDaemonLocal(const QString &daemon_address) const;
Q_INVOKABLE bool isMining() const;
Q_INVOKABLE bool startMining(const QString &address, quint32 threads, bool backgroundMining, bool ignoreBattery);