SkillAgentSearch skills...

Pycoind

Pure-Python full node and libraries for bitcoind-based crypto-currencies (eg. bitcoin, litecoin, etc)

Install / Use

/learn @ricmoo/Pycoind
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

pycoind

A simple, pure-Python easy-to-setup-and-use full-node (soon) for bitcoin and any [most] altcoins based on the original bitcoind.

Features

  • A full network node (soon)
  • Single code base for multiple coins
  • Downloads the entire blockchain
  • Allow other peers to connect and download the blockchain
  • Zero dependencies beyond standard Python installation (see scrypt performance below)
  • 100% MIT/BSD licensed
  • Full BIP38 encrypted address and wallet
  • Separation of data directory and wallet

Currently Supported Coins

  • bitcoin
  • coinyecoin (dead?)
  • dogecoin
  • feathercoin
  • flappycoin
  • litecoin
  • mooncoin (dead?)
  • potcoin
  • zetacoin

To Do (coming soon...)

There are lots of things left to do. Expect the API to change frequently for now. Also, as each altcoin has slightly different and random "things" changed from the reference implementation, which means more functions will be added to the individual pycoind.coin classes to accomodate a wider selection of altcoins.

  • Full wallet API with Deterministic BIP32
  • Wallet UI
  • Checkpoints
  • UTXO database (requires checkpoints)
  • Become a fullnode; ie. support relaying (once checkpoints and UTXO databse is complete)
  • Full legacy command line support
  • Full legacy RPC support (use the original bitcoind rpc client with pycoind, or pycoind legacy_cli with the original bitcoind)
  • Bloom filters
  • Lots more coins (namecoin is highest on the list)
  • X11 based coins
  • Adaptive-N scrypt coins
  • Python 3 support
  • UI for sending transactions
  • ipv6 has been "implemented" but is untested... I need to set up a ipv6 network to test on.
  • more test cases (integrate all bitcoind test cases too)

Why is it not yet a full node?

A full node (should) verify all transactions before relaying them to peers. To verify transactions, each transaction input spends several unspent outputs (utxo), which must be verified. This requires storing a master database of all the UTXO's. While the database is implemented and seems to work, it is slow. Incredibly slow. So, first I wish to get checkpoints implemented, which will allow the UTXO database to populate much faster.

So, in short, the missing functionality is relay transactions to peers.

Motivation

I was quite interested in all that makes bitcoin tick, but the C++ bitcoind source code was a bit intimidating, having not used C++ since university; even in my best days of C++, it was not my go-to language for learning a new algorithm or protocol.

