block_io 1.0.8 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/README.md +2 -1
- data/block_io.gemspec +0 -2
- data/examples/basic.rb +11 -5
- data/lib/block_io.rb +17 -16
- data/lib/block_io/version.rb +1 -1
- metadata +26 -60
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7fc111ee1e745f444deeec8b30fa3c3b021fa8e
|
4
|
+
data.tar.gz: d124f3c04d871af2fad451df1488f8569303ff94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55794be8297122645d9b8b2b978c6377b3aba65b13b3fc155a810d455efc4e4326ac2283553f26e8c7c6bd55ca99bb8191877ad0ef663fcbc61c9b9168464a73
|
7
|
+
data.tar.gz: c05d90965618efe46d3e4dcee968503962fefd6f196ad34e8bc74fda971c11b16b641e6fa69287d0ae75fdbca848bb585aa83125cbf433880071eed014f3a41e
|
data/README.md
CHANGED
@@ -14,10 +14,11 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install block_io -v=1.0
|
17
|
+
$ gem install block_io -v=1.2.0
|
18
18
|
|
19
19
|
## Changelog
|
20
20
|
|
21
|
+
*06/25/18*: Remove support for Ruby < 1.9.3 (OpenSSL::Cipher::Cipher). Remove connection_pool dependency.
|
21
22
|
*01/21/15*: Added ability to sweep coins from one address to another.
|
22
23
|
*11/04/14*: Fix issue with nil parameters in an API call.
|
23
24
|
*11/03/14*: Reduce dependence on OpenSSL. PBKDF2 function is now Ruby-based. Should work well with Heroku's libraries.
|
data/block_io.gemspec
CHANGED
@@ -23,7 +23,5 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency "ecdsa", "~> 1.2", '>= 1.2.0'
|
24
24
|
spec.add_runtime_dependency "httpclient", "~> 2.8", '>= 2.8.0'
|
25
25
|
spec.add_runtime_dependency "oj", "~> 3.3", '>= 3.3.5'
|
26
|
-
spec.add_runtime_dependency "oj_mimic_json"
|
27
|
-
spec.add_runtime_dependency "connection_pool", "~> 2.2", '>= 2.2.1'
|
28
26
|
spec.add_runtime_dependency "pbkdf2-ruby", '~> 0.2', '>= 0.2.1'
|
29
27
|
end
|
data/examples/basic.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
# creates a new destination address, withdraws from the default label to it, gets sent transactions, and the current price
|
1
|
+
# creates a new destination address, withdraws from the default label to it, gets updated address balances, gets sent/received transactions, and the current price
|
2
|
+
#
|
3
|
+
# basic example: $ API_KEY=TESTNET_API_KEY PIN=YOUR_SECRET_PIN ruby basic.rb
|
4
|
+
# bundler example: $ API_KEY=TESTNET_API_KEY PIN=YOUR_SECRET_PIN bundle exec ruby basic.rb
|
5
|
+
#
|
6
|
+
# adjust amount below if not using the Dogecoin Testnet
|
2
7
|
|
3
8
|
require 'block_io'
|
4
9
|
|
5
|
-
|
6
|
-
puts BlockIo.set_options :api_key => 'YOURDOGECOINTESTNETAPIKEY', :pin => 'YOURSECRETPIN', :version => 2
|
10
|
+
puts BlockIo.set_options :api_key => ENV['API_KEY'], :pin => ENV['PIN'], :version => 2
|
7
11
|
|
8
12
|
begin
|
9
13
|
puts BlockIo.get_new_address(:label => 'testDest')
|
@@ -12,11 +16,13 @@ rescue Exception => e
|
|
12
16
|
puts e.to_s
|
13
17
|
end
|
14
18
|
|
15
|
-
puts BlockIo.withdraw_from_labels(:from_labels => 'default', :to_label => 'testDest', :amount => '
|
19
|
+
puts BlockIo.withdraw_from_labels(:from_labels => 'default', :to_label => 'testDest', :amount => '2.5')
|
16
20
|
|
17
|
-
puts BlockIo.
|
21
|
+
puts BlockIo.get_address_balance(:labels => 'default,testDest')
|
18
22
|
|
19
23
|
puts BlockIo.get_transactions(:type => 'sent') # API v2 only
|
20
24
|
|
25
|
+
puts BlockIo.get_transactions(:type => 'received') # API v2 only
|
26
|
+
|
21
27
|
puts BlockIo.get_current_price(:base_price => 'BTC')
|
22
28
|
|
data/lib/block_io.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'block_io/version'
|
2
2
|
require 'httpclient'
|
3
3
|
require 'oj'
|
4
|
-
require 'connection_pool'
|
5
4
|
require 'ecdsa'
|
6
5
|
require 'openssl'
|
7
6
|
require 'digest'
|
@@ -12,9 +11,10 @@ require 'base64'
|
|
12
11
|
module BlockIo
|
13
12
|
|
14
13
|
@api_key = nil
|
15
|
-
@base_url =
|
14
|
+
@base_url = nil
|
16
15
|
@pin = nil
|
17
16
|
@encryptionKey = nil
|
17
|
+
@client = nil
|
18
18
|
@conn_pool = nil
|
19
19
|
@version = nil
|
20
20
|
|
@@ -22,9 +22,15 @@ module BlockIo
|
|
22
22
|
# initialize BlockIo
|
23
23
|
@api_key = args[:api_key]
|
24
24
|
@pin = args[:pin]
|
25
|
+
|
25
26
|
@encryptionKey = Helper.pinToAesKey(@pin) if !@pin.nil?
|
26
27
|
|
27
|
-
|
28
|
+
hostname = args[:hostname] || "block.io"
|
29
|
+
@base_url = "https://" << hostname << "/api/VERSION/API_CALL/?api_key="
|
30
|
+
|
31
|
+
@client = HTTPClient.new
|
32
|
+
@client.tcp_keepalive = true
|
33
|
+
@client.ssl_config.ssl_version = :auto
|
28
34
|
|
29
35
|
@version = args[:version] || 2 # default version is 2
|
30
36
|
|
@@ -38,7 +44,6 @@ module BlockIo
|
|
38
44
|
if ['withdraw', 'withdraw_from_address', 'withdraw_from_addresses', 'withdraw_from_user', 'withdraw_from_users', 'withdraw_from_label', 'withdraw_from_labels'].include?(m.to_s) then
|
39
45
|
# need to withdraw from an address
|
40
46
|
self.withdraw(args.first, m.to_s)
|
41
|
-
|
42
47
|
elsif ['sweep_from_address'].include?(m.to_s) then
|
43
48
|
# need to sweep from an address
|
44
49
|
self.sweep(args.first, m.to_s)
|
@@ -128,17 +133,13 @@ module BlockIo
|
|
128
133
|
|
129
134
|
body = nil
|
130
135
|
|
131
|
-
@
|
132
|
-
# prevent initiation of HTTPClients every time we make this call, use a connection_pool
|
133
|
-
|
134
|
-
response = hc.post("#{@base_url.gsub('API_CALL',endpoint[0]).gsub('VERSION', 'v'+@version.to_s) + @api_key}", endpoint[1])
|
136
|
+
response = @client.post("#{@base_url.gsub('API_CALL',endpoint[0]).gsub('VERSION', 'v'+@version.to_s) + @api_key}", endpoint[1])
|
135
137
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
138
|
+
begin
|
139
|
+
body = Oj.load(response.body)
|
140
|
+
raise Exception.new(body['data']['error_message']) if !body['status'].eql?('success')
|
141
|
+
rescue
|
142
|
+
raise Exception.new('Unknown error occurred. Please report this.')
|
142
143
|
end
|
143
144
|
|
144
145
|
body
|
@@ -354,7 +355,7 @@ module BlockIo
|
|
354
355
|
response = nil
|
355
356
|
|
356
357
|
begin
|
357
|
-
aes = OpenSSL::Cipher
|
358
|
+
aes = OpenSSL::Cipher.new(cipher_type)
|
358
359
|
aes.decrypt
|
359
360
|
aes.key = Base64.strict_decode64(b64_enc_key)
|
360
361
|
aes.iv = iv if iv != nil
|
@@ -369,7 +370,7 @@ module BlockIo
|
|
369
370
|
|
370
371
|
# Encrypts a block of data given an encryption key
|
371
372
|
def self.encrypt(data, b64_enc_key, iv = nil, cipher_type = 'AES-256-ECB')
|
372
|
-
aes = OpenSSL::Cipher
|
373
|
+
aes = OpenSSL::Cipher.new(cipher_type)
|
373
374
|
aes.encrypt
|
374
375
|
aes.key = Base64.strict_decode64(b64_enc_key)
|
375
376
|
aes.iv = iv if iv != nil
|
data/lib/block_io/version.rb
CHANGED
metadata
CHANGED
@@ -1,155 +1,121 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: block_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atif Nazir
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ecdsa
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.2'
|
48
|
-
- -
|
48
|
+
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: 1.2.0
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- - ~>
|
55
|
+
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '1.2'
|
58
|
-
- -
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 1.2.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: httpclient
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - ~>
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '2.8'
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: 2.8.0
|
71
71
|
type: :runtime
|
72
72
|
prerelease: false
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - ~>
|
75
|
+
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '2.8'
|
78
|
-
- -
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: 2.8.0
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: oj
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - ~>
|
85
|
+
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '3.3'
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 3.3.5
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - ~>
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '3.3'
|
98
|
-
- -
|
98
|
+
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 3.3.5
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
|
-
name: oj_mimic_json
|
103
|
-
requirement: !ruby/object:Gem::Requirement
|
104
|
-
requirements:
|
105
|
-
- - '>='
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '0'
|
108
|
-
type: :runtime
|
109
|
-
prerelease: false
|
110
|
-
version_requirements: !ruby/object:Gem::Requirement
|
111
|
-
requirements:
|
112
|
-
- - '>='
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
version: '0'
|
115
|
-
- !ruby/object:Gem::Dependency
|
116
|
-
name: connection_pool
|
117
|
-
requirement: !ruby/object:Gem::Requirement
|
118
|
-
requirements:
|
119
|
-
- - ~>
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
version: '2.2'
|
122
|
-
- - '>='
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 2.2.1
|
125
|
-
type: :runtime
|
126
|
-
prerelease: false
|
127
|
-
version_requirements: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ~>
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '2.2'
|
132
|
-
- - '>='
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version: 2.2.1
|
135
101
|
- !ruby/object:Gem::Dependency
|
136
102
|
name: pbkdf2-ruby
|
137
103
|
requirement: !ruby/object:Gem::Requirement
|
138
104
|
requirements:
|
139
|
-
- - ~>
|
105
|
+
- - "~>"
|
140
106
|
- !ruby/object:Gem::Version
|
141
107
|
version: '0.2'
|
142
|
-
- -
|
108
|
+
- - ">="
|
143
109
|
- !ruby/object:Gem::Version
|
144
110
|
version: 0.2.1
|
145
111
|
type: :runtime
|
146
112
|
prerelease: false
|
147
113
|
version_requirements: !ruby/object:Gem::Requirement
|
148
114
|
requirements:
|
149
|
-
- - ~>
|
115
|
+
- - "~>"
|
150
116
|
- !ruby/object:Gem::Version
|
151
117
|
version: '0.2'
|
152
|
-
- -
|
118
|
+
- - ">="
|
153
119
|
- !ruby/object:Gem::Version
|
154
120
|
version: 0.2.1
|
155
121
|
description: This Ruby Gem is the official reference client for the Block.io payments
|
@@ -161,7 +127,7 @@ executables: []
|
|
161
127
|
extensions: []
|
162
128
|
extra_rdoc_files: []
|
163
129
|
files:
|
164
|
-
- .gitignore
|
130
|
+
- ".gitignore"
|
165
131
|
- Gemfile
|
166
132
|
- LICENSE
|
167
133
|
- README.md
|
@@ -183,17 +149,17 @@ require_paths:
|
|
183
149
|
- lib
|
184
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
151
|
requirements:
|
186
|
-
- -
|
152
|
+
- - ">="
|
187
153
|
- !ruby/object:Gem::Version
|
188
154
|
version: '0'
|
189
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
156
|
requirements:
|
191
|
-
- -
|
157
|
+
- - ">="
|
192
158
|
- !ruby/object:Gem::Version
|
193
159
|
version: '0'
|
194
160
|
requirements: []
|
195
161
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.6.11
|
197
163
|
signing_key:
|
198
164
|
specification_version: 4
|
199
165
|
summary: An easy to use Dogecoin, Bitcoin, Litecoin wallet API by Block.io. Sign up
|