@@ -918,39 +918,41 @@ static bool CheckService(const ProTx& proTx, TxValidationState& state)
918918}
919919
920920template <typename ProTx>
921- static bool CheckPlatformFields (const ProTx& proTx, TxValidationState& state)
921+ static bool CheckPlatformFields (const ProTx& proTx, bool is_extended_addr, TxValidationState& state)
922922{
923923 if (proTx.platformNodeID .IsNull ()) {
924924 return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-platform-nodeid" );
925925 }
926926
927- // TODO: use real args here
928- static int mainnetPlatformP2PPort = CreateChainParams (ArgsManager{}, CBaseChainParams::MAIN)->GetDefaultPlatformP2PPort ();
929- if (Params ().NetworkIDString () == CBaseChainParams::MAIN) {
930- if (proTx.platformP2PPort != mainnetPlatformP2PPort) {
927+ if (is_extended_addr) {
928+ // platformHTTPPort and platformP2PPort have been subsumed by netInfo. They should always be zero.
929+ if (proTx.platformP2PPort != 0 ) {
931930 return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-platform-p2p-port" );
932931 }
932+ if (proTx.platformHTTPPort != 0 ) {
933+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-platform-http-port" );
934+ }
935+ return true ;
933936 }
934937
935- // TODO: use real args here
936- static int mainnetPlatformHTTPPort = CreateChainParams (ArgsManager{}, CBaseChainParams::MAIN)->GetDefaultPlatformHTTPPort ();
937- if (Params ().NetworkIDString () == CBaseChainParams::MAIN) {
938- if (proTx.platformHTTPPort != mainnetPlatformHTTPPort) {
938+ if (::IsNodeOnMainnet ()) {
939+ if (proTx.platformP2PPort != ::MainParams ().GetDefaultPlatformP2PPort ()) {
940+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-platform-p2p-port" );
941+ }
942+ if (proTx.platformHTTPPort != ::MainParams ().GetDefaultPlatformHTTPPort ()) {
939943 return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-platform-http-port" );
940944 }
941945 }
942-
943- // TODO: use real args here
944- static int mainnetDefaultP2PPort = CreateChainParams (ArgsManager{}, CBaseChainParams::MAIN)->GetDefaultPort ();
945- if (proTx.platformP2PPort == mainnetDefaultP2PPort) {
946+ if (proTx.platformP2PPort == ::MainParams ().GetDefaultPort ()) {
946947 return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-platform-p2p-port" );
947948 }
948- if (proTx.platformHTTPPort == mainnetDefaultP2PPort ) {
949+ if (proTx.platformHTTPPort == :: MainParams (). GetDefaultPort () ) {
949950 return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-platform-http-port" );
950951 }
951952
952- if (proTx.platformP2PPort == proTx.platformHTTPPort || proTx.platformP2PPort == proTx.netInfo ->GetPrimary ().GetPort () ||
953- proTx.platformHTTPPort == proTx.netInfo ->GetPrimary ().GetPort ()) {
953+ const uint16_t core_port{proTx.netInfo ->GetPrimary ().GetPort ()};
954+ if (proTx.platformP2PPort == proTx.platformHTTPPort || proTx.platformP2PPort == core_port ||
955+ proTx.platformHTTPPort == core_port) {
954956 return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-platform-dup-ports" );
955957 }
956958
@@ -1062,7 +1064,7 @@ bool CheckProRegTx(CDeterministicMNManager& dmnman, const CTransaction& tx, gsl:
10621064 }
10631065
10641066 if (opt_ptx->nType == MnType::Evo) {
1065- if (!CheckPlatformFields (*opt_ptx, state)) {
1067+ if (!CheckPlatformFields (*opt_ptx, opt_ptx-> nVersion >= ProTxVersion::ExtAddr, state)) {
10661068 return false ;
10671069 }
10681070 }
@@ -1181,7 +1183,7 @@ bool CheckProUpServTx(CDeterministicMNManager& dmnman, const CTransaction& tx, g
11811183 }
11821184
11831185 if (opt_ptx->nType == MnType::Evo) {
1184- if (!CheckPlatformFields (*opt_ptx, state)) {
1186+ if (!CheckPlatformFields (*opt_ptx, opt_ptx-> nVersion >= ProTxVersion::ExtAddr, state)) {
11851187 return false ;
11861188 }
11871189 }
0 commit comments