2022-04-09 14:38:00 +00:00
|
|
|
library(data.table)
|
2022-05-12 02:10:07 +00:00
|
|
|
library(rbch)
|
2022-04-09 14:38:00 +00:00
|
|
|
|
|
|
|
bitcoin.conf.file <- ""
|
|
|
|
# Input filepath for your bitcoin.conf file
|
|
|
|
|
|
|
|
data.dir <- ""
|
|
|
|
# Input data directory here, with trailing "/"
|
|
|
|
|
2022-04-29 20:44:29 +00:00
|
|
|
bitcoin.config <- rbch::conrpc(bitcoin.conf.file)
|
2022-04-09 14:38:00 +00:00
|
|
|
|
|
|
|
initial.fork.height <- 478558 - 1
|
|
|
|
|
|
|
|
# current.block.height <- 733867
|
|
|
|
# 733867 is for BCH
|
2022-05-12 02:10:07 +00:00
|
|
|
# current.block.height <- 729896
|
2022-04-09 14:38:00 +00:00
|
|
|
# 729896 is for BTC
|
|
|
|
|
|
|
|
block.times <- vector(length(initial.fork.height:current.block.height), mode ="list")
|
|
|
|
|
|
|
|
for (iter.block.height in initial.fork.height:current.block.height) {
|
|
|
|
|
|
|
|
if (iter.block.height %% 1000 == 0) {
|
|
|
|
cat(iter.block.height, base::date(), "\n")
|
|
|
|
}
|
|
|
|
|
2022-04-29 20:44:29 +00:00
|
|
|
block.hash <- rbch::getblockhash(bitcoin.config, iter.block.height)
|
|
|
|
block.data <- rbch::getblock(bitcoin.config, blockhash = block.hash@result, verbosity = "l1")
|
2022-04-09 14:38:00 +00:00
|
|
|
block.times[[iter.block.height - initial.fork.height + 1]] <-
|
|
|
|
data.frame(block_height = iter.block.height, block_time = block.data@result$time)
|
|
|
|
}
|
|
|
|
|
|
|
|
block.times <- data.table::rbindlist(block.times)
|
|
|
|
|
|
|
|
saveRDS(block.times, file = paste0(data.dir, "block_times.rds"))
|
|
|
|
|
|
|
|
|
|
|
|
|