bitcoiner 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bitcoiner/client.rb +18 -6
- data/lib/bitcoiner/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4848516d0cfacb59efa2e1be40d7e3d162ad2c4cd44fc82d1743fd5989517df
|
4
|
+
data.tar.gz: d353cd6b368b14bc36e9077067c8a20f3ea487654b9b40bb09b3c9230171bd3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a39081e2d1c07902fd3bcb1d34973c61aa52f417dcb1b4cdfb1559387be2999e2a708a139e4de2f065988bc4241fa0bbe7bf2b0382bef47168c420c909bf594
|
7
|
+
data.tar.gz: b96385adb58e5a95d366c6f911fe8cdd849927fb0081131a5d7f9ac1a0ffb8521929d8658184da9a29439205835a2de00bd4d445c3a82b67624924a5d299016e
|
data/lib/bitcoiner/client.rb
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
module Bitcoiner
|
4
4
|
class Client
|
5
|
-
attr_accessor :endpoint
|
5
|
+
attr_accessor :endpoint, :username, :password
|
6
6
|
|
7
7
|
def initialize(user, pass, host)
|
8
8
|
uri = Addressable::URI.heuristic_parse(host)
|
9
|
-
uri.user
|
10
|
-
uri.password
|
9
|
+
self.username = uri.user || user
|
10
|
+
self.password = uri.password || pass
|
11
|
+
uri.user = uri.password = nil
|
12
|
+
|
11
13
|
self.endpoint = uri.to_s
|
12
14
|
end
|
13
15
|
|
@@ -21,15 +23,25 @@ module Bitcoiner
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def request(method, *args)
|
24
|
-
post_body = {
|
25
|
-
|
26
|
+
post_body = {
|
27
|
+
'method' => method,
|
28
|
+
'params' => args,
|
29
|
+
'id' => 'jsonrpc'
|
30
|
+
}.to_json
|
31
|
+
|
32
|
+
response = Typhoeus.post(
|
33
|
+
endpoint,
|
34
|
+
userpwd: [username, password].join(":"),
|
35
|
+
body: post_body,
|
36
|
+
)
|
37
|
+
|
26
38
|
response_hash = parse_body(response)
|
27
39
|
raise JSONRPCError, response_hash['error'] if response_hash['error']
|
28
40
|
response_hash['result']
|
29
41
|
end
|
30
42
|
|
31
43
|
def inspect
|
32
|
-
"#<Bitcoiner::Client #{endpoint.inspect} >"
|
44
|
+
"#<Bitcoiner::Client #{endpoint.inspect} #{username}:#{password} >"
|
33
45
|
end
|
34
46
|
|
35
47
|
class JSONRPCError < RuntimeError; end
|
data/lib/bitcoiner/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitcoiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryce Kerley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.7.
|
152
|
+
rubygems_version: 2.7.7
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Control the bitcoin nework client over JSON-RPC.
|