Module: BSV::Wallet::Serializer::IsAuthenticated::Result
- Defined in:
- lib/bsv/wallet/serializer/status.rb
Class Method Summary collapse
-
.deserialize(bytes) ⇒ Hash
{ authenticated: Boolean }.
-
.serialize(result) ⇒ String
1-byte binary.
Class Method Details
.deserialize(bytes) ⇒ Hash
Returns { authenticated: Boolean }.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bsv/wallet/serializer/status.rb', line 40 def deserialize(bytes) data = bytes.b unless data.bytesize == 1 raise BSV::Wallet::InvalidParameterError.new( 'is_authenticated result', 'exactly 1 byte' ) end { authenticated: data.getbyte(0) == 1 } end |
.serialize(result) ⇒ String
Returns 1-byte binary.
34 35 36 |
# File 'lib/bsv/wallet/serializer/status.rb', line 34 def serialize(result) [result[:authenticated] ? 1 : 0].pack('C') end |