class CryptoconditionsRuby::Types::PreimageSha256Fulfillment
Constants
- FEATURE_BITMASK
- TYPE_ID
Attributes
preimage[RW]
Public Class Methods
new(preimage = nil)
click to toggle source
# File lib/cryptoconditions_ruby/types/preimage_sha_256_fulfillment.rb, line 9 def initialize(preimage = nil) if preimage && !preimage.respond_to?(:bytes) raise TypeError, "Preimage must be bytes, was #{preimage.class.name}" end @preimage = preimage end
Public Instance Methods
bitmask()
click to toggle source
# File lib/cryptoconditions_ruby/types/preimage_sha_256_fulfillment.rb, line 16 def bitmask FEATURE_BITMASK end
parse_dict(data)
click to toggle source
# File lib/cryptoconditions_ruby/types/preimage_sha_256_fulfillment.rb, line 55 def parse_dict(data) self.preimage = data['preimage'].encode end
parse_payload(reader, payload_size)
click to toggle source
# File lib/cryptoconditions_ruby/types/preimage_sha_256_fulfillment.rb, line 30 def parse_payload(reader, payload_size) unless reader.is_a?(Utils::Reader) raise TypeError, 'reader must be a Reader instance' end self.preimage = reader.read(payload_size) end
to_dict()
click to toggle source
# File lib/cryptoconditions_ruby/types/preimage_sha_256_fulfillment.rb, line 46 def to_dict { 'type' => 'fulfillment', 'type_id' => TYPE_ID, 'bitmask' => bitmask, 'preimage' => preimage } end
validate(**_kwargs)
click to toggle source
# File lib/cryptoconditions_ruby/types/preimage_sha_256_fulfillment.rb, line 59 def validate(**_kwargs) true end
write_hash_payload(hasher)
click to toggle source
# File lib/cryptoconditions_ruby/types/preimage_sha_256_fulfillment.rb, line 20 def write_hash_payload(hasher) unless hasher.is_a?(Utils::Hasher) raise TypeError, 'hasher must be a Hasher instance' end unless preimage raise TypeError, 'Could not calculate hash, no preimage provided' end hasher.write(preimage) end
write_payload(writer)
click to toggle source
# File lib/cryptoconditions_ruby/types/preimage_sha_256_fulfillment.rb, line 37 def write_payload(writer) unless [Utils::Writer, Utils::Predictor].include?(writer.class) raise TypeError, 'writer must be a Writer instance' end raise TypeError, 'Preimage must be specified' unless preimage writer.write(preimage) writer end