Py-Bitcoin-Explorer

所属分类:区块链开发
开发工具:Rust
文件大小:85KB
下载次数:0
上传日期:2021-12-28 09:58:06
上 传 者sh-1993
说明:  Py比特币浏览器,高性能区块链反序列化器
(Py-Bitcoin-Explorer,High Performance Blockchain Deserializer)

文件列表:
.cargo (0, 2023-05-22)
.cargo\config.toml (224, 2023-05-22)
Cargo.lock (21267, 2023-05-22)
Cargo.toml (706, 2023-05-22)
LICENSE.txt (1055, 2023-05-22)
bitcoin_explorer (0, 2023-05-22)
bitcoin_explorer\__init__.py (11749, 2023-05-22)
docs (0, 2023-05-22)
docs\bitcoin_explorer.html (151266, 2023-05-22)
docs\bitcoin_explorer (0, 2023-05-22)
docs\bitcoin_explorer\bitcoin_explorer.html (66478, 2023-05-22)
docs\index.html (52347, 2023-05-22)
docs\search.json (97211, 2023-05-22)
example (0, 2023-05-22)
example\tests.ipynb (10794, 2023-05-22)
gen_doc.sh (83, 2023-05-22)
pyproject.toml (1089, 2023-05-22)
src (0, 2023-05-22)
src\lib.rs (9870, 2023-05-22)
src\proto_to_py.rs (7403, 2023-05-22)

# bitcoin-explorer ![CI](https://github.com/Congyuwang/Py-Bitcoin-Explorer/actions/workflows/CI.yml/badge.svg) ![PyPI](https://img.shields.io/pypi/dm/bitcoin-explorer) ![PyPI](https://img.shields.io/pypi/wheel/bitcoin-explorer) `bitcoin_explorer` is an efficient library for reading bitcoin-core binary blockchain file as a database (utilising multi-threading). This package is ported using pyO3 from rust library `bitcoin-explorer` ### Installation MacOS, Windows, and Linux wheels are provided. Use `pip install bitcoin-explorer` to install. ## Documentation This library has a Rust version, go to [Rust Documentation](https://docs.rs/bitcoin-explorer/) For python documentation, go to [Documentation](https://congyuwang.github.io/Py-Bitcoin-Explorer/bitcoin_explorer.html). ## 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-g194b9b8792d9b07***fdb570b79fa51f1d1f5ebaf Copyright (C) 2009-2020 The Bitcoin Core developers`. ## Examples It contains one class `BitcoinDB`. ```python import bitcoin_explorer as bex # parse the same path as `--datadir` argument for `bitcoind`. db = bex.BitcoinDB("~/Bitcoin") # get the length of the longest chain currently on disk. db.get_block_count() # get block of a certain height db.get_block(1000) # to retrieve the connected outputs of each inputs as well. # note that this is inefficient. # Use `get_block_iter_range(end, connected=True)` for better performance. db.get_block(1000, connected=True) # get block hash of a certain height. db.get_hash_from_height(1000) # a fast method for getting just the header. # in memory query, no disk access db.get_block_header(1000) # get block of height 1000. db.get_height_from_hash("some hash") # get transaction from txid. # This queries the `levelDB` each time, thus it is relatively slow. db.get_transaction("some txid") # get the height of the block which this transaction belongs. db.get_height_from_txid("some txid") # get the script type and addresses from a script public key db.parse_script("some hex script pubic key") # use iterator for block in db.get_block_iter_range(start=1000, end=2000): do_something_with(block) # use iterator, iterate over heights for block in db.get_block_iter_array(heights=[1, 3, 5, 7, 9]): do_something_with(block) # use iterator, connect outpoints # This requires 5 GB memory. for block in db.get_block_iter_range(end=700000, connected=True): do_something_with(block) ```

近期下载者

相关文件


收藏者