Skip to content

Commit

Permalink
view tags: add back in with fixes for diardi blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
hayzamjs committed Aug 7, 2023
1 parent c7c3249 commit 830704c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/cryptonote_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions src/cryptonote_core/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<txout_to_key>(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;
Expand Down Expand Up @@ -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,
Expand All @@ -1594,10 +1602,16 @@ bool Blockchain::validate_miner_transaction(
std::list<std::string> 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<txout_to_key>(b.miner_tx.vout.back().target).key,
pubKey,
m_nettype)) {
vM = sM;
break;
Expand Down
25 changes: 18 additions & 7 deletions src/cryptonote_core/cryptonote_tx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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<txout_to_key>(
last_diardi_block.miner_tx.vout.back().target)
.key,
pubKey,
nettype)) {
return true;
}
Expand Down

0 comments on commit 830704c

Please sign in to comment.