bitcoinlib-rpc
Typed Python wrapper for Bitcoin Core RPC with analysis tools.
Query your Bitcoin node with typed responses, analyze mempool fee markets, decode transactions, and inspect blocks — all from Python or the command line.
Install
pip install bitcoinlib-rpc
Or from source:
git clone https://github.com/Bortlesboat/bitcoinlib-rpc.git
cd bitcoinlib-rpc
pip install -e .
Requirements
- Python 3.10+
- A running Bitcoin Core or Bitcoin Knots node with
server=1in bitcoin.conf txindex=1recommended (required for transaction lookups by txid)
Quick Start
Python API
from bitcoinlib_rpc import BitcoinRPC
rpc = BitcoinRPC() # auto-detects cookie authentication
# Node status
info = rpc.getblockchaininfo()
print(f"Block height: {info['blocks']:,}")
# Fee estimates
fee = rpc.estimatesmartfee(6)
print(f"6-block fee: {fee['feerate'] * 100_000:.1f} sat/vB")
# Decode a transaction
tx = rpc.getrawtransaction("a1075db5...", verbose=2)
Typed Analysis Objects
from bitcoinlib_rpc import BitcoinRPC
from bitcoinlib_rpc.mempool import analyze_mempool
from bitcoinlib_rpc.transactions import analyze_transaction
from bitcoinlib_rpc.blocks import analyze_block
rpc = BitcoinRPC()
# Mempool snapshot with fee bucketing
mempool = analyze_mempool(rpc)
print(f"Congestion: {mempool.congestion}")
print(f"Next block min fee: {mempool.next_block_min_fee:.1f} sat/vB")
# Transaction analysis with inscription detection
tx = analyze_transaction(rpc, "a1075db5...")
print(f"Fee rate: {tx.fee_rate_sat_vb:.1f} sat/vB")
print(f"SegWit discount: {tx.segwit_discount_pct:.1f}%")
# Block analysis with pool identification
block = analyze_block(rpc, 939290)
print(f"Mined by: {block.pool_name}")
print(f"Taproot adoption: {block.taproot_pct:.1f}%")
Command Line Tools
# Node status
bitcoin-status
# Mempool analysis
bitcoin-mempool
# Decode a transaction
bitcoin-tx a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d
# Analyze a block
bitcoin-block 939290
# Fee estimates
bitcoin-fees --once
# Continuous fee tracking with CSV log
bitcoin-fees --csv fees.csv
# Next block prediction
bitcoin-nextblock
Tools
| Command | What it does |
|---|---|
bitcoin-status |
Node chain, sync, disk, peers |
bitcoin-mempool |
Fee buckets, congestion, next-block estimate |
bitcoin-tx <txid> |
Full tx decode + inscription detection |
bitcoin-block <height> |
Pool ID, SegWit/Taproot adoption, fee distribution |
bitcoin-fees |
Fee targets for 1/3/6/25/144 blocks |
bitcoin-nextblock |
Block template: weight, revenue, fee distribution |
Authentication
The library auto-detects the .cookie file from standard Bitcoin Core locations:
- Windows:
%APPDATA%\Bitcoin\.cookieor common datadirs (E:, D:) - macOS:
~/Library/Application Support/Bitcoin/.cookie - Linux:
~/.bitcoin/.cookie
Or provide credentials explicitly:
rpc = BitcoinRPC(user="rpcuser", password="rpcpassword")
rpc = BitcoinRPC(cookie_path="/path/to/.cookie")
rpc = BitcoinRPC(datadir="/mnt/bitcoin")
Related
- Bitcoin Protocol Guide — the educational guide this library accompanies
- Bitcoin Core RPC Reference
License
MIT
Metadata
Release files for bitcoinlib-rpc 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bitcoinlib_rpc-0.1.0.tar.gz | 15.9 kB | Without provenance | Details for bitcoinlib_rpc-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bitcoinlib_rpc-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bitcoinlib_rpc-0.1.0-py3-none-any.whl |
Total release size: 35.5 kB
Release files / bitcoinlib_rpc-0.1.0.tar.gz
| Download URL | bitcoinlib_rpc-0.1.0.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7125422a7b462b501ddbd8af781c9ae29f548a7aae2dc6b87a2b4df5eaf6fd68
|
|
BLAKE2b-256 checksum How to use checksums |
59383fc06f94c2ac692c041a8a3efe2629bb6f55761016eb4ee178f8dfeb9f2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / bitcoinlib_rpc-0.1.0-py3-none-any.whl
| Download URL | bitcoinlib_rpc-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b7eb465294454c2f54a4aeae6a535b3786c85a221b4acff1c99fce9d9d03844
|
|
BLAKE2b-256 checksum How to use checksums |
f4f8f6b81a26970aa6e8e4760cad9fd4a0ac48b3e56320e83f78d3b11673a67f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for bitcoinlib-rpc 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.