tapyrus 0.2.4 → 0.2.5
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 +4 -4
- data/lib/tapyrus/script/color.rb +2 -2
- data/lib/tapyrus/script/script.rb +30 -0
- data/lib/tapyrus/version.rb +1 -1
- data/tapyrusrb.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eacc6d47ecb8c8f955e1713d0245b95185857a313189e232102a24e9dcf43c6
|
4
|
+
data.tar.gz: a961c657873aa82e7f917f55c8b00ea80175b9eb2eb363d72c3c1621f7bee9dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32adab54eb182f5f24536a0b48a89c05756901ba623b054916d7ba5ccc3e034f70147e578917bf847eabdb93070db3b7c628fe3ecc60ebc810ad4603497ec367
|
7
|
+
data.tar.gz: e7c802d4cd4081f0dcbf10c317551c47c7ab90ae764e341dfb55e7f32f91bfb28a0680d1ef915ae322ed15ca1524824df690c9e32e7d29fe27df8e080164f5bf
|
data/lib/tapyrus/script/color.rb
CHANGED
@@ -53,11 +53,11 @@ module Tapyrus
|
|
53
53
|
|
54
54
|
module ColoredOutput
|
55
55
|
def colored?
|
56
|
-
script_pubkey.
|
56
|
+
script_pubkey.colored?
|
57
57
|
end
|
58
58
|
|
59
59
|
def color_id
|
60
|
-
@color_id ||=
|
60
|
+
@color_id ||= script_pubkey.color_id
|
61
61
|
end
|
62
62
|
|
63
63
|
def reissuable?
|
@@ -75,6 +75,18 @@ module Tapyrus
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
# Remove color identifier from cp2pkh or cp2sh
|
79
|
+
# @param [ColorIdentifier] color identifier
|
80
|
+
# @return [Script] P2PKH or P2SH script
|
81
|
+
# @raise [RuntimeError] if script is neither cp2pkh nor cp2sh
|
82
|
+
def remove_color
|
83
|
+
raise RuntimeError, 'Only cp2pkh and cp2sh can remove color' unless cp2pkh? or cp2sh?
|
84
|
+
|
85
|
+
Tapyrus::Script.new.tap do |s|
|
86
|
+
s.chunks = self.chunks[2..-1]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
78
90
|
def get_multisig_pubkeys
|
79
91
|
num = Tapyrus::Opcodes.opcode_to_small_int(chunks[-2].bth.to_i(16))
|
80
92
|
(1..num).map{ |i| chunks[i].pushed_data }
|
@@ -214,6 +226,8 @@ module Tapyrus
|
|
214
226
|
(chunks.size == 1 || chunks[1].opcode <= OP_16)
|
215
227
|
end
|
216
228
|
|
229
|
+
# Return whether this script is a CP2PKH format script or not.
|
230
|
+
# @return [Boolean] true if this script is cp2pkh, otherwise false.
|
217
231
|
def cp2pkh?
|
218
232
|
return false unless chunks.size == 7
|
219
233
|
return false unless chunks[0].bytesize == 34
|
@@ -223,6 +237,8 @@ module Tapyrus
|
|
223
237
|
(chunks[2..3]+ chunks[5..6]).map(&:ord) && chunks[4].bytesize == 21
|
224
238
|
end
|
225
239
|
|
240
|
+
# Return whether this script is a CP2SH format script or not.
|
241
|
+
# @return [Boolean] true if this script is cp2pkh, otherwise false.
|
226
242
|
def cp2sh?
|
227
243
|
return false unless chunks.size == 5
|
228
244
|
return false unless chunks[0].bytesize == 34
|
@@ -230,6 +246,20 @@ module Tapyrus
|
|
230
246
|
return false unless chunks[1].ord == OP_COLOR
|
231
247
|
OP_HASH160 == chunks[2].ord && OP_EQUAL == chunks[4].ord && chunks[3].bytesize == 21
|
232
248
|
end
|
249
|
+
|
250
|
+
# Return whether this script represents colored coin.
|
251
|
+
# @return [Boolean] true if this script is colored, otherwise false.
|
252
|
+
def colored?
|
253
|
+
cp2pkh? || cp2sh?
|
254
|
+
end
|
255
|
+
|
256
|
+
# Return color identifier for this script.
|
257
|
+
# @return [ColorIdentifer] color identifier for this script if this script is colored. return nil if this script is not colored.
|
258
|
+
def color_id
|
259
|
+
return nil unless colored?
|
260
|
+
|
261
|
+
Tapyrus::Color::ColorIdentifier.parse_from_payload(chunks[0].pushed_data)
|
262
|
+
end
|
233
263
|
|
234
264
|
def op_return_data
|
235
265
|
return nil unless op_return?
|
data/lib/tapyrus/version.rb
CHANGED
data/tapyrusrb.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ["azuchi"]
|
11
11
|
spec.email = ["azuchi@chaintope.com"]
|
12
12
|
|
13
|
-
spec.summary = %q{
|
14
|
-
spec.description = %q{
|
13
|
+
spec.summary = %q{The implementation of Tapyrus Protocol for Ruby.}
|
14
|
+
spec.description = %q{The implementation of Tapyrus Protocol for Ruby.}
|
15
15
|
spec.homepage = 'https://github.com/chaintope/tapyrusrb'
|
16
16
|
spec.license = "MIT"
|
17
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapyrus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecdsa
|
@@ -290,7 +290,7 @@ dependencies:
|
|
290
290
|
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: '3.0'
|
293
|
-
description:
|
293
|
+
description: The implementation of Tapyrus Protocol for Ruby.
|
294
294
|
email:
|
295
295
|
- azuchi@chaintope.com
|
296
296
|
executables:
|
@@ -452,5 +452,5 @@ requirements: []
|
|
452
452
|
rubygems_version: 3.0.3
|
453
453
|
signing_key:
|
454
454
|
specification_version: 4
|
455
|
-
summary:
|
455
|
+
summary: The implementation of Tapyrus Protocol for Ruby.
|
456
456
|
test_files: []
|