Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Latest commit

 

History

History
67 lines (62 loc) · 2.51 KB

README.textile

File metadata and controls

67 lines (62 loc) · 2.51 KB

BitcoinDroid is a thin Android client for Bitcoin. It relies on a headless Bitcoin server running somewhere. The server must use the standard Bitcoin RPC API and accept SSL connections, e.g. via stunnel.

For reference, here’s a possible way to set up your server:

1. I created a startup script, /etc/init.d/bitcoind-ssl. It looks like this:


#!/bin/sh -e
[ -x /usr/local/bin/bitcoind ] || exit 0
. /lib/lsb/init-functions
. /etc/default/rcS
PORT=38976
USER=username
case "$1" in
start)
log_begin_msg "Starting bitcoind…"
su $USER -c ~$USER/bin/bcstart
/usr/bin/stunnel -d $PORT -r 8332
;;
stop)
log_begin_msg "Stopping bitcoind…"
su $USER -c ~$USER/bin/bcstop
echo Waiting for server to shutdown cleanly…
sleep 2
fuser -n tcp $PORT -k
;;
restart|force-reload)
su $USER -c ~$USER/bin/bcstop
echo Waiting for server to shutdown cleanly…
sleep 2
fuser -n tcp $PORT -k
su $USER -c ~$USER/bin/bcstart
/usr/bin/stunnel -d $PORT -r 8332
;;
status)
su $USER -c ~$USER/bin/bcstatus
;;
*)
echo "Usage: /etc/init.d/bitcoind-ssl {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0

2. I made three scripts in ~/bin, bcstart, bcstop, and bcstatus. The names are pretty descriptive. These scripts contain my password but are only readable by me and root, so that’s relatively safe (esp. since I’m root).

3. I scheduled the init script to start at boot-time. You can do something like sudo update-rc.d bitcoind-ssl defaults.

And, just for completeness, I use logrotate to simultaneously rotate my bitcoin logs and do staggered backups of my wallet. Here is logrotate.conf, which can be scheduled in cron (“0 1 * * * /usr/sbin/logrotate —state /home/username/.bitcoin/logrotate.state /home/username/.bitcoin/logrotate.conf”):


/home/username/.bitcoin/debug.log{
rotate 5
prerotate
/home/username/bin/bcstop
sleep 3
cp ~/.bitcoin/wallet.dat.4 ~/.bitcoin/wallet.dat.5
cp ~/.bitcoin/wallet.dat.3 ~/.bitcoin/wallet.dat.4
cp ~/.bitcoin/wallet.dat.2 ~/.bitcoin/wallet.dat.3
cp ~/.bitcoin/wallet.dat.1 ~/.bitcoin/wallet.dat.2
cp ~/.bitcoin/wallet.dat ~/.bitcoin/wallet.dat.1
endscript
compress
postrotate
/home/username/bin/bcstart
endscript
}