Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dourvaris/nano-python
RaiBlocks Node RPC Python Client
https://github.com/dourvaris/nano-python
cryptocurrency python raiblocks xrb
Last synced: about 2 months ago
JSON representation
RaiBlocks Node RPC Python Client
- Host: GitHub
- URL: https://github.com/dourvaris/nano-python
- Owner: dourvaris
- License: mit
- Created: 2018-01-07T00:37:28.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-19T00:59:37.000Z (over 4 years ago)
- Last Synced: 2024-09-18T05:00:59.663Z (4 months ago)
- Topics: cryptocurrency, python, raiblocks, xrb
- Language: Python
- Homepage: https://nano-python.readthedocs.io/
- Size: 373 KB
- Stars: 48
- Watchers: 8
- Forks: 14
- Open Issues: 5
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
===============================
Nano (RaiBlocks) Python Library
===============================.. image:: https://img.shields.io/pypi/l/nano-python.svg
:target: https://github.com/dourvaris/nano-python/blob/master/LICENSE.. image:: https://travis-ci.org/dourvaris/nano-python.svg?branch=1.0.0rc1
:target: https://travis-ci.org/dourvaris/nano-python.. image:: https://readthedocs.org/projects/nano-python/badge/?version=latest
:target: http://nano-python.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status.. image:: https://github.com/dourvaris/nano-python/raw/master/coverage.svg?sanitize=true
:target: https://travis-ci.org/dourvaris/nano-python.. image:: https://img.shields.io/pypi/pyversions/nano-python.svg?style=flat-square
:target: https://pypi.python.org/pypi/nano-python.. image:: https://img.shields.io/pypi/v/nano-python.svg
:target: https://pypi.python.org/pypi/nano-pythonThis library contains a python wrapper for the Nano (RaiBlocks) RPC server
which tries to make it a little easier to work with by converting RPC responses
to native python ones and exposing a pythonic api for making RPC calls.Also included are utilities such as converting rai/xrb and interesting accounts
Installation
============.. code-block:: text
pip install nano-python
Documentation
=============https://nano-python.readthedocs.io/
RPC client
==========You can browse the available
`RPC methods list `_
or check the
`RPC Client API documentation `_
for examples of usage... warning:: The RPC client **DOES NOT** handle timeouts or retries
automatically since this could lead to unwanted retries of requests
causing **double spends**. Keep this in mind when implementing retries.When using version 10.0 of the RPC node, use the send id when making spends
as described at https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol#highly-recommended-id.. code-block:: python
>>> import nano
>>> rpc = nano.rpc.Client('http://localhost:7076')
>>> rpc.version()
{
'rpc_version': 1,
'store_version': 10,
'node_vendor': 'RaiBlocks 9.0'
}
>>> rpc.peers()
{
'[::ffff:75.171.168.5]:7075': 4,
'[::ffff:108.44.38.183]:1032': 4
}Crypto/Accounts
===============.. code-block:: python
>>> from nano import generate_account, verify_signature, sign_message
>>> account = generate_account(seed='someseed')
>>> signature = sign_message(b'this', account['private_key_bytes'])
>>> verify_signature(b'this', signature, account['public_key_bytes'])
True
>>> verify_signature(b'that', signature, account['public_key_bytes'])
FalseConversion
==========.. code-block:: python
>>> from nano import convert
>>> convert(12, from_unit='XRB', to_unit='raw')
Decimal('1.2E+31')>>> convert(0.4, from_unit='krai', to_unit='XRB')
Traceback (most recent call last):
File "", line 1, in
ValueError: float values can lead to unexpected
precision loss, please use a Decimal or string
eg. convert('0.4', 'krai', 'XRB')>>> convert('0.4', from_unit='krai', to_unit='XRB')
Decimal('0.0004')Known Accounts / Constants
==========================.. code-block:: python
>>> from nano import GENESIS_BLOCK_HASH
>>> GENESIS_BLOCK_HASH
'991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948'.. code-block:: python
>>> from nano import KNOWN_ACCOUNT_IDS
>>> KNOWN_ACCOUNT_IDS['xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est']
'Developer Fund'.. code-block:: python
>>> from nano import KNOWN_ACCOUNT_NAMES
>>> KNOWN_ACCOUNT_NAMES['Burn']
'xrb_1111111111111111111111111111111111111111111111111111hifc8npp'Development
===========Setup
-----.. code-block:: text
virtualenv venv
source venv/bin/activate
pip install -r requirements.pip -r requirements-dev.pip
python setup.py develop
pre-commit autoupdate
pre-commit installRunning tests
-------------.. code-block:: text
# regular
pytest# coverage
./coverageBuilding docs
-------------.. code-block:: text
cd docs
# generate once
make html# live building
make liveMaking a release
----------------.. code-block:: text
vim CHANGELOG.rst # update changes
bumpversion [major|minor|patch]
python setup.py upload