https://github.com/k-nuth/py-api
Bitcoin full node as a Python library
https://github.com/k-nuth/py-api
Last synced: 3 months ago
JSON representation
Bitcoin full node as a Python library
- Host: GitHub
- URL: https://github.com/k-nuth/py-api
- Owner: k-nuth
- Created: 2020-01-30T03:32:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-11-04T15:12:40.000Z (over 2 years ago)
- Last Synced: 2025-02-15T20:33:23.259Z (5 months ago)
- Language: Python
- Homepage:
- Size: 6.22 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python API
> Bitcoin Cash full node as a Python library
[](https://pypi.org/project/kth/)
[](LICENSE.md)
[](https://github.com/feross/standard)
![Telegram][badge.telegram]
[Knuth Python API](https://pypi.org/project/kth/) 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
```2. Add a reference to our Python API package:
```
$ pip install kth
```3. Create a new file called `index.py` and write some code:
```Python
import kth
import signal
import asynciorunning_ = False
def shutdown(sig, frame):
global running_
print('Graceful shutdown ...')
running_ = Falseasync 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())
```
4. 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](https://github.com/k-nuth/kth/issues).
[badge.Travis]: https://travis-ci.org/k-nuth/py-api.svg?branch=master
[badge.Appveyor]: https://img.shields.io/appveyor/ci/Knuth/py-api.svg?style=for-the-badge&label=build&logo=appveyor&logoColor=white
[badge.Cirrus]: https://api.cirrus-ci.com/github/k-nuth/py-api.svg?branch=master
[badge.version]: https://badge.fury.io/gh/k-nuth%2Fkth-py-api.svg
[badge.release]: https://img.shields.io/github/release/k-nuth/py-api.svg
[badge.c]: https://img.shields.io/badge/C-11-blue.svg?style=flat&logo=c
[badge.telegram]: https://img.shields.io/badge/telegram-badge-blue.svg?logo=telegram&style=for-the-badge
[badge.slack]: https://img.shields.io/badge/slack-badge-orange.svg?logo=slack&style=for-the-badge