Package: piggies
PiggiesWhat is Piggies?Piggies is a package to automatically manage your cryptocurrencyhot walletsusing Python.It works by launching the wallets usingpexpect, and communicating with them via RPC.The requirement to be automatic:eliminates hardware wallets (you would need to check the addresses and push the button)makes it more dangerous, because there might be security vulnerabilities in the softwareI'm doing this because some people (including myself) still want automatic wallets (i.e. for their exchange websites accepting coins and withdrawals); however:oneshould not hold their cryptocurrencies on an exchangeone should not trustany closed-source multiwalletone should not even trustan open source web wallet.Hence this tool to help you live in the plumbing age of crypto :)Security risksMake sure not toexpose the RPC ports you're using to attackers.Do your own security research (and please share findings!)PracticeOPSEC.I am not responsible if you lose your money.InstallingPiggies is available on PyPI. You can install it via:pip3 install piggiesor via:python3 -m pip install piggiesRunningThis is a basic demo for Ethereum: it starts/usr/bin/parityon the configureddatastore_path.#!/usr/bin/env python3importloggingfrompiggiesimportPiggyETHlogger=logging.getLogger('piggy_logs')defmain():piggy=PiggyETH(wallet_bin_path='/usr/bin/parity',datastore_path='datastores/ETH',wallet_password='your_ETH_wallet_password_here')piggy.start_server()print("Balance:",piggy.get_balance())print("Suggested miner fee:",piggy.suggest_miner_fee())piggy.stop_server()if__name__=='__main__':logger.addHandler(logging.StreamHandler())logger.setLevel(logging.INFO)main()For a more advanced demo, includingMasterPiggy, check outdemo.py.Supported operationsI wanted a consistent way to use various cryptocurrencies. The supported operations are:Starting and stopping the wallet RPC serversRetrieving the balanceRetrieving an address to receive fundsRetrieving recent incoming transactionsSuggesting a miner feePerforming a transaction with specified amount to send, and specified miner feeThe operations are available for bothMasterPiggyand for the wallets individually (PiggyBTC,PiggyETH...)Supported walletsElectrum (BTC)For Bitcoin, I decided to useElectruminstead of the official Bitcoin client. This is because of two reasons:it seems impossible to precisely specify the amount and fee to send, with the official clientElectrum lets you offload computation to Electrum Servers (albeit at a risk of centralizing the Bitcoin network).Monero (XMR)Monero is supported via itsofficial client(requires you to sync the blockchain).
Note: In case something goes wrong when executing commands, and the calls hang or timeout, check the following:Make sure you have the latest blockchain.Time: since you start the daemon for the first time, it takes two days or soSpace: takes around ~55GB right nowLook at the wallet log, created by Monero next to the binaries.Look at the daemon log, usually in the datastore directory at top-level.Wait a little (should not be more than 30 seconds though), especially when performing a transaction or asking for a transaction fee estimate.Try loading the same wallet with monero-wallet-cli, and see what happens. New wallets have to refresh from the blockchain, and we don't do that automatically yet.Parity (ETH)I support Ethereum viaParity, due to its flexibility with blockchain options.Oncegas estimation works in the light client, we will use it. But right now the light client is experimental, and that specific query didn't seem to work for me on the main Ethereum network.We also send the log to the datastore directory for ETH.We don't check wallet version compatibility here, because this is handled by Web3.pyso well that you can even use different clients.The connection to Parity is via IPC, not HTTP, so we use whatever node is running on thedatastore_path, and there is no need for further settings (ports and such). It is also somewhat more secure.Fortransactions_since, we usean external servicedue to it being impractical to do. This has some caveats (see the docs for ETHtransactions_since). In the future, we might integrateQuickBlocksto avoid these caveats.OthersI might support Litecoin, Bitcoin Cash, ZCash and other distributed currencies, but I don't know for sure.
I consider Ripple and Stellar too centralized, however will review PRs for them or any other currency, if you want to support them yourself.TestingTo perform tests, run./setup.py test.FeedbackAll feedback is welcome.I especially welcome any ideas/problems about security, or about how to do testing.
If you can think of a way for usingHypothesishere, that would be excellent!To disclose something privately (i.e, security vulnerabilities), send me an e-mail atdanuthaiduc (monkeytail) gmail (period) com.Feel free to use GitHub issues, or even open a pull request, for non-security issues!