bech32 1.0.0 → 1.0.1

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: 746f17b48aafeb175a66ea2d5e5d75adcb2a4bc7
4
- data.tar.gz: 345ef0c51a1e399871d316e196a7d25e7fa6caf2
3
+ metadata.gz: 1dbf369ac8990456626ab97fbc98580c01a47110
4
+ data.tar.gz: 6c12e12379890d8a47aec779e19f68c04d0ce919
5
5
  SHA512:
6
- metadata.gz: 8b8df48e2f10f6a00e27e3f9f19332e83eacd8aca2659299b24508a59f688ebfad9585a126373396a9e69fab53a3790d99f0d0b732f1d19621a4964fb5cf0aca
7
- data.tar.gz: 114e4c62ec06132002b30c17b51884875d475f5d33aaec2c4a73436a331180984f10e644ea3762d0c3d4302d71503fe801fdd7622c9eb9e4b8d8752482ac5c2f
6
+ metadata.gz: 29940231175f3150e370c4fbe5b9d2955e61673af9bdc953304a61761048047fde43827037b25fa66dea0f4ba28e9a0be080a3aebfa76a7acc9c809f88f1fc50
7
+ data.tar.gz: 659fd697fc7edcad0645c26768ef6f320dd5db4fdd8e986d2cc19fb3b5df88791d0dc2a7309792576457800a8107034875aca91e445671148b8155f9364472c1
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Bech32 [![Build Status](https://travis-ci.org/azuchi/bech32rb.svg?branch=master)](https://travis-ci.org/azuchi/bech32rb) [![Gem Version](https://badge.fury.io/rb/bech32.svg)](https://badge.fury.io/rb/bech32) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
1
+ # Bech32 [![Build Status](https://travis-ci.org/azuchi/bech32rb.svg?branch=master)](https://travis-ci.org/azuchi/bech32rb) [![Gem Version](https://badge.fury.io/rb/bech32.svg)](https://badge.fury.io/rb/bech32) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) <img src="http://segwit.co/static/public/images/logo.png" width="100">
2
2
 
3
3
  The implementation of the Bech32 encoder and decoder for Ruby.
4
4
 
@@ -47,6 +47,7 @@ hrp, data = Bech32.decode('BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4')
47
47
  Decode Bech32-encoded Segwit address into `Bech32::SegwitAddr` instance.
48
48
 
49
49
  ```ruby
50
+ addr = 'BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4'
50
51
  segwit_addr = Bech32::SegwitAddr.new(addr)
51
52
 
52
53
  # generate script pubkey
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "bech32"
7
- spec.version = "1.0.0"
7
+ spec.version = "1.0.1"
8
8
  spec.authors = ["Shigeyuki Azuchi"]
9
9
  spec.email = ["azuchi@haw.co.jp"]
10
10
 
@@ -1,12 +1,16 @@
1
1
  module Bech32
2
2
 
3
3
  class SegwitAddr
4
+
5
+ HRP_MAINNET = 'bc'
6
+ HRP_TESTNET = 'tb'
7
+
4
8
  attr_accessor :hrp # human-readable part
5
9
  attr_accessor :ver # witness version
6
10
  attr_accessor :prog # witness program
7
11
 
8
12
  def initialize(addr = nil)
9
- @hrp = 'bc'
13
+ @hrp = HRP_MAINNET
10
14
  parse_addr(addr) if addr
11
15
  end
12
16
 
@@ -32,7 +36,7 @@ module Bech32
32
36
 
33
37
  def parse_addr(addr)
34
38
  @hrp, data = Bech32.decode(addr)
35
- raise 'Invalid address.' if @hrp.nil? || (@hrp != 'bc' && @hrp != 'tb')
39
+ raise 'Invalid address.' if @hrp.nil? || ![HRP_MAINNET, HRP_TESTNET].include?(@hrp)
36
40
  @ver = data[0]
37
41
  raise 'Invalid witness version' if @ver > 16
38
42
  @prog = convert_bits(data[1..-1], 5, 8, false)
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.0
4
+ version: 1.0.1
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-05-10 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake