Skip to content

Commit 2cd0670

Browse files
committed
Startup: move masternode port validation inside initMasternode.
Do not return an error if a different peer port is used for tor addresses. The peer is behind a hidden service which has the port fixed to the default port.
1 parent 9d0923f commit 2cd0670

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/activemasternode.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ OperationResult initMasternode(const std::string& _strMasterNodePrivKey, const s
5353
return errorOut(strprintf(_("Invalid -masternodeaddr address: %s"), strMasterNodeAddr));
5454
}
5555

56+
// Peer port needs to match the masternode public one for IPv4 and IPv6.
57+
// Onion can run in other ports because those are behind a hidden service which has the public port fixed to the default port.
58+
if (nPort != GetListenPort() && !addrTest.IsTor() && !params.IsRegTestNet()) {
59+
return errorOut(strprintf(_("Invalid -masternodeaddr port %d, isn't the same as the peer port %d"),
60+
nPort, GetListenPort()));
61+
}
62+
5663
CKey key;
5764
CPubKey pubkey;
5865
if (!CMessageSigner::GetKeysFromSecret(_strMasterNodePrivKey, key, pubkey)) {

src/init.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,11 +1035,6 @@ bool AppInit2()
10351035
// Exit early if -masternode=1 and -listen=0
10361036
if (gArgs.GetBoolArg("-masternode", DEFAULT_MASTERNODE) && !gArgs.GetBoolArg("-listen", DEFAULT_LISTEN))
10371037
return UIError(_("Error: -listen must be true if -masternode is set."));
1038-
// Exit early if -masternode=1 and -port is not the default port
1039-
if (gArgs.GetBoolArg("-masternode", DEFAULT_MASTERNODE) && (GetListenPort() != Params().GetDefaultPort() && !Params().IsRegTestNet()))
1040-
return UIError(strprintf(_("Error: Invalid port %d for running a masternode."), GetListenPort()) + "\n\n" +
1041-
strprintf(_("Masternodes are required to run on port %d for %s-net"), Params().GetDefaultPort(), Params().NetworkIDString()));
1042-
10431038
if (gArgs.GetBoolArg("-benchmark", false))
10441039
UIWarning(_("Warning: Unsupported argument -benchmark ignored, use -debug=bench."));
10451040

0 commit comments

Comments
 (0)