mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 00:37:43 +00:00
cryptonote: fix calculating coinbase tx hash
Also set error flag on exception when handling new txes to keep tests working
This commit is contained in:
parent
f5d7652f73
commit
e9519e9876
2 changed files with 8 additions and 10 deletions
|
@ -987,15 +987,11 @@ namespace cryptonote
|
||||||
{
|
{
|
||||||
if (t.version == 1)
|
if (t.version == 1)
|
||||||
return false;
|
return false;
|
||||||
static const crypto::hash empty_hash = { (char)0x70, (char)0xa4, (char)0x85, (char)0x5d, (char)0x04, (char)0xd8, (char)0xfa, (char)0x7b, (char)0x3b, (char)0x27, (char)0x82, (char)0xca, (char)0x53, (char)0xb6, (char)0x00, (char)0xe5, (char)0xc0, (char)0x03, (char)0xc7, (char)0xdc, (char)0xb2, (char)0x7d, (char)0x7e, (char)0x92, (char)0x3c, (char)0x23, (char)0xf7, (char)0x86, (char)0x01, (char)0x46, (char)0xd2, (char)0xc5 };
|
|
||||||
const unsigned int unprunable_size = t.unprunable_size;
|
const unsigned int unprunable_size = t.unprunable_size;
|
||||||
if (blob && unprunable_size)
|
if (blob && unprunable_size)
|
||||||
{
|
{
|
||||||
CHECK_AND_ASSERT_MES(unprunable_size <= blob->size(), false, "Inconsistent transaction unprunable and blob sizes");
|
CHECK_AND_ASSERT_MES(unprunable_size <= blob->size(), false, "Inconsistent transaction unprunable and blob sizes");
|
||||||
if (blob->size() - unprunable_size == 0)
|
cryptonote::get_blob_hash(epee::span<const char>(blob->data() + unprunable_size, blob->size() - unprunable_size), res);
|
||||||
res = empty_hash;
|
|
||||||
else
|
|
||||||
cryptonote::get_blob_hash(epee::span<const char>(blob->data() + unprunable_size, blob->size() - unprunable_size), res);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1007,10 +1003,7 @@ namespace cryptonote
|
||||||
const size_t mixin = t.vin.empty() ? 0 : t.vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(t.vin[0]).key_offsets.size() - 1 : 0;
|
const size_t mixin = t.vin.empty() ? 0 : t.vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(t.vin[0]).key_offsets.size() - 1 : 0;
|
||||||
bool r = tt.rct_signatures.p.serialize_rctsig_prunable(ba, t.rct_signatures.type, inputs, outputs, mixin);
|
bool r = tt.rct_signatures.p.serialize_rctsig_prunable(ba, t.rct_signatures.type, inputs, outputs, mixin);
|
||||||
CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures prunable");
|
CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures prunable");
|
||||||
if (ss.str().empty())
|
cryptonote::get_blob_hash(ss.str(), res);
|
||||||
res = empty_hash;
|
|
||||||
else
|
|
||||||
cryptonote::get_blob_hash(ss.str(), res);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1047,7 +1040,10 @@ namespace cryptonote
|
||||||
}
|
}
|
||||||
|
|
||||||
// prunable rct
|
// prunable rct
|
||||||
hashes[2] = pruned_data_hash;
|
if (t.rct_signatures.type == rct::RCTTypeNull)
|
||||||
|
hashes[2] = crypto::null_hash;
|
||||||
|
else
|
||||||
|
hashes[2] = pruned_data_hash;
|
||||||
|
|
||||||
// the tx hash is the hash of the 3 hashes
|
// the tx hash is the hash of the 3 hashes
|
||||||
crypto::hash res = cn_fast_hash(hashes, sizeof(hashes));
|
crypto::hash res = cn_fast_hash(hashes, sizeof(hashes));
|
||||||
|
|
|
@ -921,6 +921,7 @@ namespace cryptonote
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
MERROR_VER("Exception in handle_incoming_tx_pre: " << e.what());
|
MERROR_VER("Exception in handle_incoming_tx_pre: " << e.what());
|
||||||
|
tvc[i].m_verifivation_failed = true;
|
||||||
results[i].res = false;
|
results[i].res = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -951,6 +952,7 @@ namespace cryptonote
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
MERROR_VER("Exception in handle_incoming_tx_post: " << e.what());
|
MERROR_VER("Exception in handle_incoming_tx_post: " << e.what());
|
||||||
|
tvc[i].m_verifivation_failed = true;
|
||||||
results[i].res = false;
|
results[i].res = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue