fixed coinbase unlock 288 blks

This commit is contained in:
wowario 2021-05-09 21:55:34 +03:00
parent 51c8b36ba0
commit 03af4e871c
3 changed files with 15 additions and 10 deletions

View file

@ -40,6 +40,8 @@
#define CRYPTONOTE_MAX_TX_SIZE 1000000 #define CRYPTONOTE_MAX_TX_SIZE 1000000
#define CRYPTONOTE_MAX_TX_PER_BLOCK 0x10000000 #define CRYPTONOTE_MAX_TX_PER_BLOCK 0x10000000
#define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0 #define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
#define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2 288
#define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 60
#define CURRENT_TRANSACTION_VERSION 2 #define CURRENT_TRANSACTION_VERSION 2
#define CURRENT_BLOCK_MAJOR_VERSION 7 #define CURRENT_BLOCK_MAJOR_VERSION 7
#define CURRENT_BLOCK_MINOR_VERSION 7 #define CURRENT_BLOCK_MINOR_VERSION 7
@ -191,6 +193,7 @@
#define HF_VERSION_CLSAG 16 #define HF_VERSION_CLSAG 16
#define HF_VERSION_DETERMINISTIC_UNLOCK_TIME 16 #define HF_VERSION_DETERMINISTIC_UNLOCK_TIME 16
#define HF_VERSION_DYNAMIC_UNLOCK 16 #define HF_VERSION_DYNAMIC_UNLOCK 16
#define HF_VERSION_FIXED_UNLOCK 18
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8 #define PER_KB_FEE_QUANTIZATION_DECIMALS 8

View file

@ -1427,12 +1427,11 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
} }
MDEBUG("Miner tx hash: " << get_transaction_hash(b.miner_tx)); MDEBUG("Miner tx hash: " << get_transaction_hash(b.miner_tx));
// Dynamic unlock time from HF 16 if (hf_version >= HF_VERSION_FIXED_UNLOCK)
// To calculate unlock window, get the block hash at height-1337, convert the {
// first 3 characters from hexadecimal to decimal, multiply by 2, and then add 288. CHECK_AND_ASSERT_MES(b.miner_tx.unlock_time == height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2, false, "coinbase transaction transaction has the wrong unlock time="
// Unlock minimum 1 day (288 blocks), maximum is ~29 days ((4095*2)+288 = 8478 blocks) << b.miner_tx.unlock_time << ", expected " << height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2);
// unlock time = unlock_window + height } else if (hf_version < HF_VERSION_FIXED_UNLOCK && hf_version >= HF_VERSION_DYNAMIC_UNLOCK)
if (hf_version >= HF_VERSION_DYNAMIC_UNLOCK)
{ {
uint64_t N = m_nettype == MAINNET ? 1337 : 5; uint64_t N = m_nettype == MAINNET ? 1337 : 5;
crypto::hash blk_id = get_block_id_by_height(height-N); crypto::hash blk_id = get_block_id_by_height(height-N);
@ -1449,8 +1448,8 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
"\nblk_height: " << height-N << ", blk_id: " << blk_id << "\nblk_height: " << height-N << ", blk_id: " << blk_id <<
"\nhex_str: " << hex_str << ", blk_num: " << blk_num); "\nhex_str: " << hex_str << ", blk_num: " << blk_num);
} else { } else {
CHECK_AND_ASSERT_MES(b.miner_tx.unlock_time == height + 60, false, "coinbase transaction transaction has the wrong unlock time=" 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 + 60); << b.miner_tx.unlock_time << ", expected " << height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW);
} }
//check outs overflow //check outs overflow

View file

@ -167,7 +167,10 @@ namespace cryptonote
tx.version = 1; tx.version = 1;
//lock //lock
if (hard_fork_version >= HF_VERSION_DYNAMIC_UNLOCK) if (hard_fork_version >= HF_VERSION_FIXED_UNLOCK)
{
tx.unlock_time = height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2;
} else if (hard_fork_version < HF_VERSION_FIXED_UNLOCK && hard_fork_version >= HF_VERSION_DYNAMIC_UNLOCK)
{ {
uint64_t N = m_nettype == MAINNET ? 1337 : 5; uint64_t N = m_nettype == MAINNET ? 1337 : 5;
crypto::hash blk_id = pb->get_block_id_by_height(height-N); crypto::hash blk_id = pb->get_block_id_by_height(height-N);
@ -176,7 +179,7 @@ namespace cryptonote
uint64_t unlock_window = blk_num + 288; uint64_t unlock_window = blk_num + 288;
tx.unlock_time = height + unlock_window; tx.unlock_time = height + unlock_window;
} else { } else {
tx.unlock_time = height + 60; tx.unlock_time = height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
} }
tx.vin.push_back(in); tx.vin.push_back(in);