View Source BitcoinLib.Script.Opcodes.Stack.Swap (BitcoinLib v0.4.7)

Based on https://en.bitcoin.it/wiki/Script

Word OP_SWAP Opcode 124 Hex 0x7c Input x1 x2 Output x2 x1 The top two items on the stack are swapped.

Link to this section Summary

Functions

Returns <<0x7c>>

The top two items on the stack are swapped.

v()

Returns 0x7c

Link to this section Types

@type t() :: BitcoinLib.Script.Opcodes.Stack.Swap

Link to this section Functions

Returns <<0x7c>>

examples

Examples

iex> BitcoinLib.Script.Opcodes.Stack.Swap.encode()
<<0x7c>>
@spec execute(t(), list()) :: {:ok, list()} | {:error, binary()}

The top two items on the stack are swapped.

examples

Examples

iex> stack = [1, 2, 3, 4, 5]
...> %BitcoinLib.Script.Opcodes.Stack.Swap{}
...> |> BitcoinLib.Script.Opcodes.Stack.Swap.execute(stack)
{:ok, [2, 1, 3, 4, 5]}
@spec v() :: 124

Returns 0x7c

examples

Examples

iex> BitcoinLib.Script.Opcodes.Stack.Swap.v()
0x7c