Class EmulatorPacket
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
entriesIReadOnlyList<EmulatorEntry>
Fields
MaxEntryCount
Maximum number of entries in a packet (emulator MaxEntryCount).
public const int MaxEntryCount = 1000
Field Value
MaxScriptLength
Maximum ArkadeScript length per entry, in bytes (emulator MaxScriptLength).
public const int MaxScriptLength = 10000
Field Value
MaxWitnessLength
Maximum encoded witness-blob length per entry, in bytes (emulator MaxWitnessLength).
public const int MaxWitnessLength = 1000000
Field Value
PacketTypeId
The 1-byte TLV type tag the Extension envelope uses for an Emulator Packet.
public const byte PacketTypeId = 1
Field Value
Properties
Entries
Validated, immutable list of entries.
public IReadOnlyList<EmulatorEntry> Entries { get; }
Property Value
Methods
DecodePushList(byte[])
Inverse of EncodePushList(IReadOnlyList<byte[]>).
public static IReadOnlyList<byte[]> DecodePushList(byte[] witness)
Parameters
witnessbyte[]
Returns
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
pushesIReadOnlyList<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
payloadbyte[]
Returns
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
extensionExtension
Returns
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
txTransaction
Returns
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
entriesIReadOnlyList<EmulatorEntry>