blockchain 1.1.1 → 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/README.md +3 -0
- data/Rakefile +8 -0
- data/blockchain.gemspec +4 -2
- data/docs/createwallet.md +2 -1
- data/docs/wallet.md +2 -1
- data/lib/blockchain/createwallet.rb +6 -6
- data/lib/blockchain/util.rb +2 -2
- data/lib/blockchain/version.rb +1 -1
- data/lib/blockchain/wallet.rb +3 -10
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d95d10a7551162c4df9e3606b1193b24610e88c5
|
4
|
+
data.tar.gz: a60c0069e1a45759f003827ea14a180eb2035ed3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1eca5be6b204c074271055ec0d4946f83c5b833d28b11a67a3cfa7f5e61f067b95c1ff25cbf3fb6ab22794576032538ffb042f369d02168c75755dc971bb966
|
7
|
+
data.tar.gz: ec10af446b6dec13829788b80ebdbb986743865bbd7525b14514d3429bd6267d1b400cebcea197edea7889bdac1a2c344f7ccf3b0797a1d9d5fbc4623d7fc515
|
data/README.md
CHANGED
@@ -17,6 +17,8 @@ $ cd api-v1-client-ruby
|
|
17
17
|
$ rake install
|
18
18
|
```
|
19
19
|
|
20
|
+
To use the `wallet` and `createwallet` functionality, you'll also need an instance of [service-my-wallet][my-wallet].
|
21
|
+
|
20
22
|
The gem consists of the following functionality:
|
21
23
|
|
22
24
|
* `blockexplorer` ([docs](docs/blockexplorer.md)) ([api/blockchain_api][api1])
|
@@ -48,6 +50,7 @@ In order to prevent abuse some API methods require an API key approved with some
|
|
48
50
|
|
49
51
|
The same API key can be used to bypass the request limiter.
|
50
52
|
|
53
|
+
[my-wallet]: https://github.com/blockchain/service-my-wallet-v3
|
51
54
|
[api1]: https://blockchain.info/api/blockchain_api
|
52
55
|
[api2]: https://blockchain.info/api/create_wallet
|
53
56
|
[api3]: https://blockchain.info/api/exchange_rates_api
|
data/Rakefile
CHANGED
data/blockchain.gemspec
CHANGED
@@ -15,9 +15,11 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(
|
18
|
+
spec.test_files = spec.files.grep(%r{^(spec|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
24
|
+
|
25
|
+
end
|
data/docs/createwallet.md
CHANGED
@@ -7,6 +7,7 @@ Params:
|
|
7
7
|
```
|
8
8
|
password : str - password for the new wallet. At least 10 characters.
|
9
9
|
api_code : str - API code with the create wallets permission
|
10
|
+
url : str - URL for an instance of service-my-wallet
|
10
11
|
priv : str - private key to add to the wallet (optional, keyword)
|
11
12
|
label : str - label for the first address in the wallet (optional, keyword)
|
12
13
|
email : str - email to associate with the new wallet (optional, keyword)
|
@@ -16,5 +17,5 @@ Usage:
|
|
16
17
|
```ruby
|
17
18
|
require 'blockchain'
|
18
19
|
|
19
|
-
wallet = Blockchain::create_wallet('1234password', '58ck39ajuiw', label: 'Test wallet')
|
20
|
+
wallet = Blockchain::create_wallet('1234password', '58ck39ajuiw', 'http://localhost:3000/', label: 'Test wallet')
|
20
21
|
```
|
data/docs/wallet.md
CHANGED
@@ -6,6 +6,7 @@ Constructor params:
|
|
6
6
|
```
|
7
7
|
identifier : str
|
8
8
|
password : str
|
9
|
+
url : str
|
9
10
|
second_password : str (optional)
|
10
11
|
api_code : str (optional)
|
11
12
|
```
|
@@ -14,7 +15,7 @@ Usage:
|
|
14
15
|
```ruby
|
15
16
|
require 'blockchain'
|
16
17
|
|
17
|
-
wallet = Blockchain::Wallet.new('ada4e4b6-3c9f-11e4-baad-164230d1df67', 'password123')
|
18
|
+
wallet = Blockchain::Wallet.new('ada4e4b6-3c9f-11e4-baad-164230d1df67', 'password123', 'http://localhost:3000/')
|
18
19
|
```
|
19
20
|
|
20
21
|
####`send`
|
@@ -3,7 +3,7 @@ require_relative 'util'
|
|
3
3
|
|
4
4
|
module Blockchain
|
5
5
|
|
6
|
-
def self.create_wallet(password, api_code, priv: nil, label: nil, email: nil)
|
6
|
+
def self.create_wallet(password, api_code, url, priv: nil, label: nil, email: nil)
|
7
7
|
|
8
8
|
params = { 'password' => password, 'api_code' => api_code }
|
9
9
|
|
@@ -17,22 +17,22 @@ module Blockchain
|
|
17
17
|
params['email'] = email
|
18
18
|
end
|
19
19
|
|
20
|
-
response = Blockchain::call_api('api/v2/
|
20
|
+
response = Blockchain::call_api('api/v2/create', method: 'post', data: params, base_url: url)
|
21
21
|
json_response = JSON.parse(response)
|
22
22
|
return CreateWalletResponse.new(json_response['guid'],
|
23
23
|
json_response['address'],
|
24
|
-
json_response['
|
24
|
+
json_response['label'])
|
25
25
|
end
|
26
26
|
|
27
27
|
class CreateWalletResponse
|
28
28
|
attr_reader :identifier
|
29
29
|
attr_reader :address
|
30
|
-
attr_reader :
|
30
|
+
attr_reader :label
|
31
31
|
|
32
|
-
def initialize(identifier, address,
|
32
|
+
def initialize(identifier, address, label)
|
33
33
|
@identifier = identifier
|
34
34
|
@address = address
|
35
|
-
@
|
35
|
+
@label = label
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
data/lib/blockchain/util.rb
CHANGED
@@ -5,14 +5,14 @@ module Blockchain
|
|
5
5
|
class APIException < StandardError
|
6
6
|
end
|
7
7
|
|
8
|
-
BASE_URL =
|
8
|
+
BASE_URL = 'https://blockchain.info/'
|
9
9
|
TIMEOUT_SECONDS = 10
|
10
10
|
|
11
11
|
def self.call_api(resource, method: 'get', data: nil, base_url: nil)
|
12
12
|
base_url ||= BASE_URL
|
13
13
|
url = URI.parse(base_url + resource)
|
14
14
|
http = Net::HTTP.new(url.host, url.port)
|
15
|
-
http.use_ssl =
|
15
|
+
http.use_ssl = base_url.start_with? 'https://'
|
16
16
|
http.read_timeout = TIMEOUT_SECONDS
|
17
17
|
|
18
18
|
request = nil
|
data/lib/blockchain/version.rb
CHANGED
data/lib/blockchain/wallet.rb
CHANGED
@@ -5,11 +5,12 @@ module Blockchain
|
|
5
5
|
|
6
6
|
class Wallet
|
7
7
|
|
8
|
-
def initialize(identifier, password, second_password = nil, api_code = nil)
|
8
|
+
def initialize(identifier, password, url, second_password = nil, api_code = nil)
|
9
9
|
@identifier = identifier
|
10
10
|
@password = password
|
11
11
|
@second_password = second_password
|
12
12
|
@api_code = api_code
|
13
|
+
@url = url
|
13
14
|
end
|
14
15
|
|
15
16
|
def send(to, amount, from_address: nil, fee: nil, note: nil)
|
@@ -40,7 +41,7 @@ module Blockchain
|
|
40
41
|
params['note'] = note
|
41
42
|
end
|
42
43
|
|
43
|
-
response = Blockchain::call_api("merchant/#{@identifier}/#{method}", method: 'post', data: params)
|
44
|
+
response = Blockchain::call_api("merchant/#{@identifier}/#{method}", method: 'post', data: params, base_url: @url)
|
44
45
|
json_response = parse_json(response)
|
45
46
|
return PaymentResponse.new(
|
46
47
|
json_response['message'],
|
@@ -110,14 +111,6 @@ module Blockchain
|
|
110
111
|
return json_response['active']
|
111
112
|
end
|
112
113
|
|
113
|
-
def consolidate(days)
|
114
|
-
params = build_basic_request()
|
115
|
-
params['days'] = days
|
116
|
-
response = Blockchain::call_api("merchant/#{@identifier}/auto_consolidate", method: 'post', data: params)
|
117
|
-
json_response = parse_json(response)
|
118
|
-
return json_response['consolidated']
|
119
|
-
end
|
120
|
-
|
121
114
|
def build_basic_request()
|
122
115
|
params = { 'password' => @password }
|
123
116
|
if !@second_password.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blockchain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blockchain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
41
55
|
description: Blockchain API library (Ruby, v1)
|
42
56
|
email:
|
43
57
|
- support@blockchain.zendesk.com
|