Skip to main content

Typed Python wrapper for Bitcoin Core RPC with analysis tools

Project description

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=1 in bitcoin.conf
  • txindex=1 recommended (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\.cookie or 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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitcoinlib_rpc-0.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitcoinlib_rpc-0.1.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file bitcoinlib_rpc-0.1.0.tar.gz.

File metadata

  • Download URL: bitcoinlib_rpc-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for bitcoinlib_rpc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7125422a7b462b501ddbd8af781c9ae29f548a7aae2dc6b87a2b4df5eaf6fd68
MD5 7db45d412a9ddebb0da1d948628ef1f8
BLAKE2b-256 59383fc06f94c2ac692c041a8a3efe2629bb6f55761016eb4ee178f8dfeb9f2e

See more details on using hashes here.

File details

Details for the file bitcoinlib_rpc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bitcoinlib_rpc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for bitcoinlib_rpc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b7eb465294454c2f54a4aeae6a535b3786c85a221b4acff1c99fce9d9d03844
MD5 107ae0a3a08b1a1dfcb998ffba878926
BLAKE2b-256 f4f8f6b81a26970aa6e8e4760cad9fd4a0ac48b3e56320e83f78d3b11673a67f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page