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)
  ....
2
  • When you require 'bitcoin', what library are you referencing?
    – Nick ODell
    Commented Dec 6, 2015 at 6:34
  • Dear Nick it is bitcoin-ruby. Btw, it has been solved. Thank you for your kindenss:)
    – Toshi
    Commented Dec 6, 2015 at 7:40

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.