This commit is contained in:
XfedeX 2023-01-19 23:01:43 +01:00
parent 5f098e5be3
commit 9035375fca

View file

@ -1394,33 +1394,35 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
bool isSignatureValid = true; bool isSignatureValid = true;
// Miner Block Header Signing // Miner Block Header Signing
if (hf_version >= BLOCK_HEADER_MINER_SIG) if (hf_version >= BLOCK_HEADER_MINER_SIG) {
{
// sanity checks // sanity checks
if (b.miner_tx.vout.size() != 1) if (b.vote > 2) {
{
MWARNING("Only 1 output in miner transaction allowed");
return false;
}
if (b.miner_tx.vout[0].target.type() != typeid(txout_to_key))
{
MWARNING("Wrong txout type");
return false;
}
if (b.vote > 2)
{
MWARNING("Vote integer must be either 0, 1, or 2"); MWARNING("Vote integer must be either 0, 1, or 2");
return false; return false;
} }
if (b.miner_tx.vout.size() != 1) {
if (hf_version < OPTIONAL_BLOCK_HEADER_MINER_SIG) {
MWARNING("Only 1 output in miner transaction allowed");
return false;
}
isSignatureValid = false;
} else {
if (b.miner_tx.vout[0].target.type() != typeid(txout_to_key)) {
if (hf_version < OPTIONAL_BLOCK_HEADER_MINER_SIG) {
MWARNING("Wrong txout type");
return false;
}
isSignatureValid = false;
} else {
// keccak hash block header data and check miner signature // keccak hash block header data and check miner signature
// if signature is invalid, reject block // if signature is invalid, reject block
crypto::hash sig_data = get_sig_data(b); crypto::hash sig_data = get_sig_data(b);
crypto::signature signature = b.signature; crypto::signature signature = b.signature;
crypto::public_key eph_pub_key = boost::get<txout_to_key>(b.miner_tx.vout[0].target).key; crypto::public_key eph_pub_key =
if (!crypto::check_signature(sig_data, eph_pub_key, signature)) boost::get<txout_to_key>(b.miner_tx.vout[0].target).key;
{ if (!crypto::check_signature(sig_data, eph_pub_key, signature)) {
if (hf_version < OPTIONAL_BLOCK_HEADER_MINER_SIG) if (hf_version < OPTIONAL_BLOCK_HEADER_MINER_SIG) {
{
MWARNING("Miner signature is invalid"); MWARNING("Miner signature is invalid");
return false; return false;
} }
@ -1430,6 +1432,8 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
LOG_PRINT_L1("Vote: " << b.vote); LOG_PRINT_L1("Vote: " << b.vote);
} }
} }
}
}
LOG_PRINT_L3("Blockchain::" << __func__); LOG_PRINT_L3("Blockchain::" << __func__);
CHECK_AND_ASSERT_MES(b.miner_tx.vin.size() == 1, false, "coinbase transaction in the block has no inputs"); CHECK_AND_ASSERT_MES(b.miner_tx.vin.size() == 1, false, "coinbase transaction in the block has no inputs");