Class: Btc::Rpc

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/btc/rpc.rb

Class Method Summary collapse

Class Method Details

.query(method, params, settings) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/btc/rpc.rb', line 8

def query(method, params, settings)
  auth = {
    :username => settings[:username],
    :password => settings[:password]
  }

  options = {
    :method => method, 
    :jsonrpc => "2.0", 
    :id => randid, 
    :params => params, 
    :basic_auth => auth
  }

  begin
    post(settings[:url], options)
  rescue Errno::ECONNREFUSED
    raise Btc::DaemonError
  end
end

.randidObject



29
30
31
# File 'lib/btc/rpc.rb', line 29

def randid
  (rand * 10 ** 12).to_i.to_s
end