I am a newbie for "bitcoin-ruby" to parse bitcoin blockchain data and found comparatively
easier to understand than other parsers. But while testing it, I am having issues to make some bitcoin-cli commands to get this to work. Here are the codes I am using to parse the data :
I am sharing the installation environment and versions I have tried till now.
Please give your expert guidelines how to fix the issue.
Ruby_bitcoin Sheet (1).docx
I am a newbie for "bitcoin-ruby" to parse bitcoin blockchain data and found comparatively easier to understand than other parsers. But while testing it, I am having issues to make some bitcoin-cli commands to get this to work. Here are the codes I am using to parse the data :
require 'bitcoin' require 'net/http' require 'json' RPCUSER = "" RPCPASSWORD =""
HOST = "localhost" PORT= 8332
def bitcoinRPC(method,param) http = Net::HTTP.new(HOST,PORT) request = Net::HTTP::Post.new('/') request.basic_auth(RPCUSER,RPCPASSWORD) request.content_type = 'application/json' request.body = {method: method, param: param, id: 'jsonrpc'}.to_json JSON.parse(http.request(request).body)["result"] end
The following client commands are working :
bitcoinRPC("help",[])
bitcoinRPC("getnewaddress",[])
bitcoinRPC("getchaintips",[])
But following returns "nil" vale :
bid = "0000000000000000004bd4aff1966f6df18b1dba6f6ef83a878e526ab31eee73" bitcoinRPC("getblock",[bid])
I am sharing the installation environment and versions I have tried till now. Please give your expert guidelines how to fix the issue. Ruby_bitcoin Sheet (1).docx
Thanks in advance for your kind help.