{"id":23364,"library":"bitcoin-utils","title":"bitcoin-utils","description":"A Python library for Bitcoin utility functions, including key generation, transaction building, and script manipulation. Version 0.8.1 is the latest release. Development and release cadence are intermittent.","status":"active","version":"0.8.1","language":"python","source_language":"en","source_url":"https://github.com/karask/python-bitcoin-utils","tags":["bitcoin","cryptocurrency","blockchain","utilities"],"install":[{"cmd":"pip install bitcoin-utils","lang":"bash","label":"latest"}],"dependencies":[],"imports":[{"note":"Common pattern: import setup and then the classes you need.","symbol":"BitcoinAddress","correct":"from bitcoinutils.setup import setup\nfrom bitcoinutils.utils import BitcoinAddress\nfrom bitcoinutils.script import Script"}],"quickstart":{"code":"from bitcoinutils.setup import setup\nfrom bitcoinutils.keys import PrivateKey\nfrom bitcoinutils.utils import BitcoinAddress\nfrom bitcoinutils.script import Script\n\n# Setup network\nsetup('regtest')\n\n# Generate private key\npriv = PrivateKey()\nprint('Private key:', priv.to_wif())\n\n# Get public key\npub = priv.get_public_key()\nprint('Public key:', pub.to_hex())\n\n# Generate P2PKH address\naddr = pub.get_address()\nprint('Address:', addr.to_string())","lang":"python","description":"Demonstrates basic setup, key generation, and P2PKH address creation on regtest."},"warnings":[{"fix":"Always call setup('mainnet') or setup('testnet') or setup('regtest') first.","message":"Network setup must be called before any other operations. Failure to call setup() leads to cryptic errors.","severity":"breaking","affected_versions":"all"},{"fix":"Use PrivateKey.from_wif('L...') instead of PrivateKey()","message":"PrivateKey generates new random keys by default. To recover from a WIF, use PrivateKey.from_wif().","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Call setup('testnet') for testnet addresses or setup('mainnet') for mainnet addresses.","cause":"Using an address from a different network (mainnet vs testnet) without setting the correct network.","error":"bitcoinutils.exceptions.AddressError: Invalid address checksum"},{"fix":"Do not call setup() multiple times. Alternatively, check if already set up or use a single call at the start.","cause":"Attempting to call setup() more than once.","error":"bitcoinutils.setup.NetworkSetupError: Already setup on 'mainnet'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}