/bitcoineasy

Simple Bitcoin primitives for learning purpose

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Bitcoin-easy

A set of utility functions for Bitcoin.
PyPI version Pull Requests Welcome

📋 Contents

Introduction (/ what can you do with bitcoin-easy ?)

You can generate private and derive corresponding public keys, addresses, and in different formats (compressed, uncompressed, WIF).
You can encrypt your keys in an universal scheme described in bip-038.
You can also use the functions from utils.py if you want to do other things (like base58check encoding, WIF encoding, pseudo-random generation, common Bitcoin hashing functions).
Still in development, more functions to come.

How ?

>>> import bitcoineasy.bitcoineasy as bitcoin
>>> bitcoin.get_keypair()
('L1o65mEUSCgopZUd6hndxqMSvkfvihXV7XmnYoAKt6hWimBXXt6t', '18fyV1xFCXaHXxdjbUnVDBLqFyVnFgrzm1')
>>> bitcoin.encrypt('L1o65mEUSCgopZUd6hndxqMSvkfvihXV7XmnYoAKt6hWimBXXt6t', 'foobar')
'6PYSL5VV8uTFCnCynVdSctyQzm6X2AEJZXG4XQvMu9Bngns2xMeb77JyXH'

Installation

You can install bitcoin-easy directly from Pypi using pip :

pip install bitcoin-easy

To use it from source, you need to install dependencies (see below for more details about dependencies) :

git clone https://github.com/darosior/bitcoineasy/ && cd bitcoin-easy
python3 -m venv venv
. venv/bin/activate
pip install py_ecc pycrypto scrypt requests

Dependencies

Examples

Generate a keypair (default is compressed public key and WIF encoded private key) :

kp = get_keypair()

If you want unencoded private key (diplayed as hex) and uncompressed public key :

kp = get_keypair(compressed=False, wif=False)

You can base58 or base58check encode raw bytes with :

base58_encode(data)
base58check_encode(data)

You can also check example.py which is a showcase of some functionalities provided by bitcoin-easy.

To do

  • P2SH
  • A better way to handle 0x00 prefix with base58check_decode()

Not finished yet, any remark or feature request are welcome