bit_wallet 0.5.0 → 0.6.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGFiM2Y3MGRkNjFjYjY2YzIxZWFhNDc0MzNkODE4ZmM2NjhmMTc2MA==
4
+ ZTdmOGQyNGU2NWI4ZDAyNjc4OTE2ZTYyMTE2YjlkMGIwZjA1ZTA1NQ==
5
5
  data.tar.gz: !binary |-
6
- MTJjZjFhZjVjNjk3MTVkNGQ2MDQ1MjYzYzRiMjRkNWQzNTZkZDFiMw==
6
+ Njg5YzcxMzUyZjIzNWU2NWYyMDUxMWI0ZWM3N2RkZGZiYzMwMTM5ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTIxMjJkNzFiYjllYWVmNDMyYThmYzU5NjVjYWE0NWI0M2IyYWJjZmVmZTgw
10
- YTEzMDY2NzQ2ODgwMDRjODRhNTk5YmNiZDM5MjU2ZDY2MzQ3OWQ0YjZkMDQy
11
- MWM0MWIzMTAyMDg3MzlkNDdmOWRhYzg4Y2Y0MjYxMzBiZmZmZDA=
9
+ ZTFmYTEzOTAxMTZjM2Y1YTFlYjhiMGYyN2Q5NGUzNTM1YzdkMGVjZDY2ZTI2
10
+ OTVjOGI3NWE1NWIzOGYwMzRlMGZmZmEwZDY2ZTc1Y2ViNWIzNGUwZTZhODA4
11
+ ZTE3ZmRlZjhmYzUxZThkYjMzNjliYzhlNDQzYTM4OTQ1MzhiMTA=
12
12
  data.tar.gz: !binary |-
13
- NDE3YTI0YTFhZDM5ZWZjZmE2N2YyMTU3ZGI3N2NkM2RkNTVkZWU3NmE5Yjg1
14
- MmIwNDg3ZDA3YmQ0OWY3MDMwNTgxYmU3N2NkNGNjZDNjZjg5YzMzYTRkZDcx
15
- YWY5MzUzNzIwMWRjMTM2ZjBiMGVlZGY5ZGE4ZTQ4ODQ2ZmRiMzY=
13
+ ZjkwYTU5MDE0MzE2ZmMxYzk2ZTMxODE0YmY3MzQyMjE2OGIxODgyY2ViNjMx
14
+ NDc3ZDFiMDgxYmE2MGU1MjZhNmRkZGU3ODY0OWMxZmVhMWJlZGQ3NWU2Zjg3
15
+ ZDAzNTlhNDIxYTMwOWU0NThhNGFlNjQ5MzdkYzJjYzQxNjVhODA=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.6.0
2
+
3
+ - Handle error -6 (invalid address)
4
+
1
5
  # v0.5.0
2
6
 
3
7
  - Allow to set the host, and ssl (true/false) of Bitcoin client
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in bit_wallet.gemspec
4
4
  gemspec
5
+
6
+ gem "pry", "0.9.12.2"
data/bit_wallet.gemspec CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.add_dependency 'bitcoin-client'
21
21
  gem.add_dependency 'activesupport'
22
22
  gem.add_development_dependency 'rspec', '~> 2.12'
23
- gem.add_development_dependency 'pry'
24
23
  gem.add_development_dependency 'factory_girl', '4.2.0'
25
24
  gem.add_development_dependency 'bitcoin_testnet', '0.5.0'
26
25
  gem.add_development_dependency 'vcr', '~> 2.4'
@@ -60,12 +60,7 @@ module BitWallet
60
60
  BitWallet.config.min_conf)
61
61
  txid
62
62
  rescue => e
63
- error_message = JSON.parse(e.response).with_indifferent_access
64
- if error_message[:error][:code] == -6
65
- fail InsufficientFunds, "'#{self.name}' does not have enough funds"
66
- else
67
- raise e
68
- end
63
+ parse_error e.message
69
64
  end
70
65
 
71
66
  private
@@ -2,4 +2,5 @@ module BitWallet
2
2
  class StandardError < ::StandardError; end
3
3
  class InsufficientFunds < StandardError; end
4
4
  class InvalidAmount < StandardError; end
5
+ class InvalidAddress < StandardError; end
5
6
  end
@@ -6,6 +6,8 @@ module BitWallet
6
6
  InsufficientFunds.new("cannot send an amount more than what this account has")
7
7
  elsif message.include?("-3")
8
8
  InvalidAmount.new("amount is invalid")
9
+ elsif message.include?("-5")
10
+ InvalidAddress.new("bitcoin address is invalid")
9
11
  else
10
12
  ArgumentError.new("unknown error: #{message}")
11
13
  end
@@ -1,3 +1,3 @@
1
1
  module BitWallet
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -10,6 +10,13 @@ module BitWallet
10
10
  end
11
11
  end
12
12
 
13
+ context "error is -5" do
14
+ it "raises InvalidAddress error" do
15
+ expect { described_class.from("some error -5 message") }.
16
+ to raise_error(InvalidAddress, "bitcoin address is invalid")
17
+ end
18
+ end
19
+
13
20
  context "error is -6" do
14
21
  it "raises InsufficientFunds error" do
15
22
  expect { described_class.from("-6 message") }.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bit_wallet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-01 00:00:00.000000000 Z
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bitcoin-client
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.12'
55
- - !ruby/object:Gem::Dependency
56
- name: pry
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ! '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: factory_girl
71
57
  requirement: !ruby/object:Gem::Requirement