Skip to main content

Bitcoin Cash development platform for Python applications

Project description

Python API

Bitcoin Cash full node as a Python library

PyPi Version License py-standard-style Telegram

Knuth Python API is a high performance implementation of the Bitcoin Cash protocol focused on users requiring extra performance and flexibility. It is a Bitcoin Cash node you can use as a library.

Getting started with Python

  1. Create a new Python console project:
$ mkdir HelloKnuth
$ cd HelloKnuth
  1. Add a reference to our Python API package:
$ pip install kth
  1. Create a new file called and write some code:
import kth
import signal
import asyncio

running_ = False

def shutdown(sig, frame):
    global running_
    print('Graceful shutdown ...')
    running_ = False

async def main():
    global running_
    signal.signal(signal.SIGINT, shutdown)
    config = kth.config.getDefault(kth.config.Network.mainnet)

    with kth.node.Node(config, True) as node:
        await node.launch(kth.primitives.StartModules.all)
        print("Knuth node has been launched.")
        running_ = True

        (_, height) = await node.chain.getLastHeight()
        print(f"Current height in local copy: {height}")

        if await comeBackAfterTheBCHHardFork(node):
            print("Bitcoin Cash has been created!")

        # node.close()
        print("Good bye!")

async def comeBackAfterTheBCHHardFork(node):
    hfHeight = 478559
    while running_:
        (_, height) = await node.chain.getLastHeight()
        if height >= hfHeight:
            return True
        await asyncio.sleep(10)

    return False
  1. Enjoy Knuth node as a Python library:
$ python


Each of our modules has its own Github repository, but in case you want to create an issue, please do so in our main repository.

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

kth-0.8.0.tar.gz (26.7 kB view hashes)

Uploaded source

Built Distribution

kth-0.8.0-py2.py3-none-any.whl (30.6 kB view hashes)

Uploaded py2 py3

Supported by

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