Class: Tapyrus::Color::ColorIdentifier
- Includes:
- HexConverter
- Defined in:
- lib/tapyrus/script/color.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .nft(out_point) ⇒ Object
- .non_reissuable(out_point) ⇒ Object
- .parse_from_payload(payload) ⇒ Object
- .reissuable(script_pubkey) ⇒ Object
Instance Method Summary collapse
Methods included from HexConverter
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
13 14 15 |
# File 'lib/tapyrus/script/color.rb', line 13 def payload @payload end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/tapyrus/script/color.rb', line 13 def type @type end |
Class Method Details
.nft(out_point) ⇒ Object
23 24 25 |
# File 'lib/tapyrus/script/color.rb', line 23 def self.nft(out_point) new(TokenTypes::NFT, Tapyrus.sha256(out_point.to_payload)) end |
.non_reissuable(out_point) ⇒ Object
19 20 21 |
# File 'lib/tapyrus/script/color.rb', line 19 def self.non_reissuable(out_point) new(TokenTypes::NON_REISSUABLE, Tapyrus.sha256(out_point.to_payload)) end |
.parse_from_payload(payload) ⇒ Object
31 32 33 34 |
# File 'lib/tapyrus/script/color.rb', line 31 def self.parse_from_payload(payload) type, payload = payload.unpack('Ca*') new(type, payload) end |
.reissuable(script_pubkey) ⇒ Object
15 16 17 |
# File 'lib/tapyrus/script/color.rb', line 15 def self.reissuable(script_pubkey) new(TokenTypes::REISSUABLE, Tapyrus.sha256(script_pubkey.to_payload)) end |
Instance Method Details
#==(other) ⇒ Object
36 37 38 |
# File 'lib/tapyrus/script/color.rb', line 36 def ==(other) other && other.to_payload == to_payload end |
#to_payload ⇒ Object
27 28 29 |
# File 'lib/tapyrus/script/color.rb', line 27 def to_payload [type, payload].pack('Ca*') end |
#valid? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/tapyrus/script/color.rb', line 40 def valid? return false unless [TokenTypes::REISSUABLE, TokenTypes::NON_REISSUABLE, TokenTypes::NFT].include?(type) return false unless payload.bytesize == 32 true end |