bitclient 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/bitclient/version.rb +1 -1
- data/lib/bitclient.rb +20 -18
- metadata +3 -2
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
== Simple interface to the Bitcoind JSON-RPC API
|
2
2
|
|
3
3
|
== How to use
|
4
|
-
bitclient = Bitclient.new(:username => "asd", :password => "dsa")
|
4
|
+
bitclient = Bitclient::Client.new(:username => "asd", :password => "dsa")
|
5
5
|
bitclient.get_balance # => 0.0000
|
6
6
|
bitclient.get_info # => {"version": ...}
|
data/lib/bitclient/version.rb
CHANGED
data/lib/bitclient.rb
CHANGED
@@ -3,25 +3,27 @@ require "httparty"
|
|
3
3
|
# https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
|
4
4
|
#
|
5
5
|
module Bitclient
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
class Client
|
7
|
+
def initialize(opts = {})
|
8
|
+
@url = opts[:url] || "http://localhost:8332"
|
9
|
+
@auth = {:username => opts[:username], :password => opts[:password]}
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
def method_missing(method, *args)
|
13
|
+
options = {
|
14
|
+
:body => {
|
15
|
+
:method => method.to_s.gsub(/\_/, ""),
|
16
|
+
:params => args
|
17
|
+
}.to_json,
|
18
|
+
:basic_auth => @auth,
|
19
|
+
:format => :json
|
20
|
+
}
|
21
|
+
res = HTTParty.post(@url, options).parsed_response
|
22
|
+
if res["error"]
|
23
|
+
raise Exception, res["error"]
|
24
|
+
else
|
25
|
+
res["result"]
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
metadata
CHANGED