mirror of
https://git.wownero.com/wownero/wownero.git
synced 2025-01-06 20:28:52 +00:00
Dynamic Unlock from HF 16
This commit is contained in:
parent
bda76b6be9
commit
1eb01bb388
@ -41,7 +41,6 @@
|
||||
#define CRYPTONOTE_MAX_TX_SIZE 1000000
|
||||
#define CRYPTONOTE_MAX_TX_PER_BLOCK 0x10000000
|
||||
#define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
|
||||
#define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 60
|
||||
#define CURRENT_TRANSACTION_VERSION 2
|
||||
#define CURRENT_BLOCK_MAJOR_VERSION 7
|
||||
#define CURRENT_BLOCK_MINOR_VERSION 7
|
||||
@ -178,6 +177,7 @@
|
||||
#define HF_VERSION_REJECT_SIGS_IN_COINBASE 15
|
||||
#define HF_VERSION_ENFORCE_MIN_AGE 15
|
||||
#define HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY 15
|
||||
#define HF_VERSION_DYNAMIC_UNLOCK 16
|
||||
|
||||
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
|
||||
|
||||
|
@ -1384,7 +1384,28 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
|
||||
return false;
|
||||
}
|
||||
MDEBUG("Miner tx hash: " << get_transaction_hash(b.miner_tx));
|
||||
CHECK_AND_ASSERT_MES(b.miner_tx.unlock_time == height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, false, "coinbase transaction transaction has the wrong unlock time=" << b.miner_tx.unlock_time << ", expected " << height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
// Dynamic unlock time from HF 16
|
||||
// To calculate unlock window, use first 3 characters of tx public key (convert to decimal), multiply by 2, plus 288
|
||||
// Unlock minimum 1 day, maximum ~1 month
|
||||
// unlock time = unlock_window + height
|
||||
if (hf_version >= HF_VERSION_DYNAMIC_UNLOCK)
|
||||
{
|
||||
crypto::public_key tx_pub_key = cryptonote::get_tx_pub_key_from_extra(b.miner_tx);
|
||||
std::string hex_str = epee::string_tools::pod_to_hex(tx_pub_key).substr(0, 3);
|
||||
uint64_t unlock_window = (std::stol(hex_str,nullptr,16) * 2) + 288;
|
||||
if (b.miner_tx.unlock_time != height + unlock_window) {
|
||||
MWARNING("Coinbase transaction has the wrong unlock time=" << b.miner_tx.unlock_time << ", expected " << height + unlock_window <<
|
||||
", unlock window based on first 3 characters of transaction public key, multiply by 2, plus 288.");
|
||||
return false;
|
||||
}
|
||||
LOG_PRINT_L1("+++++ MINER TX UNLOCK TIME INFO\n" << "Height: " << height << ", Unlock window: " << unlock_window << ", Unlock time: " << b.miner_tx.unlock_time <<
|
||||
"\nMiner TX:\t" << get_transaction_hash(b.miner_tx) << "\nTX Pub Key:\t" << tx_pub_key <<
|
||||
"\nHex: " << hex_str << ", Decimal: " << std::stol(hex_str,nullptr,16));
|
||||
} else {
|
||||
CHECK_AND_ASSERT_MES(b.miner_tx.unlock_time == height + 60, false, "coinbase transaction transaction has the wrong unlock time="
|
||||
<< b.miner_tx.unlock_time << ", expected " << height + 60);
|
||||
}
|
||||
|
||||
//check outs overflow
|
||||
//NOTE: not entirely sure this is necessary, given that this function is
|
||||
|
@ -167,7 +167,15 @@ namespace cryptonote
|
||||
tx.version = 1;
|
||||
|
||||
//lock
|
||||
tx.unlock_time = height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
|
||||
if (hard_fork_version >= HF_VERSION_DYNAMIC_UNLOCK)
|
||||
{
|
||||
crypto::public_key tx_pub_key = get_tx_pub_key_from_extra(tx);
|
||||
std::string hex_str = epee::string_tools::pod_to_hex(tx_pub_key).substr(0, 3);
|
||||
uint64_t unlock_window = (std::stol(hex_str,nullptr,16) * 2) + 288;
|
||||
tx.unlock_time = height + unlock_window;
|
||||
} else {
|
||||
tx.unlock_time = height + 60;
|
||||
}
|
||||
tx.vin.push_back(in);
|
||||
|
||||
tx.invalidate_hashes();
|
||||
|
@ -8097,7 +8097,8 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||
const uint64_t amount = td.is_rct() ? 0 : td.amount();
|
||||
std::unordered_set<uint64_t> seen_indices;
|
||||
// request more for rct in base recent (locked) coinbases are picked, since they're locked for longer
|
||||
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0);
|
||||
// unlock window max is (4095*2)+288 = 8478 (~29 days)
|
||||
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? 8478 - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0);
|
||||
size_t start = req.outputs.size();
|
||||
bool use_histogram = amount != 0 || !has_rct_distribution;
|
||||
|
||||
@ -8413,7 +8414,8 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||
for(size_t idx: selected_transfers)
|
||||
{
|
||||
const transfer_details &td = m_transfers[idx];
|
||||
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0);
|
||||
// unlock window max is (4095*2)+288 = 8478 (~29 days)
|
||||
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? 8478 - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0);
|
||||
outs.push_back(std::vector<get_outs_entry>());
|
||||
outs.back().reserve(fake_outputs_count + 1);
|
||||
const rct::key mask = td.is_rct() ? rct::commit(td.amount(), td.m_mask) : rct::zeroCommit(td.amount());
|
||||
|
Loading…
Reference in New Issue
Block a user