Bitcoin Forum
April 26, 2024, 04:56:00 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [ANN] blockfound - push notifications when your pool solves a block  (Read 1687 times)
Professoruss (OP)
Member
**
Offline Offline

Activity: 64
Merit: 10


View Profile
February 18, 2014, 01:23:55 AM
 #1

I just updated this so it works on all pools via blockchain, so I figured, might as well post it in here.
Hope someone can get some use out of it.
https://github.com/professoruss/blockfound

readme:

Blockfound will notify you when your pool finds a new block

Ruby
Support for Pushover - ios/android push notifications
Run via cron or irc bot
Data comes from blockchain.info API (or optionally slush API)
Version

2.0

Installation

gem install json
gem install yaml
git clone https://github.com/professoruss/blockfound.git
Command line options

--pool <Slush, BTC%Guild, Eligius> (Specify pool name from blockchain.info - use same case as https://blockchain.info/pools?timespan=24hrs, replace spaces with %20)
--oldschool (Get data from slush API instead of blockchain.info)
--output <cli, pushover> (specify the output, defaults to cli)
--help (uhh, help)
Run the damn thing!

output to console

ruby blockfound.rb --pool Slush
Push Notifications Via pushover

enter your token and user into the yaml file

cd blockfound
vim pushover.yaml
push notifications

ruby blockfound.rb --pool Slush --output pushover
Run via cron

* * * * * sleep 1 ;ruby blockfound/blockfound.rb --pool Slush --output pushover > /dev/null 2>&1

ZClassic Block Explorer|BTC: 1Hu6oYgiLeFySD9QjNs9vmDycC4bzWFsQo | LTC: MBHLcCcgq9wV1KtPPPA4egkWU839KCsgGq | ZEC: t1TtiE4yZjqpBSkzJWAS3jKB54t9fMQ9nm4 |ZCL: t1PSxBAKfvXK2EDJPwMQfsBWH4on94fULLV
1714150560
Hero Member
*
Offline Offline

Posts: 1714150560

View Profile Personal Message (Offline)

Ignore
1714150560
Reply with quote  #2

1714150560
Report to moderator
"With e-currency based on cryptographic proof, without the need to trust a third party middleman, money can be secure and transactions effortless." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714150560
Hero Member
*
Offline Offline

Posts: 1714150560

View Profile Personal Message (Offline)

Ignore
1714150560
Reply with quote  #2

1714150560
Report to moderator
1714150560
Hero Member
*
Offline Offline

Posts: 1714150560

View Profile Personal Message (Offline)

Ignore
1714150560
Reply with quote  #2

1714150560
Report to moderator
Professoruss (OP)
Member
**
Offline Offline

Activity: 64
Merit: 10


View Profile
February 18, 2014, 02:55:15 AM
 #2

also, open for suggestions for other types of notifications

ZClassic Block Explorer|BTC: 1Hu6oYgiLeFySD9QjNs9vmDycC4bzWFsQo | LTC: MBHLcCcgq9wV1KtPPPA4egkWU839KCsgGq | ZEC: t1TtiE4yZjqpBSkzJWAS3jKB54t9fMQ9nm4 |ZCL: t1PSxBAKfvXK2EDJPwMQfsBWH4on94fULLV
Professoruss (OP)
Member
**
Offline Offline

Activity: 64
Merit: 10


View Profile
February 18, 2014, 03:22:03 AM
 #3

Whoops, found a bug, i think i misinterpreted the api for blockchain.info

ZClassic Block Explorer|BTC: 1Hu6oYgiLeFySD9QjNs9vmDycC4bzWFsQo | LTC: MBHLcCcgq9wV1KtPPPA4egkWU839KCsgGq | ZEC: t1TtiE4yZjqpBSkzJWAS3jKB54t9fMQ9nm4 |ZCL: t1PSxBAKfvXK2EDJPwMQfsBWH4on94fULLV
Professoruss (OP)
Member
**
Offline Offline

Activity: 64
Merit: 10


View Profile
February 18, 2014, 03:37:53 AM
 #4

bug fixed

ZClassic Block Explorer|BTC: 1Hu6oYgiLeFySD9QjNs9vmDycC4bzWFsQo | LTC: MBHLcCcgq9wV1KtPPPA4egkWU839KCsgGq | ZEC: t1TtiE4yZjqpBSkzJWAS3jKB54t9fMQ9nm4 |ZCL: t1PSxBAKfvXK2EDJPwMQfsBWH4on94fULLV
dplusf
Sr. Member
****
Offline Offline

Activity: 258
Merit: 250


View Profile
February 19, 2014, 06:21:40 PM
 #5

I like your script and installed it and will test it.
But i think ill have to wait a bit since i am mining on P2Pool... :-)
Professoruss (OP)
Member
**
Offline Offline

Activity: 64
Merit: 10


View Profile
February 19, 2014, 10:09:39 PM
 #6

Well, I think I found another bug, it sometimes doesn't detect the new block when pulling from blockchain.  I'll need to look into it.

ZClassic Block Explorer|BTC: 1Hu6oYgiLeFySD9QjNs9vmDycC4bzWFsQo | LTC: MBHLcCcgq9wV1KtPPPA4egkWU839KCsgGq | ZEC: t1TtiE4yZjqpBSkzJWAS3jKB54t9fMQ9nm4 |ZCL: t1PSxBAKfvXK2EDJPwMQfsBWH4on94fULLV
dplusf
Sr. Member
****
Offline Offline

