pyspv - An extensible Python 3 Bitcoin SPV libraryWARNING: This is ALPHA software. USE AT YOUR OWN RISK.I've been working on this project for the past month and I finally feel that it's time to tell the community about it and ask for some constructive feedback. I'm also more than happy to accept code contributions
The goal of this project is to create a library that can be used with Bitcoin (and eventually altcoins) that makes it easy for you to develop applications, both client and server, without doing any of the tedious Blockchain/Network/Transaction programming. Integrating Bitcoin into your application is now literally a two line change to your code.
Features:
- SPV implementation, so relatively lightweight
- Written in Python, so useful for both server and user applications
- Multisignature support, can create, send to and spend multisignature payments
- Stealth address support, can create, send to and spend stealth address payments
- Tor/SOCKS support
- Testnet support
- Extensible payment monitor and transaction building system
- Completely modular, so you can initiate multiple SPV instances in the same application (This would allow for multiple alt-coin wallets)
The source comes with a sample RPC wallet called simple-wallet.py, you can launch it simply:
$ python3 examples/simple-wallet.py --testnet -v
The
README describes the full set of RPC commands available, but here is a small demonstration:
$ python3 examples/simple-wallet.py getnewstealthaddress
7orJaJ2A3iRh6NAwbCZt8GoKHWUzoiPdwwvsZPpoFX7mreLRAQYXzP1
...
$ python3 examples/simple-wallet.py sendtoaddress 7orJaJ2A3iRh6NAwbCZt8GoKHWUzoiPdwwvsZPpoFX7mreLRAQYXzP1 1.0
(The stealth address implementation was based on sx, so they should be fully compatible)$ python3 examples/simple-wallet.py genmultisig 1 2 0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71
{"address": "2MvM4RveSBwk3jwZV2Pe6avBFCYxUKgnDKi", "nreq": 1,
"redemption_script": "51210368b036cc3a4cc6187cb8d51ab25c71e9e98cd830df7f322174a8524f96d772b3210378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c7152ae",
"pubkeys": ["0368b036cc3a4cc6187cb8d51ab25c71e9e98cd830df7f322174a8524f96d772b3", "0378d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71"]}
...
$ python3 examples/simple-wallet.py sendtoaddress 2MvM4RveSBwk3jwZV2Pe6avBFCYxUKgnDKi 0.05
(simple-wallet will generate new keys if not enough are provided on the command-line)So, anyways. If you have time, try it out and let me know. Also, let me know if you end up using it in a project, I'd love to link to it from here.
TODO
* Namecoin support (I actually have this mostly working, but I need to implement AuxPOW for the new blocks)
* Once Namecoin works, I should be able to finish my P2P alt-chain trading code and help automate trades (see
https://en.bitcoin.it/wiki/Contracts#Example_5:_Trading_across_chains)
* BIP32 (HDW) and BIP38 (Encryption) support
* BIP70 (Payment protocol) support
* More altcoins? More payment monitors?
* CPU mining support (To aid in the creation of new alt-coins)
* Bug fixes
NOTE: Looks like there's a crash that happens between OpenSSL and Python when using 64-Bit Python build, so refrain from using 64-bit python for now. I'm looking into it.