Bitcoin Forum
September 27, 2018, 10:26:23 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Identifying when new block is found on network  (Read 980 times)
nuggetbram
Full Member
***
Offline Offline

Activity: 330
Merit: 100



View Profile
September 23, 2014, 01:55:30 AM
 #1

I'm looking into controlling and/or reading the rpc-json output of bitcoin as a learning exercise. Is there a way to be notified of a new network block in the same way that cg or sgminer would output? I don't mind what language, as I've been using command line curl so far, but there obviously isn't a 'notifymeofanewblockinstantly' api call Smiley

A basic example to point me in the right direction would be excellent

thanks,

nuggetbram
1538087183
Hero Member
*
Offline Offline

Posts: 1538087183

View Profile Personal Message (Offline)

Ignore
1538087183
Reply with quote  #2

1538087183
Report to moderator
1538087183
Hero Member
*
Offline Offline

Posts: 1538087183

View Profile Personal Message (Offline)

Ignore
1538087183
Reply with quote  #2

1538087183
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538087183
Hero Member
*
Offline Offline

Posts: 1538087183

View Profile Personal Message (Offline)

Ignore
1538087183
Reply with quote  #2

1538087183
Report to moderator
1538087183
Hero Member
*
Offline Offline

Posts: 1538087183

View Profile Personal Message (Offline)

Ignore
1538087183
Reply with quote  #2

1538087183
Report to moderator
1538087183
Hero Member
*
Offline Offline

Posts: 1538087183

View Profile Personal Message (Offline)

Ignore
1538087183
Reply with quote  #2

1538087183
Report to moderator
-ck
Staff
Legendary
*
Offline Offline

Activity: 2660
Merit: 1143


Ruu \o/


View Profile WWW
September 23, 2014, 02:09:45 AM
 #2

See bitcoind's -blocknotify option.

Developer/maintainer for cgminer and ckpool/ckproxy.
ZERO FEE Pooled mining at ckpool.org, 1% Fee Solo mining at solo.ckpool.org
-ck
TheFootMan
Hero Member
*****
Offline Offline

Activity: 490
Merit: 500


View Profile
September 28, 2014, 09:38:40 PM
 #3

See bitcoind's -blocknotify option.

Yes, this is correct.

Assuming you use linux, run bitcoind, then in the configuration file (~/.bitcoin/bitcoin.conf) you could input something like:

blocknotify=/usr/myuser/scripts/block.sh %s

Then input whatever commands you want run in the script. The '%s' simply is the blockhash. So, every time your bitcoin daemon receives a new block, block.sh is run. Based on the blockhash, you could do all kinds of interesting stuff by using API-calls. Check this list: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

You can also use -walletnotify or walletnotify=/path/script %s in config file to run a command whenever you receive a transaction. I think it gets triggered for 0 and 1 conf for a tx. %s here being the txid.

Remember if you want to play around with this, that you do it on the testnet. Run bitcoind with -testnet switch. You could also use -addnode to add a testnet node. Google to find some active testnet nodes.

There are testnet faucets that will give you some testnet coins to play around with. You should use testnet because if you do something wrong, you do not lose money, and in addition you do not clutter the main chain with uncessary data. Imagine if every developer tested on the main chain..
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!