bitcoinquery
bitcoinquery
is a python package developed in rust
for accessing bitcoin-core binary files as a database.
Compatibility Note
This package deals with the binary file of another software Bitcoin Core
.
It might not be compatible with older Bitcoin Core versions.
Currently, it is compatible with Bitcoin Core version
Bitcoin Core version v0.21.1.0-g194b9b8792d9b0798fdb570b79fa51f1d1f5ebaf Copyright (C) 2009-2020 The Bitcoin Core developers
.
Usage
It contains one class BitcoinDB
.
# parse the same path as `--datadir` argument for `bitcoind`.
=
# get the length of the longest chain currently on disk.
# get block of a certain height
# to retrieve the connected outputs of each inputs as well
# get block hash of a certain height.
# a fast method for getting just the header.
# in memory query, no disk access
# get block of height 1000.
# get blocks of heights 100..199.
# (This method uses `rayon` parallel computing to take advantage of multicore)
# this function returns json string instead of object.
# get transaction from txid.
# This queries the `levelDB` each time, thus it is relatively slow.
# get the height of the block which this transaction belongs.
# get the script type and addresses from a script public key
How to Build
This is a PyO3 project. Use maturin to build and publish.
pip install maturin
.
On mac, when using cargo to build, add the following into .cargo/cargo.toml
.
[]
= [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
[]
= [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]