Of course, I first installed bitcoind to whet my appetite (after settling macport's tantrums with boost)... Then litecoind... dogecoind... Lather, rinse, repeat.

It was more work than I thought necessary, tweaking Makefiles, building, setting up and managing a completely separate code bases for a dozen coins, that were nearly identical except for a handful bytes.

So, I finally started pycoind, to bring all my full nodes into a single cohesive (ish) code base.

Application and Scripts

Several useful scipts are included that demonstrate this library, and should suffice for most users' needs.

Address Manipulation (pycoind-address)

This tool allows you to perform common functions to addresses, such as:

  • generate new private keys and addresses
  • dump all information about a private or public key
  • compress and decompress addresses' private keys and addresses
  • encrypt and decrypt private keys
  • generate printable BIP38 intermediate codes
  • generate BIP38 EC-multiply printed private keys from an intermediate code and confirm their confirmation codes
  • available in human readable or JSON output
  • supports all available coins

In general, passing in a passphrase or key on the command line is not secure. Leaving it blank will provide a secure (non-echoing) prompt for you to enter your passphrase or key.

Care should also be taken when displaying unencrypted private keys (ie. --show-private), as your terminal may have a scrollback buffer which would leave the keys visible long after using the utility. On OS X, alt-command-K will clear your scrollback.

usage: pycoind-address [--coin COINNAME] [--generate | --key [KEY]]
                       [--compress | --decompress] [--decrypt [PASSWORD]]
                       [--encrypt [PASSWORD]] [--intermediate [PASSWORD]]
                       [--lot LOT] [--sequence SEQUENCE]
                       [--generate-printed INTERMEDIATE_CODE]
                       [--confirm CONFIRM_CODE [PASSWORD]] [-h] [-v]
                       [--show-private] [--json]

Address Manipulation Tool

Address Options:
  --coin COINNAME       specify coin (default: bitcoin)
  --generate            generate a new address
  --key [KEY]           hex public key or wif private key *

Compression:
  --compress            compress the key
  --decompress          decompress the key

Encryption:
  --decrypt [PASSWORD]  use passsphrase to decrypt key *
  --encrypt [PASSWORD]  use passphrase to encrypt key *

Printed Addresses:
  --intermediate [PASSWORD]
                        generate an intermediate code for a passphrase *
  --lot LOT             set printed address lot number
  --sequence SEQUENCE   set printed address sequence number
  --generate-printed INTERMEDIATE_CODE
                        generate a printed address
  --confirm CONFIRM_CODE [PASSWORD]
                        confirm a printed address *

Output Formatting:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --show-private        show unencrypted private keys *
  --json                output in JSON

* Most terminals use a scrollback buffer, which can leave contents (such as
private keys and passphrases) visible long after using this utility. Make sure
you clear your scrollback and use the secure passphrase and key input when
possible, by omitting the passphrase or key from the command line.

Example: generate new addresses

Generate a compressed address:

/home/ricmoo> pycoind-address --generate --show-private
Address:     1AqGV68GPQVAZLtpRBkgRD5bC5V1xYavkD
Public Key:  03d24230984c42a2d733da5535abb6ac989ad709f0a231259207c5b90278983093
Compressed:  True
Private Key: L3PizuKXn5r8SVxhgXx5L5jKUa1uxC67e6ekUYhFDP8Xy7NJTzFX

Generate a decompressed address:

/home/ricmoo> pycoind-address --generate --show-private --decompress
Address:     137BJruaWcvS5YLGvX8ptTK1jRXVewzGHr
Public Key:  046fe1b3d42a5d73e0bc53d5d559f18bfe0a49193d19fdb4f50fdc8dc7f15344a5141b3a45e68b1a5f0284a76ff8bd6c30df21cbad1fb82cadd19e240836197f67
Compressed:  False
Private Key: 5KEBWFpYiZrb1sYZYTNvhHcVtfJ3nTA8XQzfb6SPVTmhfGBZ3Yi

Or, more securely, do not display the private key, instead encrypt it:

/home/ricmoo> pycoind-address --generate --encrypt
Passphrase: [typed foo]
Compressed:  True
Private Key: 6PYKQkjEsozH4JHnV4GQYTsAr3nt2ZVq3djWmY1MhewD8aK2gmtdEMNfRx

Example: compressed addresses

Decompress an address:

/home/ricmoo> pycoind-address --key L1e4vSqvTfFhc4NNDXr5gm4MmtMgZSDLGoz6rwBGtBSNSbkFBSMW --show-private --decompress
Address:     1MCwNzTdFX3dTCXY6MzryR8XtmQkStmxzo
Public Key:  043fd52cf96f079ef4520f989f7f6273cde1f18992967a7a0d72ac156e8f2baf1879b7f9d48ff27b04ddc8ca5d954319f5bfde9023c1ba7f178c29a42bb23b1590
Compressed:  False
Private Key: 5JpNHBqhCvyoMdZUv8tuGMQRC5PMk9RzqSbgqvWWt21JzwZBdZw

Compress an address:

/home/ricmoo> pycoind-address --key 5JpNHBqhCvyoMdZUv8tuGMQRC5PMk9RzqSbgqvWWt21JzwZBdZw --show-private --compress
Address:     1FhTqT8eFTk3uUoSKfevB7BKBTQdieMMVE
Public Key:  023fd52cf96f079ef4520f989f7f6273cde1f18992967a7a0d72ac156e8f2baf18
Compressed:  True
Private Key: L1e4vSqvTfFhc4NNDXr5gm4MmtMgZSDLGoz6rwBGtBSNSbkFBSMW

Example: change password from "foo" to "bar"

/home/ricmoo> pycoind-address --key 6PYMn7XkUgLhAmARM4BeayeyfycbZAyv7Lpwjk6jsNpLZNc7oRwnqd49H9 --decrypt foo --encrypt bar
Compressed:  True
Private Key: 6PYMn7XkTrBCRXEhwtnTEKGrHPRQiGdq4qS6tMMyAmfdZhcBCVmNVpnYf9

Or, Using secure input: (note that what you type will not be echoed to the terminal)

/home/ricmoo> pycoind-address --key --decrypt --encrypt 
Key: [typed 6PYMn7XkUgLhAmARM4BeayeyfycbZAyv7Lpwjk6jsNpLZNc7oRwnqd49H9]
Passphrase: [typed foo]
Passphrase: [typed bar]
Compressed:  True
Private Key: 6PYMn7XkTrBCRXEhwtnTEKGrHPRQiGdq4qS6tMMyAmfdZhcBCVmNVpnYf9

Node Management (pycoind-node)

This tool starts a pycoind full node, which will connect to other nodes to synchronize and maintain a local copy of the blockchain.

/home/ricmoo> pycoind-node --help
usage: pycoind-node [--coin COINNAME] [--data-dir DIRECTORY] [--no-init]
                    [--background] [--bind ADDRESS] [--port PORT]
                    [--no-listen] [--max-peers COUNT] [--seek-peers COUNT]
                    [--connect ADDRESS[:PORT] [ADDRESS[:PORT] ...]]
                    [--no-dns-lookup] [--no-bootstrap] [-h] [--version]
                    [--debug]

Node Management Tool

Node Options:
  --coin COINNAME       specify coin (default: bitcoin)
  --data-dir DIRECTORY  database directory (default: ~/.pycoind/data)
  --no-init             do not create data-dir if missing
  --background          run the node in the background

Network:
  --bind ADDRESS        Use specific interface (default: 127.0.0.1)
  --port PORT           port to connect on (default: coin specific)
  --no-listen           do not accept incoming connections

Peer Discovery:
  --max-peers COUNT     maximum connections to allow (default: 125)
  --seek-peers COUNT    number of peers to seek out (default: 16)
  --connect ADDRESS[:PORT] [ADDRESS[:PORT] ...]
                        specify peer addresses
  --no-dns-lookup       do not attempt to resolve DNS names for connect
  --no-bootstrap        do 
View on GitHub
GitHub Stars119
CategoryDevelopment
Updated6mo ago
Forks41

Languages

Python

Security Score

87/100

Audited on Sep 26, 2025

No findings