Activity: 258
Merit: 250


View Profile
February 20, 2014, 06:26:36 PM
 #7

Well, I think I found another bug, it sometimes doesn't detect the new block when pulling from blockchain.  I'll need to look into it.

i think i run into this bug. for testing i was using GHash.io, regardless i do not like centralised pools. script only found four blocks, one block was messaged to me three times.
maybe you want me to test something to get closer to the error?

another thing i would like to mention is if i switch to p2pool i ll get a error message:

blockfound.rb:86:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)

my command line looks like
Code:
ruby blockfound.rb --pool P2Pool
Professoruss (OP)
Member
**
Offline Offline

Activity: 64
Merit: 10


View Profile
February 20, 2014, 07:42:19 PM
 #8

I'll try to address these issues by the end of the week.  Work has me running around in quite a few directions this week, so I won't be able to dig into it until the weekend.

ZClassic Block Explorer|BTC: 1Hu6oYgiLeFySD9QjNs9vmDycC4bzWFsQo | LTC: MBHLcCcgq9wV1KtPPPA4egkWU839KCsgGq | ZEC: t1TtiE4yZjqpBSkzJWAS3jKB54t9fMQ9nm4 |ZCL: t1PSxBAKfvXK2EDJPwMQfsBWH4on94fULLV
dplusf
Sr. Member
****
Offline Offline

Activity: 258
Merit: 250


View Profile
February 20, 2014, 08:27:24 PM
 #9

No hurry.
Didnt know about the Pushover App until this thread, so thank you about that too! :-)
Professoruss (OP)
Member
**
Offline Offline

Activity: 64
Merit: 10


View Profile
February 20, 2014, 08:41:01 PM
 #10

No prob!

ZClassic Block Explorer|BTC: 1Hu6oYgiLeFySD9QjNs9vmDycC4bzWFsQo | LTC: MBHLcCcgq9wV1KtPPPA4egkWU839KCsgGq | ZEC: t1TtiE4yZjqpBSkzJWAS3jKB54t9fMQ9nm4 |ZCL: t1PSxBAKfvXK2EDJPwMQfsBWH4on94fULLV
edonkey
Legendary
*
Offline Offline

Activity: 1150
Merit: 1004



View Profile
March 18, 2015, 03:16:45 PM
 #11

Thanks for pulling this script together.

I'm trying to call it from Mac OS X Yosemite 10.10.2 and am getting the following error:

Code:
ruby blockfound.rb --pool Slush 
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:223:in `open_loop': redirection forbidden: http://blockchain.info/blocks/Slush?format=json -> https://blockchain.info/blocks/Slush?format=json (RuntimeError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:149:in `open_uri'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:689:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:34:in `open'
from blockfound.rb:83:in `<main>'

If I try to directly access the same URL (https://blockchain.info/blocks/Slush?format=json) from a browser, it works.

So I googled the problem and found this page:

http://stackoverflow.com/questions/10013293/open-uri-is-not-redirecing-http-to-https

I installed the open_uri_redirections gem, then made the minor mods to your script to allow redirections, and it works.

Here's the text of the patch, if you're interested:

Code:
*** ../blockfound/blockfound.rb	2015-03-18 07:40:34.000000000 -0700
--- blockfound.rb 2015-03-18 07:59:25.000000000 -0700
***************
*** 1,6 ****
--- 1,7 ----
  require 'rubygems'
  require 'json'
  require 'open-uri'
+ require 'open_uri_redirections'
  require 'yaml'
  require 'net/https'
  require 'optparse'
***************
*** 54,60 ****
    oldschool = res["oldschool"]
    if oldschool == true
      #slush specific
!     result = JSON.load(open("http://mining.bitcoin.cz/stats/json/"))
 
      #pool speed
      gh = result["ghashes_ps"]
--- 55,61 ----
    oldschool = res["oldschool"]
    if oldschool == true
      #slush specific
!     result = JSON.load(open("http://mining.bitcoin.cz/stats/json/", :allow_redirections => :safe))
 
      #pool speed
      gh = result["ghashes_ps"]
***************
*** 80,86 ****
      #clean up %20 if present
      pool_name = res["pool"]
      pool_name.gsub!('%20', ' ')
!     bc_pjson = JSON.load(open(bcurl))
      bc_latest_height = bc_pjson["blocks"][0]["height"]
      bc_latest_time = Time.at(bc_pjson["blocks"][0]["time"]).utc
      bc_second_time = Time.at(bc_pjson["blocks"][1]["time"]).utc
--- 81,87 ----
      #clean up %20 if present
      pool_name = res["pool"]
      pool_name.gsub!('%20', ' ')
!     bc_pjson = JSON.load(open(bcurl, :allow_redirections => :safe))
      bc_latest_height = bc_pjson["blocks"][0]["height"]
      bc_latest_time = Time.at(bc_pjson["blocks"][0]["time"]).utc
      bc_second_time = Time.at(bc_pjson["blocks"][1]["time"]).utc

Maybe an alternative simpler patch (which I didn't try) would be to change the URLs to https to avoid redirection.

Was I helpful?   BTC: 3G1Ubof5u8K9iJkM8We2f3amYZgGVdvpHr
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!