@ -1382,7 +1382,18 @@ bool Blockchain::prevalidate_miner_transaction(const block& b, uint64_t height,
return false ;
}
MDEBUG ( " Miner tx hash: " < < get_transaction_hash ( b . miner_tx ) ) ;
if ( hf_version > = HF_VERSION_FIXED_UNLOCK ) {
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= " < < b . miner_tx . unlock_time < < " , expected " < < height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW_V2 ) ;
} else if ( hf_version < HF_VERSION_FIXED_UNLOCK & & hf_version > = HF_VERSION_DYNAMIC_UNLOCK ) {
uint64_t N = m_nettype = = MAINNET ? 1337 : 5 ;
crypto : : hash blk_id = get_block_id_by_height ( height - N ) ;
std : : string hex_str = epee : : string_tools : : pod_to_hex ( blk_id ) . substr ( 0 , 3 ) ;
uint64_t blk_num = std : : stol ( hex_str , nullptr , 16 ) * 2 ;
uint64_t unlock_window = blk_num + 288 ;
CHECK_AND_ASSERT_MES ( b . miner_tx . unlock_time = = height + unlock_window , false , " coinbase transaction transaction has the wrong unlock time= " < < b . miner_tx . unlock_time < < " , expected " < < height + unlock_window ) ;
} else {
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 ) ;
}
//check outs overflow
if ( ! check_outs_overflow ( b . miner_tx ) )
@ -1753,7 +1764,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
//make blocks coin-base tx looks close to real coinbase tx to get truthful blob weight
uint8_t hf_version = b . major_version ;
size_t max_outs = hf_version > = 4 ? 1 : 11 ;
bool r = construct_miner_tx ( height , median_weight , already_generated_coins , txs_weight , fee , miner_address , b . miner_tx , ex_nonce , max_outs , hf_version ) ;
bool r = construct_miner_tx ( this , m_nettype , height , median_weight , already_generated_coins , txs_weight , fee , miner_address , b . miner_tx , ex_nonce , max_outs , hf_version ) ;
CHECK_AND_ASSERT_MES ( r , false , " Failed to construct miner tx, first chance " ) ;
size_t cumulative_weight = txs_weight + get_transaction_weight ( b . miner_tx ) ;
# if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
@ -1762,7 +1773,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
# endif
for ( size_t try_count = 0 ; try_count ! = 10 ; + + try_count )
{
r = construct_miner_tx ( height , median_weight , already_generated_coins , cumulative_weight , fee , miner_address , b . miner_tx , ex_nonce , max_outs , hf_version ) ;
r = construct_miner_tx ( this , m_nettype , height , median_weight , already_generated_coins , cumulative_weight , fee , miner_address , b . miner_tx , ex_nonce , max_outs , hf_version ) ;
CHECK_AND_ASSERT_MES ( r , false , " Failed to construct miner tx, second chance " ) ;
size_t coinbase_weight = get_transaction_weight ( b . miner_tx ) ;