coin-address-validators 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8505cc7abe02d2cab1f65b85d2a0c94e4123d34a
4
- data.tar.gz: 36c3ea9f60a7e07274b8766c754ebcbbc54723fd
3
+ metadata.gz: 56edfdfd7d5f1a470161a6b023912670965de8d8
4
+ data.tar.gz: 9d11bd8bec9a018592e5fa10ad59e92133c2b74b
5
5
  SHA512:
6
- metadata.gz: 1430779091f39c62a1dc23d5e1498cd99640bd346bb6d156e1c39bb9f90885db0da48d5a9e471ccbcee20f68edaed8ff5134ab6c64b10d2bc05f4028d299442c
7
- data.tar.gz: 9f13b7d932a823fd8085b35506935c3fde0532395df8cb020627286dbe14adec89ed2fbfabfcd3d881adc95197f5ef9f6f5050542dfd6e104298313a68e2c0b4
6
+ metadata.gz: 120653700405dc6acef33ea0dda46c1e68fe77ee923d480d516ed1535bc1f25fa9a5da73f33b4fa3f6a42f5719875ec41fe9263b9e2d028f762c51884734cc54
7
+ data.tar.gz: 018b1bf5ad16408657d32d444b0d7cd5fe76a068c059a9794386d2c24d7ee30981041946ad1711f1b289b96e2040d196e581d7880495529dc7f8adfa46f7497a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coin-address-validators (0.0.1)
4
+ coin-address-validators (0.0.2)
5
5
  base_x
6
6
  bitcoin-ruby
7
7
  cashaddress
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ rm *.gem; gem build coin-address-validators.gemspec; gem push *.gem
@@ -71,20 +71,20 @@ class CoinAddressValidators
71
71
 
72
72
  class BchValidator
73
73
  include Bitcoin::Util
74
+ def parse_cash_addr(address)
75
+ if address.start_with?("bitcoincash:")
76
+ [Cashaddress.to_legacy(address), true]
77
+ else
78
+ [Cashaddress.to_legacy("bitcoincash:#{address}"), true]
79
+ end
80
+ rescue Cashaddress::Error
81
+ [nil, false]
82
+ end
83
+
74
84
  def valid?(address)
75
85
  return true if valid_address?(address)
76
- begin
77
- legacy_address = Cashaddress.to_legacy(address)
78
- return true
79
- rescue Cashaddress::Error
80
- return false if address.start_with?("bitcoincash:")
81
- begin
82
- legacy_address = Cashaddress.to_legacy("bitcoincash:" + address)
83
- return true
84
- rescue Cashaddress::Error
85
- return false
86
- end
87
- end
86
+ legacy_address, ok = parse_cash_addr(address)
87
+ ok
88
88
  end
89
89
  end
90
90
 
@@ -1,3 +1,3 @@
1
1
  class CoinAddressValidators
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coin-address-validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phuong Nguyen
@@ -118,6 +118,7 @@ files:
118
118
  - ".gitignore"
119
119
  - Gemfile
120
120
  - Gemfile.lock
121
+ - build-and-publish.sh
121
122
  - coin-address-validators.gemspec
122
123
  - lib/coin-address-validators.rb
123
124
  - lib/coin-address-validators/version.rb