Script-level VarInt helpers for BSV.Contract modules.
VarInts are commonly used in Bitcoin scripts to encode variable-length data. These helpers generate script opcodes that extract or trim VarInt prefixes at runtime on the script stack.
Usage
import BSV.Contract.VarIntHelpersOr through use BSV.Contract (auto-imported).
Summary
Functions
Assuming the top stack item is a VarInt-prefixed binary, extract the VarInt number and place it on top of the stack.
Assuming the top stack item is a VarInt-prefixed binary, extract the VarInt data and place it on top of the stack.
Assuming the top stack item is a VarInt-prefixed binary, trim the VarInt prefix from the leading bytes.
Functions
@spec get_varint(BSV.Contract.t()) :: BSV.Contract.t()
Assuming the top stack item is a VarInt-prefixed binary, extract the VarInt number and place it on top of the stack.
The original element is not removed (it is duplicated first).
@spec read_varint(BSV.Contract.t()) :: BSV.Contract.t()
Assuming the top stack item is a VarInt-prefixed binary, extract the VarInt data and place it on top of the stack.
The original element is removed. Any remaining data is second on the stack.
@spec trim_varint(BSV.Contract.t()) :: BSV.Contract.t()
Assuming the top stack item is a VarInt-prefixed binary, trim the VarInt prefix from the leading bytes.
The original element is replaced with the data after the VarInt prefix.