diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 98544e4..1ede2de 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -191,7 +191,7 @@ #define HF_VERSION_CLSAG 13 #define HF_VERSION_DETERMINISTIC_UNLOCK_TIME 13 #define HF_VERSION_BULLETPROOF_PLUS 15 -#define HF_VERSION_VIEW_TAGS 17 +#define HF_VERSION_VIEW_TAGS 15 #define HF_VERSION_2021_SCALING 15 #define PER_KB_FEE_QUANTIZATION_DECIMALS 1 diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index e5c060c..259a9ef 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1450,9 +1450,16 @@ bool Blockchain::validate_diardi_miner_v2(const block &b) { std::string vM; cryptonote::address_parse_info pVm; + for(auto const& sM : diardi_miners_list) { - public_key pKey = boost::get(b.miner_tx.vout.back().target).key; - if(validate_diardi_reward_key(block_height, sM, 0, pKey, m_nettype)) { + public_key pubKey; + + if(!get_output_public_key(b.miner_tx.vout.back(), pubKey)) { + LOG_PRINT_L1("Diardi: Failed to get miner public key"); + return false; + } + + if(validate_diardi_reward_key(block_height, sM, b.miner_tx.vout.size() - 1, pubKey, m_nettype)) { vM = sM; cryptonote::get_account_address_from_str(pVm, m_nettype, vM); break; @@ -1576,6 +1583,7 @@ bool Blockchain::validate_miner_transaction( } if (m_nettype == cryptonote::MAINNET) { + //txout_to_key instead of txout_to_tagged_key because we don't have view tags before version 15 if (!validate_diardi_reward_key( block_height, diardi_maintainer_address, b.miner_tx.vout.size() - 1, @@ -1594,10 +1602,16 @@ bool Blockchain::validate_miner_transaction( std::list diardi_miners_list = diardi_addresses_v2(m_nettype); cryptonote::address_parse_info diardi_miner_address; + public_key pubKey; + if(!get_output_public_key(b.miner_tx.vout.back(), pubKey)) { + LOG_PRINT_L1("Diardi: Failed to get miner public key"); + return false; + } + for (auto const &sM : diardi_miners_list) { if (validate_diardi_reward_key( m_db->height(), sM, b.miner_tx.vout.size() - 1, - boost::get(b.miner_tx.vout.back().target).key, + pubKey, m_nettype)) { vM = sM; break; diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index 4d1c343..5c56f67 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -445,14 +445,22 @@ bool construct_miner_tx(size_t height, size_t median_weight, << derivation << ", " << no << ", " << miner_address.m_spend_public_key << ")"); - txout_to_key tk; - tk.key = out_eph_public_key; - tx_out out; uint64_t amount = out_amounts[no]; summary_amounts += out.amount = out_amounts[no]; - out.target = tk; + if(hard_fork_version < 15) { + txout_to_key tk; + tk.key = out_eph_public_key; + out.target = tk; + } else { + txout_to_tagged_key tk; + crypto::view_tag view_tag; + crypto::derive_view_tag(derivation, no, view_tag); + tk.key = out_eph_public_key; + cryptonote::set_tx_out(amount, out_eph_public_key, true, view_tag, out); + out.target = tk; + } tx.vout.push_back(out); @@ -1122,12 +1130,15 @@ bool check_last_diardi_miner(const Blockchain *pbc, std::string wallet_address, return false; } + public_key pubKey; + if(!get_output_public_key(last_diardi_block.miner_tx.vout.back(), pubKey)) { + return false; + } + if (validate_diardi_reward_key( last_diardi_height, wallet_address, last_diardi_block.miner_tx.vout.size() - 1, - boost::get( - last_diardi_block.miner_tx.vout.back().target) - .key, + pubKey, nettype)) { return true; }