Skip to content

Commit 5c52e28

Browse files
committed
Relative lock - consensus code (proof of concept)
1 parent 70600ee commit 5c52e28

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/cryptonote_core/blockchain.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,14 @@ static bool get_fcmp_tx_tree_root(const BlockchainDB *db, const cryptonote::tran
102102
return true;
103103
CHECK_AND_ASSERT_MES(!tx.pruned, false, "can't get root for pruned FCMP txs");
104104

105-
// Make sure reference block exists in the chain
106-
CHECK_AND_NO_ASSERT_MES_L1(tx.rct_signatures.p.reference_block < db->height(), false,
105+
uint64_t unlock_height = db->height();
106+
if (tx.unlock_time == 1) //relative lock
107+
{
108+
unlock_height -= 720;
109+
}
110+
111+
// Make sure reference block exists in the chain and is unlocked
112+
CHECK_AND_NO_ASSERT_MES_L1(tx.rct_signatures.p.reference_block < unlock_height, false,
107113
"tx " << get_transaction_hash(tx) << " included reference block that was too high");
108114

109115
// Get the tree root and n tree layers at provided block

src/cryptonote_core/tx_verification_utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ static bool ver_non_input_consensus_templated(TxForwardIt tx_begin,
346346
}
347347

348348
// Rule 8
349-
if (hf_version >= HF_VERSION_REJECT_UNLOCK_TIME && tx.unlock_time != 0)
349+
// Allow unlock_time 0 (no lock) or 1 (relative lock)
350+
if (hf_version >= HF_VERSION_REJECT_UNLOCK_TIME && tx.unlock_time > 1)
350351
{
351352
tvc.m_verifivation_failed = true;
352353
tvc.m_nonzero_unlock_time = true;

0 commit comments

Comments
 (0)