fixed communication issue with tx version relay

This commit is contained in:
Matt Hess
2025-11-16 21:01:21 +00:00
parent 595d9560a7
commit 735eb6737f
7 changed files with 37 additions and 12 deletions
+29 -4
View File
@@ -2483,6 +2483,11 @@ bool P2PServer::P2PClient::on_handshake_challenge(const uint8_t* buf)
uint64_t peer_id;
memcpy(&peer_id, buf + CHALLENGE_SIZE, sizeof(uint64_t));
LOGINFO(0, "DEBUG: Received handshake from " << static_cast<const char*>(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<const char*>(m_addrString));
return false;
@@ -3184,12 +3189,33 @@ 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)) {
uint64_t unlock_height;
const uint8_t* p = buf + data.header_size + 1;
if (!readVarint(p, buf + header_and_miner_tx_size, unlock_height)) {
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;
if (!readVarint(p, buf + header_and_miner_tx_size, num_inputs) || (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;
if (!readVarint(p, buf + header_and_miner_tx_size, height)) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: height not found in txin_gen");
return false;
}
p2pool* pool = server->m_pool;
// Ignore blocks which already unlocked
@@ -3209,7 +3235,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;