How to access bitcoin client from ruby using Rpc client?

0

I'd like to access local bitcoin node from ruby by using RPC client. The following is my code, and it returns the next code. Could you tell me how to call Bitcoin client on ruby?

#console    
NoMethodError (undefined method `getblockcount' for #<BitcoinRpc:0x007fe4e2577050>):


#product_controller.rb
require 'net/http'
require 'uri'
require 'json'
class BitcoinRpc
  def initialize(service_url)
    @uri = URI.parse(service_url)
  end
end

class ProductsController < ApplicationController
  require 'openassets'
  require 'bitcoin'
  include Bitcoin::Util
  include Bitcoin::Builder
  h = BitcoinRpc.new('http://'rpcuser':'rpcpassword'@localhost:8332')
  puts(h.getblockcount)
  ....

lalala

Posted 2015-12-06T03:21:26.703

Reputation: 251

When you require 'bitcoin', what library are you referencing?Nick ODell 2015-12-06T06:34:29.377

Dear Nick it is bitcoin-ruby. Btw, it has been solved. Thank you for your kindenss:)lalala 2015-12-06T07:40:05.517

Answers

0

I've solved the problem by changing the url as follows. http://'rpcuser':'rpcpassword'@127.0.0.1:8332'

lalala

Posted 2015-12-06T03:21:26.703

Reputation: 251