Skip to content

Commit

Permalink
added locktime validation making sure locktimes aren't in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
slanesuke committed Apr 13, 2024
1 parent 9e4fc25 commit 329d210
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mine-your-first-block/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,15 @@ fn process_mempool(mempool_path: &str) -> io::Result<Vec<TransactionForProcessin
//eprintln!("Transaction is not valid: {:?}", path);
}

// Check if locktime is valid by comparing it to the current time
let current_time = SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Time went backwards")
.as_secs() as u32;
if transaction.locktime > current_time && transaction.locktime >= 500_000_000 {
continue;
}


// Get the fee if valid so i can add it to my vec
let fee = verify_tx_fee(&transaction);
Expand Down Expand Up @@ -880,6 +889,8 @@ fn calculate_transaction_weight(tx: &Transaction) -> u64 {
tx_weight
}

// ISSUE Block does not meet target difficulty
// So my block hash is too big so maybe too many transations in a block?
fn main() {
let mempool_path = "../mempool";

Expand Down

0 comments on commit 329d210

Please sign in to comment.