Welcome to neo-python-core’s documentation!¶
Contents:
Library for working with NEO related data in Python, without database dependencies.
- Datatypes like
UInt160
,KeyPair
,BigInteger
and basic string to address and address toUInt160
methods - Includes a useful cli-tool
np-utils
(see help withnp-utils -h
) - Compatible with Python 3.5+
- Used by neo-python
- https://pypi.python.org/pypi/neocore
np-utils
examples:
$ np-utils -h
usage: np-utils [-h] [--version] [--address-to-scripthash address]
[--scripthash-to-address scripthash] [--create-wallet]
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
--address-to-scripthash address
Convert an address to scripthash
--scripthash-to-address scripthash
Convert scripthash to address
--create-wallet Create a wallet
$ np-utils --create-wallet
{
"private_key": "KwJqCbjsmGUCqbkp83Nxi9MJ9mA7F8EN4tebJVWjYZBEoWCNxCaF",
"address": "AHVvg26CNz1vxteJfeHy4R8P4VN8SydCM6"
}
$ np-utils --address-to-scripthash AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y
Scripthash big endian: 0xe9eed8dc39332032dc22e5d6e86332c50327ba23
Scripthash little endian: 23ba2703c53263e8d6e522dc32203339dcd8eee9
Scripthash neo-python format: b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9'
$ np-utils --scripthash-to-address 0xe9eed8dc39332032dc22e5d6e86332c50327ba23
AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y
$ np-utils --scripthash-to-address 23ba2703c53263e8d6e522dc32203339dcd8eee9
Detected little endian scripthash. Converting to big endian for internal use.
Big endian scripthash: 0xe9eed8dc39332032dc22e5d6e86332c50327ba23
AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y
Getting started¶
You need Python 3.5 or higher!
You can install neocore from PyPI with easy_install
or pip
:
$ pip install -U neocore
Alternatively, if you want to work on the code, clone this repository and setup your venv:
- Clone the repo:
git clone https://github.com/CityOfZion/neo-python-core.git
- Create a Python 3 virtual environment and activate it:
$ python3 -m venv venv
$ source venv/bin/activate
- Then install the requirements:
$ pip install -e .
$ pip install -r requirements_dev.txt
Useful commands¶
$ make lint
$ make test
$ make coverage
Release checklist¶
(Only for admins)
Releasing a new version on GitHub automatically uploads this release to PyPI. This is a checklist for releasing a new version:
# Only in case you want to increase the version number again (eg. scope changed from patch to minor):
bumpversion --no-tag minor|major
# Update ``HISTORY.rst`` with the new version number and the changes and commit this
vi HISTORY.rst
git commit -m "Updated HISTORY.rst" HISTORY.rst
# Set the release version number and create the tag
bumpversion release
# Increase patch number and add `-dev`
bumpversion --no-tag patch
# Push to GitHub, which also updates the PyPI package
git push && git push --tags
Installation¶
Stable release¶
To install neo-python-core, run this command in your terminal:
$ pip install neocore
This is the preferred method to install neo-python-core, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for neo-python-core can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/CityOfZion/neo-python-core
Or download the tarball:
$ curl -OL https://github.com/CityOfZion/neo-python-core/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/CityOfZion/neo-python-core/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
neo-python-core could always use more documentation, whether as part of the official neo-python-core docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/CityOfZion/neo-python-core/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up neo-python-core for local development.
Fork the neo-python-core repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:<your-name>/neo-python-core.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv neo-python-core $ cd neo-python-core/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 neocore tests $ python setup.py test or py.test
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/CityOfZion/neo-python-core/pull_requests and make sure that the tests pass for all supported Python versions.
History¶
0.5.6 2018-12-18¶
- Updated dependencies
- Added
SafeReadBytes
toBinaryReader
0.5.5 2018-12-18¶
- Updated dependencies
- Added
isValidPublicAddress()
to utility module
0.5.4 2018-10-31¶
- Updated BigInteger to properly support logical shifts
- Added tests for np-utils
- Updated dependencies
0.5.3 2018-10-02¶
- Updated the dependencies
0.5.2 (2018-08-28)¶
- Fixed8.TryParse fix for zero
- Updated dependencies
0.5.1 (2018-08-23)¶
- Change BigInteger divisor operation to use floordiv rather than truediv
0.5.0 (2018-08-21)¶
- np-utils –address-to-scripthash outputs now little-endian and big-endian scripthashes
- np-utils –scripthash-to-address detects input endianness and converts accordingly
- Updated dependencies
0.4.11 (2018-07-05)¶
- Added
Size()
method to ECPoint and Fixed8 class.
0.4.10 (2018-06-25)¶
- Updated requirements: pycryptome
0.4.9 (2018-06-08)¶
- Updated dependencies, especially base58
0.4.8 (2018-05-31)¶
- Create wallets with
np-utils --create-wallet
0.4.2 (2018-04-26)¶
np-utils
now supports--scripthash-to-address
(thx @belane)
0.4.1 (2018-04-26)¶
np-utils
cli tool (seecli.py
, PR #40)- alter initialization of Crypto signature curve
0.3.10 (2018-03-21)¶
- Fix formatting of
ToNeoJsonString()
which was cutting off trailing zeroes from integers.
0.3.8 (2018-03-14)¶
- Fix travis deploy to be compatible with recent neo-python changes
- Update scrypt and logzero dependency versions
0.3.6 (2018-02-26)¶
- Enabled Python >= 3.4 in setup.py
0.3.2 (2018-01-23)¶
- Added UInt
To0xString
method
0.3.1 (2018-01-09)¶
- Documentation update
- Moved the
cryptography
dependency torequirements_dev.txt
0.3.0 (2018-01-09)¶
- Added
neo.Cryptography
andKeyPair
- Changed signature of
neocore.Cryptography.Crypto.Sign()
to remove unusedpublic_key
argument - Removed redundant
neocore.Cryptography.Helper.hash_to_wallet_address()
function, useneocore.Cryptography.Helper.scripthash_to_address()
instead. - Removed unused
neocore.Cryptography.Helper
functions:random_string
,bytes_to_hex_string
,bin_sha256
,sha256
,random_key
.
0.2.4 + 0.2.5 (2018-01-03)¶
- Bugfix for deploying from Travis to PyPI/neocore
0.1.1 - 0.1.2 (2017-12-30)¶
- Testing of releases on PyPI with Travis CI.
0.1.0 (2017-12-28)¶
- First release on PyPI.