BSV.Tokens.TxType (bsv_sdk v1.5.0)

Copy Markdown View Source

STAS 3.0 v0.1 §8.1 transaction-type (txType) parameter.

Every STAS 3.0 unlocking script carries a 1-byte txType value (slot 18 in the spec §7 witness layout) describing the high-level shape of the spend:

ValueAtomOperation
0:regularRegular spend / split / 1-in/1-out
1:atomic_swapAtomic swap (counterparty trailing parameters apply)
2:merge_2Merge with 2 pieces
3:merge_3Merge with 3 pieces
4:merge_4Merge with 4 pieces
5:merge_5Merge with 5 pieces
6:merge_6Merge with 6 pieces
7:merge_7Merge with 7 pieces

Mirrors BSV.Tokens.SpendType in shape: to_byte/1 and from_byte/1.

Summary

Functions

Convert a wire-format byte value (0..7) to a txType atom.

Convert a txType atom to its wire-format byte value (0..7).

Types

t()

@type t() ::
  :regular
  | :atomic_swap
  | :merge_2
  | :merge_3
  | :merge_4
  | :merge_5
  | :merge_6
  | :merge_7

Functions

from_byte(arg1)

@spec from_byte(byte()) :: {:ok, t()} | {:error, :unknown_tx_type}

Convert a wire-format byte value (0..7) to a txType atom.

to_byte(atom)

@spec to_byte(t()) :: byte()

Convert a txType atom to its wire-format byte value (0..7).