blockcypher-ruby 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/blockcypher/api.rb +25 -11
- data/spec/blockcypher/api_spec.rb +45 -21
- 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: dfbc37a64ab4a52a21b42e53205f82a3e714ec6b
|
4
|
+
data.tar.gz: 90369729738d15f05be790985b558d8d0684ea4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8eb9097474353ca1ab9918880cb1e02f406753af16717f26b3b20b8e2b578d8b901d534e9f079bdada946115355d6d5a77723ca7be091d442504d23cc421a98
|
7
|
+
data.tar.gz: 5f48d97c217b03ebb401b52f3d06aba9a248625a05631d3f650e0c87731f540adee7dca47b5f466e9dd73d9ba2f51b8a50e9ab9a8d39ce3562b897c0f65e425b
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Simply using rubygems:
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem 'blockcypher-ruby', '~> 0.2.
|
16
|
+
gem 'blockcypher-ruby', '~> 0.2.4', :require => 'blockcypher'
|
17
17
|
```
|
18
18
|
|
19
19
|
And then execute:
|
@@ -29,7 +29,7 @@ $ git clone https://github.com/blockcypher/ruby-client.git
|
|
29
29
|
$ cd ruby-client
|
30
30
|
$ bundle
|
31
31
|
$ gem build blockcypher-ruby.gemspec
|
32
|
-
$ gem install blockcypher-ruby-0.2.
|
32
|
+
$ gem install blockcypher-ruby-0.2.4.gem
|
33
33
|
```
|
34
34
|
|
35
35
|
## Initializing a client
|
data/lib/blockcypher/api.rb
CHANGED
@@ -179,29 +179,41 @@ module BlockCypher
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def address_details(address, unspent_only: false, limit: 50,
|
182
|
-
before: nil,
|
182
|
+
before: nil, after: nil, confirmations: nil,
|
183
|
+
omit_wallet_addresses: false, include_confidence:false)
|
183
184
|
query = {
|
184
185
|
unspentOnly: unspent_only,
|
185
186
|
limit: limit,
|
186
|
-
omitWalletAddresses: omit_wallet_addresses
|
187
|
+
omitWalletAddresses: omit_wallet_addresses,
|
188
|
+
includeConfidence: include_confidence
|
187
189
|
}
|
188
190
|
query[:before] = before if before
|
191
|
+
query[:after] = after if after
|
189
192
|
|
190
193
|
api_http_get('/addrs/' + address, query: query )
|
191
194
|
end
|
192
195
|
|
193
|
-
def address_balance(address)
|
194
|
-
|
196
|
+
def address_balance(address, omit_wallet_addresses: false)
|
197
|
+
query = { omitWalletAddresses: omit_wallet_addresses }
|
198
|
+
api_http_get('/addrs/' + address + '/balance', query: query)
|
195
199
|
end
|
196
200
|
|
197
|
-
def address_final_balance(address)
|
198
|
-
details = address_balance(address
|
201
|
+
def address_final_balance(address, omit_wallet_addresses: false)
|
202
|
+
details = address_balance(address,
|
203
|
+
omit_wallet_addresses: omit_wallet_addresses)
|
199
204
|
details['final_balance']
|
200
205
|
end
|
201
206
|
|
202
|
-
def address_full_txs(address, limit: 10, before: nil
|
203
|
-
|
207
|
+
def address_full_txs(address, limit: 10, before: nil, after: nil,
|
208
|
+
include_hex: false, omit_wallet_addresses: false, include_confidence:false)
|
209
|
+
query = {
|
210
|
+
limit: limit,
|
211
|
+
includeHex: include_hex,
|
212
|
+
omitWalletAddresses: omit_wallet_addresses,
|
213
|
+
includeConfidence: include_confidence
|
214
|
+
}
|
204
215
|
query[:before] = before if before
|
216
|
+
query[:after] = after if after
|
205
217
|
|
206
218
|
api_http_get("/addrs/#{address}/full", query: query)
|
207
219
|
end
|
@@ -219,9 +231,11 @@ module BlockCypher
|
|
219
231
|
api_http_get('/wallets/' + name)
|
220
232
|
end
|
221
233
|
|
222
|
-
def wallet_add_addr(name, addresses)
|
223
|
-
payload = { 'addresses' => Array(addresses)}
|
224
|
-
|
234
|
+
def wallet_add_addr(name, addresses, omit_wallet_addresses: false)
|
235
|
+
payload = { 'addresses' => Array(addresses) }
|
236
|
+
query = { omitWalletAddresses: omit_wallet_addresses }
|
237
|
+
api_http_post('/wallets/' + name + '/addresses',
|
238
|
+
json_payload: payload, query: query)
|
225
239
|
end
|
226
240
|
|
227
241
|
def wallet_get_addr(name)
|
@@ -3,16 +3,38 @@ require 'blockcypher'
|
|
3
3
|
module BlockCypher
|
4
4
|
|
5
5
|
describe Api do
|
6
|
-
let(:api)
|
6
|
+
let(:api) do
|
7
|
+
BlockCypher::Api.new({
|
8
|
+
api_token: 'testtoken',
|
9
|
+
currency: BlockCypher::BCY,
|
10
|
+
network: BlockCypher::TEST_NET,
|
11
|
+
version: BlockCypher::V1
|
12
|
+
})
|
13
|
+
end
|
7
14
|
|
8
|
-
|
9
|
-
|
15
|
+
context '#address_generate' do
|
16
|
+
it 'should generate new addresses' do
|
17
|
+
$addr1 = api.address_generate
|
18
|
+
$addr2 = api.address_generate
|
19
|
+
expect($addr1["address"]).to be_a(String)
|
20
|
+
expect($addr2["address"]).to be_a(String)
|
21
|
+
end
|
22
|
+
end
|
10
23
|
|
11
|
-
let(:
|
12
|
-
let(:
|
24
|
+
let(:address_1) { $addr1["address"].to_s }
|
25
|
+
let(:address_1_private_key) { $addr1["private"].to_s }
|
13
26
|
|
14
|
-
|
27
|
+
let(:address_2) { $addr2["address"].to_s }
|
28
|
+
let(:address_2_private_key) { $addr2["private"].to_s }
|
15
29
|
|
30
|
+
context '#faucet' do
|
31
|
+
it 'should fund a bcy test address with the faucet' do
|
32
|
+
res = api.faucet(address_1, 100000)
|
33
|
+
expect(res["tx_ref"]).to be_a(String)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context '#transaction_new' do
|
16
38
|
it 'should call the txs/new api' do
|
17
39
|
input_addresses = [address_1]
|
18
40
|
output_addresses = [address_2]
|
@@ -24,67 +46,69 @@ module BlockCypher
|
|
24
46
|
end
|
25
47
|
|
26
48
|
context '#transaction_sign_and_send' do
|
27
|
-
|
28
49
|
it 'should call txs/send api' do
|
29
|
-
|
30
|
-
|
31
|
-
output_addresses = [address_1]
|
50
|
+
input_addresses = [address_1]
|
51
|
+
output_addresses = [address_2]
|
32
52
|
satoshi_value = 10000
|
33
53
|
|
34
54
|
new_tx = api.transaction_new(input_addresses, output_addresses, satoshi_value)
|
35
|
-
res = api.transaction_sign_and_send(new_tx,
|
55
|
+
res = api.transaction_sign_and_send(new_tx, address_1_private_key)
|
36
56
|
expect(res["tx"]["hash"]).to be_a(String)
|
37
57
|
expect(res["tx"]["hash"].length).to be(64)
|
38
58
|
end
|
39
|
-
|
40
59
|
end
|
41
60
|
|
42
61
|
context '#address_final_balance' do
|
43
|
-
|
44
62
|
it 'should get the balance of an address' do
|
45
63
|
balance = api.address_final_balance(address_1)
|
46
64
|
expect(balance).to be_kind_of Integer
|
47
65
|
expect(balance).to be > 0
|
48
66
|
end
|
49
|
-
|
50
67
|
end
|
51
68
|
|
52
69
|
context '#create_forwarding_address' do
|
53
70
|
|
54
71
|
it 'creates a payment forward' do
|
55
|
-
forward_details = api.create_forwarding_address(address_1
|
72
|
+
forward_details = api.create_forwarding_address(address_1)
|
56
73
|
expect(forward_details["input_address"]).to be_a(String)
|
57
74
|
expect(forward_details["input_address"].length).to be(34) # Ok this isn't strictly true but..
|
58
75
|
end
|
59
76
|
|
60
77
|
it 'allows creating a payment forward with a callback' do
|
61
|
-
forward_details = api.create_forwarding_address(address_1,
|
78
|
+
forward_details = api.create_forwarding_address(address_1, callback_url: "http://test.com/foo")
|
62
79
|
expect(forward_details["callback_url"]).to eql("http://test.com/foo")
|
63
80
|
expect(forward_details["enable_confirmations"]).to be nil
|
64
81
|
end
|
65
82
|
|
66
83
|
it 'allows creating a payment forward with a callback and confirmation notifications enabled' do
|
67
|
-
forward_details = api.create_forwarding_address(address_1,
|
84
|
+
forward_details = api.create_forwarding_address(address_1, callback_url: "http://test.com/foo", enable_confirmations: true)
|
68
85
|
expect(forward_details["callback_url"]).to eql("http://test.com/foo")
|
69
86
|
expect(forward_details["enable_confirmations"]).to be true
|
70
87
|
end
|
71
88
|
|
72
89
|
it 'is possible to use the alias create_payments_forwarding' do
|
73
|
-
forward_details = api.create_payments_forwarding(address_1
|
90
|
+
forward_details = api.create_payments_forwarding(address_1)
|
74
91
|
expect(forward_details["input_address"]).to be_a(String)
|
75
92
|
end
|
76
93
|
|
77
94
|
end
|
78
95
|
|
79
96
|
context '#list_forwarding_addresses' do
|
80
|
-
|
81
97
|
it 'lists all forwading addresses created for a given token' do
|
82
|
-
forwarding_addresses = api.list_forwarding_addresses
|
98
|
+
forwarding_addresses = api.list_forwarding_addresses
|
83
99
|
expect(forwarding_addresses.first["destination"]).to eql(address_1)
|
84
100
|
end
|
85
|
-
|
86
101
|
end
|
87
102
|
|
103
|
+
context '#delete_forwarding_address' do
|
104
|
+
it 'deletes all previously created forwarding addresses' do
|
105
|
+
forwarding_addresses = api.list_forwarding_addresses
|
106
|
+
forwarding_addresses.each{|x| api.delete_forwarding_address(x["id"])}
|
107
|
+
forwarding_addresses = api.list_forwarding_addresses
|
108
|
+
expect(forwarding_addresses.any? == false)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
88
112
|
describe '#endpoint_uri' do
|
89
113
|
it 'should encode query into URI' do
|
90
114
|
uri = api.send(:endpoint_uri, '/path', { test: 42 }).to_s
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blockcypher-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CoinHako
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bitcoin-ruby
|
@@ -83,6 +83,20 @@ dependencies:
|
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: pry
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
86
100
|
description: Ruby library to help you build your crypto application on BlockCypher
|
87
101
|
email: contact@blockcypher.com
|
88
102
|
executables: []
|