Bitcoin Forum
November 18, 2024, 11:50:10 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoind and incoming blocks scanning  (Read 500 times)
scalaz (OP)
Newbie
*
Offline Offline

Activity: 15
Merit: 1


View Profile
March 10, 2016, 07:01:19 PM
Merited by ABCbits (1)
 #1

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!
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
March 10, 2016, 07:09:37 PM
Merited by ABCbits (2)
 #2

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.

scalaz (OP)
Newbie
*
Offline Offline

Activity: 15
Merit: 1


View Profile
March 10, 2016, 07:53:06 PM
 #3

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
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6886


Just writing some code


View Profile WWW
March 10, 2016, 08:25:47 PM
Last edit: March 10, 2016, 08:51:11 PM by knightdk
Merited by ABCbits (2)
 #4

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

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>
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.
Edit: It works.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!