BSV.Tokens.ScriptFlags (bsv_sdk v1.4.0)

Copy Markdown View Source

STAS protocol flags field.

The flags field is embedded in the trailing metadata of a STAS locking script, immediately after the redemption address/MPKH. Each bit enables an optional administrative capability that is set at issuance and cannot be changed.

Bit Layout

BitFlagEffect
0freezableEnables freeze/unfreeze by authority
1confiscatableEnables confiscation by authority

When a flag is enabled, a corresponding service field follows the flags in the trailing metadata, containing the authority address/MPKH for that capability. Service fields appear left-to-right in the opposite order of the flag bits (right-to-left).

Encoding

The flags field is always present unless no data follows the redemption PKH. Use OP_0 (0x00) or <<0x01, 0x00>> for default (no flags). Do NOT use OP_1OP_16 for the flags field — use pushdata encoding.

Summary

Functions

Decode a flags binary into a ScriptFlags struct.

Encode flags to a binary for embedding in a locking script.

Returns the number of service fields expected for the given flags.

Types

t()

@type t() :: %BSV.Tokens.ScriptFlags{confiscatable: boolean(), freezable: boolean()}

Functions

decode(arg1)

@spec decode(binary()) :: {:ok, t()} | {:error, :invalid_flags}

Decode a flags binary into a ScriptFlags struct.

encode(script_flags)

@spec encode(t()) :: binary()

Encode flags to a binary for embedding in a locking script.

Returns a binary where bit 0 = freezable, bit 1 = confiscatable.

service_field_count(script_flags)

@spec service_field_count(t()) :: non_neg_integer()

Returns the number of service fields expected for the given flags.