kth 0.8.0

Creator: bradpython12

Last updated:

Add to Cart

Description:

kth 0.8.0

Python API

Bitcoin Cash full node as a Python library






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

Create a new Python console project:

$ mkdir HelloKnuth
$ cd HelloKnuth


Add a reference to our Python API package:

$ pip install kth


Create a new file called index.py 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

asyncio.run(main())


Enjoy Knuth node as a Python library:

$ python index.py

Issues
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.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.