Skip to content

Commit 435605a

Browse files
author
pythcoiner
committed
get genesis timestamp from bitcoind
1 parent 3fcbb0b commit 435605a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/commands/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ use miniscript::{
3333
};
3434
use serde::{Deserialize, Serialize};
3535

36-
// Timestamp in the header of the genesis block. Used for sanity checks.
37-
const MAINNET_GENESIS_TIME: u32 = 1231006505;
38-
3936
#[derive(Debug, Clone, PartialEq, Eq)]
4037
pub enum CommandError {
4138
NoOutpointForSelfSend,
@@ -888,13 +885,14 @@ impl DaemonControl {
888885
/// The date must be after the genesis block time and before the current tip blocktime.
889886
pub fn start_rescan(&self, timestamp: u32) -> Result<(), CommandError> {
890887
let mut db_conn = self.db.connection();
888+
let genesis_timestamp = self.bitcoin.genesis_block().height as u32;
891889

892890
let future_timestamp = self
893891
.bitcoin
894892
.tip_time()
895893
.map(|t| timestamp >= t)
896894
.unwrap_or(false);
897-
if timestamp < MAINNET_GENESIS_TIME || future_timestamp {
895+
if timestamp < genesis_timestamp || future_timestamp {
898896
return Err(CommandError::InsaneRescanTimestamp(timestamp));
899897
}
900898
if db_conn.rescan_timestamp().is_some() || self.bitcoin.rescan_progress().is_some() {

0 commit comments

Comments
 (0)