Class: Bitcoind::Client
- Inherits:
-
Object
- Object
- Bitcoind::Client
- Defined in:
- lib/bitcoind/client.rb
Instance Method Summary collapse
- #accounts ⇒ Object
- #balance ⇒ Object
-
#initialize(user, pass) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
- #request(method, *args) ⇒ Object
Constructor Details
#initialize(user, pass) ⇒ Client
Returns a new instance of Client.
3 4 5 |
# File 'lib/bitcoind/client.rb', line 3 def initialize(user, pass) @endpoint = "http://#{user}:#{pass}@localhost:8332" end |
Instance Method Details
#accounts ⇒ Object
11 12 13 14 |
# File 'lib/bitcoind/client.rb', line 11 def accounts balance_hash = request 'listaccounts' AccountHash.new self, balance_hash end |
#balance ⇒ Object
7 8 9 |
# File 'lib/bitcoind/client.rb', line 7 def balance request 'getbalance' end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/bitcoind/client.rb', line 24 def inspect "#<Bitcoind::Client #{@endpoint.inspect} >" end |
#request(method, *args) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/bitcoind/client.rb', line 16 def request(method, *args) body = { 'id'=>'jsonrpc', 'method'=>method} body['params'] = args unless args.empty? response_json = RestClient.post @endpoint, body.to_json response = JSON.parse response_json return response['result'] end |