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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad08d3e5bdd0f0c8efe3e233bf08d0dd3ec4237b68766d0a1b08965cd24aff79
4
- data.tar.gz: 5f66ea4a949376c7c1075bbd00b7de454cef939cc90961125ccb54bd5f106b7d
3
+ metadata.gz: a4848516d0cfacb59efa2e1be40d7e3d162ad2c4cd44fc82d1743fd5989517df
4
+ data.tar.gz: d353cd6b368b14bc36e9077067c8a20f3ea487654b9b40bb09b3c9230171bd3f
5
5
  SHA512:
6
- metadata.gz: 288fb5283f7b5d8b2f5c2812578cef7fdf8f368e146e3652bb2e7dc620208d75a83d2056a389ef1865b46d54faa1524352ccfa7c94c58140aa7b22d9b69ec57d
7
- data.tar.gz: 637cdfc9dd689f257cc4690cb753789cdb807d3a9dd4272ab7b2e79394eac7bf8aa7ae9910ad80fd2d1f07d67cad5fba4a501d8eae7dce51e6dc1d3cbd6d2556
6
+ metadata.gz: 2a39081e2d1c07902fd3bcb1d34973c61aa52f417dcb1b4cdfb1559387be2999e2a708a139e4de2f065988bc4241fa0bbe7bf2b0382bef47168c420c909bf594
7
+ data.tar.gz: b96385adb58e5a95d366c6f911fe8cdd849927fb0081131a5d7f9ac1a0ffb8521929d8658184da9a29439205835a2de00bd4d445c3a82b67624924a5d299016e
@@ -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 ||= user
10
- uri.password ||= pass
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 = { 'method' => method, 'params' => args, 'id' => 'jsonrpc' }.to_json
25
- response = Typhoeus.post(endpoint, body: post_body)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitcoiner
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
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.2
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-04-17 00:00:00.000000000 Z
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.3
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.