bech32 1.0.2 → 1.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: d1dbccb1bebbe132f71fac8cdad1a0e8a0beba9e
4
- data.tar.gz: cdd71f62ac2d8733815fb59e9d369f13c654d752
3
+ metadata.gz: 9acaaf9038539574877c05ca9dc45fbb69f78fb0
4
+ data.tar.gz: 6b73bb92def6f2eaebb5ac369217d7d973a4891f
5
5
  SHA512:
6
- metadata.gz: 733bf71d25d4344e550c9906c25678370ba23988a92e15955779c2f64d633aa836c6404bcf6ae2f6331d9babb22f25eeba60b454eba5adf785b3dfcd0c1882d5
7
- data.tar.gz: 72d15f485dd93fdbb0a9bca2da08eb4aee8ee66fb2df2c2b5cc059c9e2291748fc96032d44f30fb5fd683276959bec0f9b22b5180edc1e3dec1cb72797853faa
6
+ metadata.gz: 98ad08c6ca5138e4643f4b0c6b5587a9e2f110d7358a7585e8938c3ed520bbeff5626bcdd954500bda086c6a652566ce0a944a842d0002b56c388fac7612af63
7
+ data.tar.gz: a0e59ec902594e8d60d45bc254e49fca7ae96d57cf9be389b62654a38fe077172bc23753aa1b178478d7ca4562ee74ea3aaf13ef713d03c24c4cf67a6d3baf11
@@ -1,10 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bech32/version'
4
5
 
5
6
  Gem::Specification.new do |spec|
6
7
  spec.name = "bech32"
7
- spec.version = "1.0.2"
8
+ spec.version = Bech32::VERSION
8
9
  spec.authors = ["Shigeyuki Azuchi"]
9
10
  spec.email = ["azuchi@haw.co.jp"]
10
11
 
@@ -34,6 +34,8 @@ module Bech32
34
34
  # [0, 14, 20, 15, 7, 13, 26, 0, 25, 18, 6, 11, 13, 8, 21, 4, 20, 3, 17, 2, 29, 3, 12, 29, 3, 4, 15, 24, 20, 6, 14, 30, 22] # data
35
35
  #
36
36
  def decode(bech)
37
+ # check invalid bytes
38
+ return nil if bech.scrub('?').include?('?')
37
39
  # check uppercase/lowercase
38
40
  return nil if (bech.downcase != bech && bech.upcase != bech)
39
41
  bech.each_char{|c|return nil if c.ord < 33 || c.ord > 126}
@@ -23,7 +23,7 @@ module Bech32
23
23
  # parse script pubkey into witness version and witness program
24
24
  def script_pubkey=(script_pubkey)
25
25
  values = [script_pubkey].pack('H*').unpack("C*")
26
- @ver = values[0]
26
+ @ver = values[0] == 0 ? values[0] : values[0] - 0x50
27
27
  @prog = values[2..-1]
28
28
  end
29
29
 
@@ -36,7 +36,7 @@ module Bech32
36
36
 
37
37
  def parse_addr(addr)
38
38
  @hrp, data = Bech32.decode(addr)
39
- raise 'Invalid address.' if @hrp.nil? || ![HRP_MAINNET, HRP_TESTNET].include?(@hrp)
39
+ raise 'Invalid address.' if hrp.nil? || data[0].nil? || ![HRP_MAINNET, HRP_TESTNET].include?(hrp)
40
40
  @ver = data[0]
41
41
  raise 'Invalid witness version' if @ver > 16
42
42
  @prog = convert_bits(data[1..-1], 5, 8, false)
@@ -0,0 +1,3 @@
1
+ module Bech32
2
+ VERSION = "1.0.3"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bech32
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeyuki Azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-07 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -60,6 +60,7 @@ files:
60
60
  - bin/setup
61
61
  - lib/bech32.rb
62
62
  - lib/bech32/segwit_addr.rb
63
+ - lib/bech32/version.rb
63
64
  homepage: https://github.com/azuchi/bech32rb
64
65
  licenses:
65
66
  - MIT
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  version: '0'
81
82
  requirements: []
82
83
  rubyforge_project:
83
- rubygems_version: 2.6.12
84
+ rubygems_version: 2.6.13
84
85
  signing_key:
85
86
  specification_version: 4
86
87
  summary: The implementation of Bech32 encoder and decoder.