blockcypher-ruby 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ee649063cde0162f14040bafc09e2d1a7cbb6dc
4
- data.tar.gz: 0f44d0d0fe1f91010a47799ca41bd171c64f5ff6
3
+ metadata.gz: dfbc37a64ab4a52a21b42e53205f82a3e714ec6b
4
+ data.tar.gz: 90369729738d15f05be790985b558d8d0684ea4a
5
5
  SHA512:
6
- metadata.gz: a06ce90d9d766498e367aec48c8933457862ba637deeb72a9da696a411e54fbff830f5a1cdadd2980d364bcc2c49fa6a20897acf712a997b740e5cf5d84ab0aa
7
- data.tar.gz: 94f82dea7f64bb80b08a5ab3e2ac47ea9e1d207e89ab9cb5872ce4fa590e0ebaca02d71bab893c44edf87b8f67b8fdf10d9c1cac4a54e7ae05c8e86e77396502
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.0', :require => 'blockcypher'
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.0.gem
32
+ $ gem install blockcypher-ruby-0.2.4.gem
33
33
  ```
34
34
 
35
35
  ## Initializing a client
@@ -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, omit_wallet_addresses: false)
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
- api_http_get('/addrs/' + address + '/balance')
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
- query = { limit: limit }
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
- api_http_post('/wallets/' + name + '/addresses', json_payload: payload)
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) { BlockCypher::Api.new(currency: BlockCypher::BTC, network: BlockCypher::TEST_NET_3, version: BlockCypher::V1) }
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
- let(:address_1) { 'miB9s4fcYCEBxPQm8vw6UrsYc2iSiEW3Yn' }
9
- let(:address_1_private_key) { 'f2a73451a726e81aec76a2bfd5a4393a89822b30cc4cddb2b4317efb2266ad47' }
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(:address_2) { 'mnTBb2Fd13pKwNjFQz9LVoy2bqmDugLM5m' }
12
- let(:address_2_private_key) { '76a32c1e5b6f9e174719e7c1b555d6a55674fdc2fd99cfeee96a5de632775645' }
24
+ let(:address_1) { $addr1["address"].to_s }
25
+ let(:address_1_private_key) { $addr1["private"].to_s }
13
26
 
14
- context '#transaction_new' do
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
- input_addresses = [address_2]
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, address_2_private_key)
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, "foo")
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, "foo", callback_url: "http://test.com/foo")
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, "foo", callback_url: "http://test.com/foo", enable_confirmations: true)
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, "foo")
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("foo")
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.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: 2015-09-20 00:00:00.000000000 Z
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: []