Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Gemfile.lock
Gemfile.lock
spec/config.yml
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'

gemspec
gemspec
27 changes: 27 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (5.0.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.4.0)
bitcoin-ruby (0.0.6)
coderay (1.1.0)
concurrent-ruby (1.0.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
diff-lcs (1.2.5)
ffi (1.9.8)
hashdiff (0.3.0)
i18n (0.7.0)
method_source (0.8.2)
minitest (5.9.0)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
Expand All @@ -31,14 +43,29 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
safe_yaml (1.0.4)
slop (3.6.0)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
vcr (3.0.3)
webmock (2.1.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff

PLATFORMS
ruby

DEPENDENCIES
activesupport
blockcypher-ruby!
bundler (~> 1.6)
pry
rake
rspec
vcr
webmock

BUNDLED WITH
1.13.1
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ For more information check the API docs at:

http://dev.blockcypher.com

## Development

- Copy `spec/config.yml.sample` to `spec/config.yml` and put your test API token
- `rspec spec`

## Contributors

Contributions from [CoinHako](http://www.coinhako.com) and [meXBT](https://mexbt.com)
3 changes: 3 additions & 0 deletions blockcypher-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rake"
s.add_development_dependency "rspec"
s.add_development_dependency "pry"
s.add_development_dependency "activesupport"
s.add_development_dependency "vcr"
s.add_development_dependency "webmock"
end
10 changes: 8 additions & 2 deletions lib/blockcypher/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,17 @@ def event_webhook_delete(id)
# Payments and Forwarding API
##################

def create_forwarding_address(destination, callback_url: nil, enable_confirmations: false)
def create_forwarding_address(
destination,
callback_url: nil,
enable_confirmations: false,
mining_fees_satoshis: nil
)
payload = {
destination: destination,
callback_url: callback_url,
enable_confirmations: enable_confirmations
enable_confirmations: enable_confirmations,
mining_fees_satoshis: mining_fees_satoshis,
}
api_http_post('/payments', json_payload: payload)
end
Expand Down
37 changes: 18 additions & 19 deletions spec/blockcypher/api_spec.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
require 'blockcypher'
require 'spec_helper'

module BlockCypher

describe Api do
describe Api, vcr: {record: :once} do
let(:api) do
BlockCypher::Api.new({
api_token: 'testtoken',
api_token: CONFIG[:api_token],
currency: BlockCypher::BCY,
network: BlockCypher::TEST_NET,
version: BlockCypher::V1
})
end

let(:addr1) { api.address_generate }
let(:addr2) { api.address_generate }
context '#address_generate' do
it 'should generate new addresses' do
$addr1 = api.address_generate
$addr2 = api.address_generate
expect($addr1["address"]).to be_a(String)
expect($addr2["address"]).to be_a(String)
expect(addr1["address"]).to be_a(String)
expect(addr2["address"]).to be_a(String)
end
end

let(:address_1) { $addr1["address"].to_s }
let(:address_1_private_key) { $addr1["private"].to_s }
let(:address_1) { addr1["address"].to_s }
let(:address_1_private_key) { addr1["private"].to_s }

let(:address_2) { $addr2["address"].to_s }
let(:address_2_private_key) { $addr2["private"].to_s }
let(:address_2) { addr2["address"].to_s }
let(:address_2_private_key) { addr2["private"].to_s }

context '#faucet' do
it 'should fund a bcy test address with the faucet' do
Expand Down Expand Up @@ -74,16 +74,15 @@ module BlockCypher
expect(forward_details["input_address"].length).to be(34) # Ok this isn't strictly true but..
end

it 'allows creating a payment forward with a callback' do
forward_details = api.create_forwarding_address(address_1, callback_url: "http://test.com/foo")
expect(forward_details["callback_url"]).to eql("http://test.com/foo")
expect(forward_details["enable_confirmations"]).to be nil
end

it 'allows creating a payment forward with a callback and confirmation notifications enabled' do
forward_details = api.create_forwarding_address(address_1, callback_url: "http://test.com/foo", enable_confirmations: true)
it 'allows creating a payment forward with options' do
forward_details = api.create_forwarding_address(address_1, {
callback_url: "http://test.com/foo",
enable_confirmations: true,
mining_fees_satoshis: 20_000,
})
expect(forward_details["callback_url"]).to eql("http://test.com/foo")
expect(forward_details["enable_confirmations"]).to be true
expect(forward_details["mining_fees_satoshis"]).to be 20_000
end

it 'is possible to use the alias create_payments_forwarding' do
Expand Down
2 changes: 2 additions & 0 deletions spec/config.yml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
api_token: testtoken-changeme
Loading