Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: darkskiez on July 15, 2010, 07:19:57 PM



Title: Request: Set the destination pubkey for bitcoind generation
Post by: darkskiez on July 15, 2010, 07:19:57 PM

I'd like to run some bitcoin daemons unattended, and have them generate the blocks but with a predefined public key, rather than a fresh one, so i don't have to check them manually / transfer coins manually.

I have made do for the moment with a cron job that attempts to send 50 every hour :)



Title: Re: Request: Set the destination pubkey for bitcoind generation
Post by: laszlo on July 15, 2010, 07:36:17 PM
The JSON-RPC interface can be used to query the balance and send it. Try something similar to this.. this will also start bitcoind if it's not running already.  You can run this every few hours from cron.

Code:
#!/bin/bash

NICE=/bin/nice
BITCOIN=/home/solar/bitcoin/bitcoind

ADDR=1XPTgDRhN8RFnzniWCddobD9iKZatrvH4
NODE=192.75.207.66

date

${BITCOIN} getbalance 2>&1 | while read balance;
do
  if [ "${balance}" == "0.000000000000000" ];
  then
    echo "zero balance";
  elif [ "${balance}" == "error: couldn't connect to server" ];
  then
    echo "server not running, starting...";
    ${NICE} -n 19 ${BITCOIN} -daemon -addnode=${NODE}
  else
    echo "sending ${balance} BTC to ${ADDR}"
    ${BITCOIN} sendtoaddress ${ADDR} ${balance};
  fi
done


Title: Re: Request: Set the destination pubkey for bitcoind generation
Post by: lachesis on July 15, 2010, 08:03:49 PM
That's not a terrible idea, though. A better low level interface to the generation and transaction spec would be nice.


Title: Re: Request: Set the destination pubkey for bitcoind generation
Post by: laszlo on July 15, 2010, 09:49:06 PM
To extend on this you can connect to the remote host and request a new key before you send, as right now that reuses the same address over and over.

To connect to the remote server and get an address you could set up pubkey auth with ssh and do something like this : ssh solar@eclipse.heliacal.net bitcoin/bitcoind getnewaddress