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 +4 -4
- data/README.md +2 -1
- data/bech32.gemspec +1 -1
- data/lib/bech32/segwit_addr.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dbf369ac8990456626ab97fbc98580c01a47110
|
4
|
+
data.tar.gz: 6c12e12379890d8a47aec779e19f68c04d0ce919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/bech32.gemspec
CHANGED
data/lib/bech32/segwit_addr.rb
CHANGED
@@ -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 =
|
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
|
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.
|
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-
|
11
|
+
date: 2017-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|