Title: Bitcoind and incoming blocks scanning Post by: scalaz on March 10, 2016, 07:01:19 PM Hello!
Want to scan incoming blocks with native bitcoind client. Could you please clarify 1. Can I connect to the bitcoind "pipe line with incoming blocks" 2. How can I process "parse" data blocks ? any libraries, solutions ? 3. Any advice how to make it KISS ? Thanks! Title: Re: Bitcoind and incoming blocks scanning Post by: achow101 on March 10, 2016, 07:09:37 PM You can use the -blocknotify=<cmd> option to run a command every time a new block is received. The command can just be a bash script which can then get the block hash and look up the block through bitcoin-cli and get the JSON to parse it.
Title: Re: Bitcoind and incoming blocks scanning Post by: scalaz on March 10, 2016, 07:53:06 PM Sorry, no so clear.
Do you mean run client like this ? sudo bin/bitcoind -datadir=.bitcoin -port=88888 -rpcport=99999 -rpcallowip=127.0.0.1 -rpcuser=bitcoinrpc -rpcpassword=password -blocknotify Any examples ? Thanks Title: Re: Bitcoind and incoming blocks scanning Post by: achow101 on March 10, 2016, 08:25:47 PM Sorry, no so clear. Kinda. So you would run Bitcoind like this bitcoind -datadir=.bitcoin -port=88888 -rpcport=99999 -rpcallowip=127.0.0.1 -rpcuser=bitcoinrpc -rpcpassword=password -blocknotify=<cmd>Do you mean run client like this ? sudo bin/bitcoind -datadir=.bitcoin -port=88888 -rpcport=99999 -rpcallowip=127.0.0.1 -rpcuser=bitcoinrpc -rpcpassword=password -blocknotify Any examples ? Thanks where <cmd> is whatever command you want to run whenever you receive a block. An Example: bitcoind -datadir=.bitcoin -port=88888 -rpcport=99999 -rpcallowip=127.0.0.1 -rpcuser=bitcoinrpc -rpcpassword=password -blocknotify="bitcoin-cli getblock %s > block-%s.txt" %s in the command is replaced by the block hash automatically by this flag so you would literally have %s in the command wherever you need to have the block hash. I think that should work, although I am testing it right now and will get back to you when that runs. |