Bitcoin Cash development platform for Python applications
Project description
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.
Project details
Release history Release notifications | RSS feed
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 details)
Built Distribution
kth-0.8.0-py2.py3-none-any.whl
(30.6 kB
view details)
File details
Details for the file kth-0.8.0.tar.gz
.
File metadata
- Download URL: kth-0.8.0.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2712f8ff8cdac18278e6fdf7afc6fd8e88055e8a0ce59d11e185804108ed943d |
|
MD5 | 8c9e766199b325f59bc62b670755c57e |
|
BLAKE2b-256 | ba1cdf3fee4bad914593c7fcabdae27f31459f608276c58569d59f3f698fe4f5 |
File details
Details for the file kth-0.8.0-py2.py3-none-any.whl
.
File metadata
- Download URL: kth-0.8.0-py2.py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31457c627d8421054660ba968a59e107f20c0aedab23a5a7019522086b81c817 |
|
MD5 | 849b7ce75f2a0a9b1b90f966dcfcd819 |
|
BLAKE2b-256 | 57667a191c00939fca19df569e6bc7ae20639568763f0417acbe0c262fd11c6d |