diff --git a/src/gridcoin/sidestake.cpp b/src/gridcoin/sidestake.cpp index d5d777a9bc..bee4eeeea4 100644 --- a/src/gridcoin/sidestake.cpp +++ b/src/gridcoin/sidestake.cpp @@ -414,15 +414,11 @@ void SideStakeRegistry::Revert(const ContractContext& ctx) bool SideStakeRegistry::Validate(const Contract& contract, const CTransaction& tx, int &DoS) const { - if (contract.m_version < 1) { - return true; - } - const auto payload = contract.SharePayloadAs(); - if (contract.m_version >= 3 && payload->m_version < 2) { + if (contract.m_version < 3) { DoS = 25; - error("%s: Legacy SideStake entry contract in contract v3", __func__); + error("%s: Sidestake entries only valid in contract v3 and above", __func__); return false; } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 025d6584f3..ee6581ef46 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2437,30 +2437,35 @@ UniValue addkey(const UniValue& params, bool fHelp) break; case GRC::ContractType::SIDESTAKE: { - GRC::CBitcoinAddressForStorage sidestake_address; - if (!sidestake_address.SetString(params[2].get_str())) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Address specified for the sidestake is invalid."); - } + if (block_v13_enabled) { + GRC::CBitcoinAddressForStorage sidestake_address; + if (!sidestake_address.SetString(params[2].get_str())) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Address specified for the sidestake is invalid."); + } - double allocation = 0.0; - if (!ParseDouble(params[3].get_str(), &allocation)) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid allocation specified."); - } + double allocation = 0.0; + if (!ParseDouble(params[3].get_str(), &allocation)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid allocation specified."); + } - allocation /= 100.0; + allocation /= 100.0; - if (allocation > 1.0) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Allocation specified is greater than 100.0%."); + if (allocation > 1.0) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Allocation specified is greater than 100.0%."); + } + + contract = GRC::MakeContract( + contract_version, // Contract version number (3+) + action, // Contract action + uint32_t {1}, // Contract payload version number + sidestake_address, // Sidestake address + allocation, // Sidestake allocation + GRC::SideStakeStatus::MANDATORY // sidestake status + ); + } else { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Sidestake contracts are not valid for block version less than v13."); } - contract = GRC::MakeContract( - contract_version, // Contract version number - action, // Contract action - uint32_t {1}, // Contract payload version number - sidestake_address, // Sidestake address - allocation, // Sidestake allocation - GRC::SideStakeStatus::MANDATORY // sidestake status - ); break; } case GRC::ContractType::BEACON: