I run Bitcoin as a daemon on my laptop, and because building the GUI on stock Debian is a chore (and I guess I can't be bothered to take a look at the possible RPC-based frontends), I use bitcoin through RPC calls on the command line through a wrapper script I named
bitcoin (with the actual Bitcoin binaries living outside
PATH):
#!/bin/bash
set -e
# Avoid accidentally starting the server.
if [ "$#" -eq 0 ]; then
set help
fi
exec sudo sudo -u bitcoind ~bitcoind/bin/bitcoind "$@"
This of course makes a lot of assumptions about my system: that Bitcoin is restricted to the
bitcoind system account, the location of the binary, and so on. Adjust to suit your needs.
Reading the output of
listtransactions is not pleasant. More interesting to this topic and building upon the trivial
bitcoin script is a Python script I wrote to print transactions in a tabular format.
- BTC amounts are converted to USD in a separate column
- Separate actual and available account balances are tracked and printed (due to transaction confirmation and generation maturity times).
- The decimal point lines up correctly. Compare:
+9.87654321 -vs- +9.87654321
+1234.5 +1234.5
Example output:
Time Conf. Amt. BTC Bal. BTC Amt. USD Bal. USD
0 0
Initial balance
2011-06-10T20:28:38 15752 +0.52 0.52 +2.51 2.51
Received with 1GFiqyGUYpMxD2xummYMMXd2BEWyLTHom5
...snipped...
2011-06-29T02:23:57 11873 -1.62 0.01840998 -7.84 0.08
Sent to 1FEEwKSGutzbz5be3YE1mjjd3wCFCRognN
2011-06-29T02:23:57 11873 -0.001 0.01740998 -0.00 0.08
Fee for above transaction
...snipped...
2011-07-27T21:03:02 7273 +0.00009596 0.03053736 +0.00 0.14
Generated
0.03053736 0.14
Final balance
(Final/available balances combined to one line since in this case they are the same.)
There are some rough edges: the table formatting code is heinous, a request to MtGox is made on each execution for the exchange rate, there's currently no paging or limitation on the number of output rows, the fiat currency shown is hard-coded for USD (
get_mtgox_price()), and it assumes the presence of a
bitcoin command which takes RPC arguments and prints a JSON response (
bitcoin_request() could easily be adjusted to use a different command name, or to make a JSON-RPC request directly). Python 2.6 or higher (prior to 3) required.
If anyone is interested, the code is available here:
http://www.thoughtcrime.us/software/etc/bitcoin-transactions.py