diff --git a/src/block_template.cpp b/src/block_template.cpp index 360ca53..ddb6c1d 100644 --- a/src/block_template.cpp +++ b/src/block_template.cpp @@ -938,7 +938,7 @@ int BlockTemplate::create_miner_tx(const MinerData& data, const std::vector(m_addrString) + << " peer_id=" << peer_id + << " my_id=" << server->get_peerId(false) + << " my_tor_id=" << server->get_peerId(true)); + if ((peer_id == server->get_peerId(false)) || (peer_id == server->get_peerId(true))) { LOGWARN(5, "tried to connect to self at " << static_cast(m_addrString)); return false; @@ -3188,11 +3193,35 @@ bool P2PServer::P2PClient::on_monero_block_broadcast(const uint8_t* buf, uint32_ return false; } - uint64_t unlock_height; - if (!readVarint(buf + data.header_size + 1, buf + header_and_miner_tx_size, unlock_height)) { - LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: unlock_height not found"); - return false; - } + uint64_t unlock_height; + const uint8_t* p = buf + data.header_size + 1; + p = readVarint(p, buf + header_and_miner_tx_size, unlock_height); // Capture return value! + if (!p) { + LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: unlock_height not found"); + return false; + } + + // Parse actual height from txin_gen (Salvium uses literal 60 for unlock_time) + uint64_t num_inputs; + p = readVarint(p, buf + header_and_miner_tx_size, num_inputs); // Capture return value! + if (!p || (num_inputs != 1)) { + LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: num_inputs invalid"); + return false; + } + + // Check input type (should be 0xff for txin_gen) + if ((p >= buf + header_and_miner_tx_size) || (*p != 0xff)) { + LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: txin_gen not found"); + return false; + } + ++p; + + uint64_t height; + p = readVarint(p, buf + header_and_miner_tx_size, height); // Capture return value! + if (!p) { + LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: height not found in txin_gen"); + return false; + } p2pool* pool = server->m_pool; @@ -3213,7 +3242,6 @@ bool P2PServer::P2PClient::on_monero_block_broadcast(const uint8_t* buf, uint32_ return true; } - const uint64_t height = unlock_height - MINER_REWARD_UNLOCK_TIME; LOGINFO(6, "on_monero_block_broadcast: height = " << height); difficulty_type diff; diff --git a/src/pool_block.cpp b/src/pool_block.cpp index bf384cc..9d37b06 100644 --- a/src/pool_block.cpp +++ b/src/pool_block.cpp @@ -160,7 +160,7 @@ std::vector PoolBlock::serialize_mainchain_data(size_t* header_size, si // Miner tx data.push_back(TX_VERSION); - writeVarint(m_txinGenHeight + MINER_REWARD_UNLOCK_TIME, data); + writeVarint(MINER_REWARD_UNLOCK_TIME, data); data.push_back(1); data.push_back(TXIN_GEN); writeVarint(m_txinGenHeight, data); diff --git a/src/pool_block_parser.inl b/src/pool_block_parser.inl index e2ee4e3..4a2cfc0 100644 --- a/src/pool_block_parser.inl +++ b/src/pool_block_parser.inl @@ -88,7 +88,7 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si READ_VARINT(m_txinGenHeight); if (m_majorVersion != sidechain.network_major_version(m_txinGenHeight)) return __LINE__; - if (unlock_height != m_txinGenHeight + MINER_REWARD_UNLOCK_TIME) return __LINE__; + if (unlock_height != MINER_REWARD_UNLOCK_TIME) return __LINE__; std::vector outputs_blob; const int outputs_offset = static_cast(data - data_begin); diff --git a/src/side_chain.cpp b/src/side_chain.cpp index cc684fe..0322b82 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -55,9 +55,9 @@ static constexpr uint64_t MONERO_BLOCK_TIME = 120; namespace p2pool { -static constexpr uint8_t default_consensus_id[HASH_SIZE] = { 34,175,126,231,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24 }; -static constexpr uint8_t mini_consensus_id[HASH_SIZE] = { 57,130,201,26,149,174,199,250,66,80,189,18,108,216,194,220,136,23,63,24,64,113,221,44,219,86,39,163,53,24,126,196 }; -static constexpr uint8_t nano_consensus_id[HASH_SIZE] = { 171,248,206,148,210,226,114,99,250,145,221,96,13,216,23,63,104,53,129,168,244,80,141,138,157,250,50,54,37,189,5,89 }; +static constexpr uint8_t default_consensus_id[HASH_SIZE] = { 83,65,76,86,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24 }; +static constexpr uint8_t mini_consensus_id[HASH_SIZE] = { 83,65,76,77,149,174,199,250,66,80,189,18,108,216,194,220,136,23,63,24,64,113,221,44,219,86,39,163,53,24,126,196 }; +static constexpr uint8_t nano_consensus_id[HASH_SIZE] = { 83,65,76,78,210,226,114,99,250,145,221,96,13,216,23,63,104,53,129,168,244,80,141,138,157,250,50,54,37,189,5,89 }; NetworkType SideChain::s_networkType = NetworkType::Invalid; diff --git a/src/zmq_reader.cpp b/src/zmq_reader.cpp index 330e8c0..63402c8 100644 --- a/src/zmq_reader.cpp +++ b/src/zmq_reader.cpp @@ -336,7 +336,7 @@ static std::vector construct_monero_block_blob(rapidjson::Value* value, blob.push_back(1); blob.push_back(TXIN_GEN); - writeVarint(unlock_height - MINER_REWARD_UNLOCK_TIME, blob); + writeVarint(MINER_REWARD_UNLOCK_TIME, blob); auto arr = outputs->value.GetArray();