Python library to verify crypto addresses.
Project description
Crypto Address Validation
Simple crypto address validator. Currently it supports the following crypto addresses:
- Bitcoin
- Litecoin
Supported Python versions
Only supported in python >= 3.5
.
Installation
$ pip install cryptoaddress
API
The BitcoinAddress class
BitcoinAddress(address [, network_type='mainnet'])
Parameters
address
: the Bitcoin address to validate.network_type
: Optional. Use either 'mainnet' or 'testnet'.
Raises
ValueError
if the provided address is not a valid Bitcoin address
The LitecoinAddress class
LitecoinAddress(address [, network_type='mainnet'])
Parameters
address
: the Litecoin address to validate.network_type
: Optional. Use either 'mainnet' or 'testnet'.
Raises
ValueError
if the provided address is not a valid Litecoin address
Usage example
You can use directly a subclass of CryptoAddress
:
from cryptoaddress import BitcoinAddress
try:
bitcoin_address = BitcoinAddress('17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem', network_type='mainnet')
print('The address "%s" is valid.' % str(bitcoin_address))
except ValueError:
print('The address is invalid.')
# Prints 'The address "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem" is valid.'
Or you can use the get_crypto_address
utility function:
from cryptoaddress import get_crypto_address
try:
bitcoin_address = get_crypto_address('BTC', '17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem', network_type='mainnet')
print('The address "%s" is valid.' % str(bitcoin_address))
except ValueError:
print('The address is invalid.')
# Prints 'The address "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhem" is valid.'
Upload to pypi
After creating a semantic versioning tag proceed in the following way:
- Install all required packages:
$ python3 -m pip install --user --upgrade setuptools wheel twine
- Generate the package:
$ python3 setup.py sdist bdist_wheel
This will create a dist/
folder whose content has to be uploaded.
- Upload the new package to pypi:
$ python3 -m twine upload --repository-url https://pypi.org/legacy/ dist/*
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
Built Distribution
Hashes for cryptoaddress-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2e5b1761b887f28dc3848787ffce22c43f97fccd0f1e191c2cc76e4d470bb58 |
|
MD5 | ee2893afe4f857c9b977d776cdd90408 |
|
BLAKE2b-256 | ae91759c3970c863e6ec0444b0bbbf215768e5a78cd67f5bcca8f2aa9d1df362 |