Cyberithub

How to Install pycoin(Bitcoin Client) on Linux (RHEL/Ubuntu/Rocky Linux)

Advertisements

In this article, I will take you through the steps to install pycoin (Bitcoin Client) on Linux (RHEL / Ubuntu / Rocky Linux). The Python library pycoin, originally written and maintained by Richard Kiss, is a Python-based library that supports manipulation of bitcoin keys and transactions, even supporting the scripting language enough to properly deal with nonstandard transactions. The pycoin library supports both Python 2 (2.7.x) and Python 3 (after 3.3), and comes with some handy command-line utilities, ku and tx. More on official website.

How to Install pycoin(Bitcoin Client) on Linux (RHEL/Ubuntu/Rocky Linux)

How to Install pycoin(Bitcoin Client) on Linux (RHEL / Ubuntu / Rocky Linux)

Also Read: How to Install Geth(Go Ethereum) on RHEL CentOS and Rocky Linux

Advertisements

Step 1: Prerequisites

a) You should have a running Linux (RHEL/Ubuntu/Rocky Linux) Server.

b) You should have python or python3 installed in your System.

Advertisements

c) You should have pip or pip3 utility available in your System.

d) You should have access to install Python library in your system.

Advertisements

 

Step 2: Install pycoin

If you have pip3 utility available in your System then you can install pycoin library by using pip3 install pycoin command as shown below.

[root@localhost ~]# pip3 install pycoin
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pycoin
Downloading https://files.pythonhosted.org/packages/ca/3e/7fb954bbda54d9995e3b52a93d6460cd5e4a5412202d6cec16f2a054ec67/pycoin-0.92.20220213.tar.gz (343kB)
100% |████████████████████████████████| 348kB 1.2MB/s
Installing collected packages: pycoin
Running setup.py install for pycoin ... done
Successfully installed pycoin-0.0.0

Alternatively, you can also choose to install the library by using python3 -m pip install pycoin command as shown below.

Advertisements
[root@localhost ~]# python3 -m pip install pycoin
Collecting pycoin
Downloading pycoin-0.92.20220213.tar.gz (343 kB)
|████████████████████████████████| 343 kB 340 kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: pycoin
Building wheel for pycoin (PEP 517) ... done
Created wheel for pycoin: filename=pycoin-0.92.20220213-py3-none-any.whl size=191434 sha256=2ef5f12d8bee7f85c75e269c2a168d292cc843991f58fb04329478f8975d87c2
Stored in directory: /root/.cache/pip/wheels/46/38/fd/bc8bff9eb85c07c849ae2a1c4f2150ef9f353e3964e6c8efbd
Successfully built pycoin
Installing collected packages: pycoin
Successfully installed pycoin-0.92.20220213

If you are looking to install some specific version of pycoin library then you need to pass that specific version as an argument to pip3 install command. For example, here we are installing version 0.1 using pip3 install pycoin==0.1 command as shown below.

root@cyberithub:~# pip3 install pycoin==0.1
Collecting pycoin==0.1
Downloading pycoin-0.1.tar.gz (19 kB)
Building wheels for collected packages: pycoin
Building wheel for pycoin (setup.py) ... done
Created wheel for pycoin: filename=pycoin-0.1-py3-none-any.whl size=25318 sha256=d1b0b6ba95d2047ccfe31be0ff7411a8bab56d51aace78003a97ba4de23ccc56
Stored in directory: /root/.cache/pip/wheels/c6/68/20/a973d71e7592983004acdb6ae58c1be493f0116be910353ee3
Successfully built pycoin
Installing collected packages: pycoin
Successfully installed pycoin-0.1

 

Step 3: Using pycoin library

Now that we have pycoin library installed and available we can think of using it in a sample python program to create a private key and get the corresponding address. Although below program does not generate a strong key but it still gives a good understanding of pycoin usage.

[root@localhost ~]# vi pycoin_example.py
from pycoin.symbols.btc import network

k = network.keys.private(secret_exponent=3) 
print(k.wif())
print(k.sec())
print(k.address())
print(k.address(is_compressed=False))

key = network.parse(k.wif())
print(key.address())

Output:-

[root@localhost ~]# python3 pycoin_example.py
KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn
b'\x02y\xbef~\xf9\xdc\xbb\xacU\xa0b\x95\xce\x87\x0b\x07\x02\x9b\xfc\xdb-\xce(\xd9Y\xf2\x81[\x16\xf8\x17\x98'
1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm
1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH

 

Step 4: Uninstall pycoin

Once you are done with pycoin library, you can choose to uninstall it from System using pip3 uninstall pycoin command as shown below.

[root@localhost ~]# pip3 uninstall pycoin
Uninstalling pycoin-0.0.0:
/usr/local/bin/b58
/usr/local/bin/block
/usr/local/bin/coinc
/usr/local/bin/keychain
/usr/local/bin/ku
/usr/local/bin/msg
/usr/local/bin/tx
/usr/local/lib/python3.6/site-packages/pycoin-0.0.0-py3.6.egg-info
/usr/local/lib/python3.6/site-packages/pycoin/__init__.py
/usr/local/lib/python3.6/site-packages/pycoin/__pycache__/__init__.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/pycoin/__pycache__/block.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/pycoin/__pycache__/bloomfilter.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/pycoin/__pycache__/intbytes.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/pycoin/__pycache__/merkle.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/pycoin/block.py
/usr/local/lib/python3.6/site-packages/pycoin/blockchain/BlockChain.py
/usr/local/lib/python3.6/site-packages/pycoin/blockchain/ChainFinder.py
/usr/local/lib/python3.6/site-packages/pycoin/blockchain/__init__.py
/usr/local/lib/python3.6/site-packages/pycoin/blockchain/__pycache__/BlockChain.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/pycoin/blockchain/__pycache__/ChainFinder.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/pycoin/blockchain/__pycache__/__init__.cpython-36.pyc
/usr/local/lib/python3.6/site-packages/pycoin/bloomfilter.py
/usr/local/lib/python3.6/site-packages/pycoin/cmds/__init__.py
..................................................
Proceed (y/n)? y
Successfully uninstalled pycoin-0.0.0

Leave a Comment