Sha256: 7d9faab13bc84970c7004f61441144b562e6c02b9a558243c0e66e191e80b8c6
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
require 'rest_client' class Bitcoin::RPC def initialize(options) @user, @pass = options[:user], options[:pass] @host, @port = options[:host], options[:port] @ssl = options[:ssl] end def credentials if @user "#{@user}:#{@pass}" else nil end end def service_url url = @ssl ? "https://" : "http://" url.concat "#{credentials}@" if c = credentials url.concat "#{@host}:#{@port}" url end def dispatch(request) respdata = RestClient.post service_url, request.to_post_data response = JSON.parse(respdata) raise Bitcoin::Errors::RPCError, response['error'] if response['error'] response['result'] end private def symbolize_keys(hash) case hash when Hash hash.inject({}) do |result, (key, value)| key = key.to_sym if key.kind_of?(String) value = symbolize_keys(value) result[key] = value result end when Array hash.collect do |ele| symbolize_keys(ele) end else hash end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
ramontayag-bitcoin-client-0.1.0 | lib/bitcoin/rpc.rb |
bitcoin-client-0.0.1 | lib/bitcoin/rpc.rb |