Skip to content

Commit 9837f53

Browse files
committed
[Bug] Fix CMasternodeConfig::read
rebase from upstream. Windows doesn't initialize CService properly during startup before the masternode.conf file is read.
1 parent 76c01a5 commit 9837f53

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/masternodeconfig.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
// Distributed under the MIT/X11 software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6-
// clang-format off
7-
#include "net.h"
6+
#include "netbase.h"
87
#include "masternodeconfig.h"
98
#include "util.h"
109
#include "ui_interface.h"
1110
#include <base58.h>
12-
// clang-format on
1311

1412
CMasternodeConfig masternodeConfig;
1513

@@ -60,15 +58,25 @@ bool CMasternodeConfig::read(std::string& strErr)
6058
}
6159
}
6260

61+
int port = 0;
62+
std::string hostname = "";
63+
SplitHostPort(ip, port, hostname);
64+
if(port == 0 || hostname == "") {
65+
strErr = _("Failed to parse host:port string") + "\n"+
66+
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"";
67+
streamConfig.close();
68+
return false;
69+
}
70+
6371
if (Params().NetworkID() == CBaseChainParams::MAIN) {
64-
if (CService(ip).GetPort() != 51472) {
72+
if (port != 51472) {
6573
strErr = _("Invalid port detected in masternode.conf") + "\n" +
6674
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" +
6775
_("(must be 51472 for mainnet)");
6876
streamConfig.close();
6977
return false;
7078
}
71-
} else if (CService(ip).GetPort() == 51472) {
79+
} else if (port == 51472) {
7280
strErr = _("Invalid port detected in masternode.conf") + "\n" +
7381
strprintf(_("Line: %d"), linenumber) + "\n\"" + line + "\"" + "\n" +
7482
_("(51472 could be used only on mainnet)");

0 commit comments

Comments
 (0)