Class BSV::Script::Chunk ¶
Inherits: Object
A single element of a parsed script — either an opcode or a data push.
Scripts are composed of a sequence of chunks. Each chunk is either a bare opcode (e.g. OP_DUP) or a data push (opcode + data payload).
Attributes¶
data [R] ¶
- @return [String, nil] the pushed data bytes, or +nil+ for bare opcodes
opcode [R] ¶
- @return [Integer] the opcode byte
Public Instance Methods¶
==(other) ¶
- @param
other[Object] the object to compare - @return [Boolean] +true+ if both chunks have equal opcode and data
data?() ¶
Whether this chunk carries a data payload. - @return [Boolean] +true+ if this is a data push chunk
initialize(opcode:, data: = nil) ¶
- @param
opcode[Integer] the opcode byte value - @param
data[String, nil] data payload for push operations - @return [Chunk] a new instance of Chunk
to_asm() ¶
Render this chunk as human-readable ASM.
Data pushes are shown as hex strings; opcodes are shown by name. - @return [String] ASM representation
to_binary() ¶
Serialise this chunk back to raw script bytes.
Preserves the original push encoding (including non-minimal pushes) so that round-tripping through parse/serialise does not alter the script bytes. This is critical for sighash computation. - @return [String] binary script bytes for this chunk