Table of Contents

Class EmulatorPacket

Namespace
NArk.Arkade.Emulator
Assembly
NArk.Arkade.dll

TLV record (type tag 0x01) carried inside the same Extension OP_RETURN envelope the asset packet uses, binding ArkadeScript bytecode + a witness stack to specific transaction inputs for emulator co-signing.

public sealed class EmulatorPacket : IExtensionPacket
Inheritance
EmulatorPacket
Implements
Inherited Members

Remarks

Wire format inside the TLV payload:

compactSize(entry_count) +
  per entry: u16_le(vin) +
             compactSize(script_len) + script_bytes +
             compactSize(witness_payload_len) + witness_payload

where witness_payload is the standard compactSize(num_pushes) + [compactSize(len)+bytes]* shape produced by Bitcoin's WriteTxWitness (matching the Go reference's wire.TxWitness).

1:1 with arkade-os/emulator pkg/arkade/emulator_packet.go and the ts-sdk's extension/emulator/packet.ts. Fixtures are vendored verbatim from the emulator's testdata/emulator_packet.json.

Constructors

EmulatorPacket(IReadOnlyList<EmulatorEntry>)

Construct from a list of entries — validates the packet against the emulator's rules: 1–MaxEntryCount entries, each script 1–MaxScriptLength bytes, each encoded witness blob ≤ MaxWitnessLength bytes, and unique Vin values.

public EmulatorPacket(IReadOnlyList<EmulatorEntry> entries)

Parameters

entries IReadOnlyList<EmulatorEntry>

Fields

MaxEntryCount

Maximum number of entries in a packet (emulator MaxEntryCount).

public const int MaxEntryCount = 1000

Field Value

int

MaxScriptLength

Maximum ArkadeScript length per entry, in bytes (emulator MaxScriptLength).

public const int MaxScriptLength = 10000

Field Value

int

MaxWitnessLength

Maximum encoded witness-blob length per entry, in bytes (emulator MaxWitnessLength).

public const int MaxWitnessLength = 1000000

Field Value

int

PacketTypeId

The 1-byte TLV type tag the Extension envelope uses for an Emulator Packet.

public const byte PacketTypeId = 1

Field Value

byte

Properties

Entries

Validated, immutable list of entries.

public IReadOnlyList<EmulatorEntry> Entries { get; }

Property Value

IReadOnlyList<EmulatorEntry>

Methods

DecodePushList(byte[])

public static IReadOnlyList<byte[]> DecodePushList(byte[] witness)

Parameters

witness byte[]

Returns

IReadOnlyList<byte[]>

EncodePushList(IReadOnlyList<byte[]>)

Encode a list of stack pushes in the standard compactSize(num) + [compactSize(len)+bytes]* shape — matches Bitcoin's WriteTxWitness.

public static byte[] EncodePushList(IReadOnlyList<byte[]> pushes)

Parameters

pushes IReadOnlyList<byte[]>

Returns

byte[]

FromBytes(byte[])

Parse the inner TLV payload bytes into an EmulatorPacket. Throws FormatException on truncated input or trailing data; ArgumentException on validation rule violations.

public static EmulatorPacket FromBytes(byte[] payload)

Parameters

payload byte[]

Returns

EmulatorPacket

FromExtension(Extension)

Look up the emulator packet riding alongside other packets in an already-parsed Extension. Returns null when the extension carries no emulator record. Re-parses the underlying UnknownPacket bytes — Extension itself doesn't know the emulator type natively (different package).

public static EmulatorPacket? FromExtension(Extension extension)

Parameters

extension Extension

Returns

EmulatorPacket

FromTransaction(Transaction)

Convenience: search a transaction's outputs for an Extension OP_RETURN and return its embedded emulator packet, or null.

public static EmulatorPacket? FromTransaction(Transaction tx)

Parameters

tx Transaction

Returns

EmulatorPacket

SerializePacketData()

public byte[] SerializePacketData()

Returns

byte[]

Validate(IReadOnlyList<EmulatorEntry>)

Apply the emulator's validation rules: 1–MaxEntryCount entries, each script 1–MaxScriptLength bytes, each encoded witness blob ≤ MaxWitnessLength bytes, and unique Vins. Returns a defensive copy on success; throws ArgumentException on violation.

public static IReadOnlyList<EmulatorEntry> Validate(IReadOnlyList<EmulatorEntry> entries)

Parameters

entries IReadOnlyList<EmulatorEntry>

Returns

IReadOnlyList<EmulatorEntry>