Class: Stack

script.Stack

new Stack(itemsnullable)

Represents the stack of a Script during execution.

Parameters:
Name Type Attributes Description
items Array:.<Buffer:> <nullable>

Stack items.

Properties:
Name Type Description
items Array:.<Buffer:>

Stack items.

length Number

Size of stack.

Source:

Methods

(static) isStack(obj) → {Boolean}

Test an object to see if it is a Stack.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

clear()

Clear the stack.

Source:

clone() → {Stack}

Clone the stack.

Source:
Returns:

Cloned stack.

Type
Stack

erase(start, end) → {Array:.<Buffer:>}

Erase stack items.

Parameters:
Name Type Description
start Number
end Number
Source:
Returns:
Type
Array:.<Buffer:>

get(index) → {Buffer|null}

Get a stack item by index.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
Buffer | null

insert(index, item) → {Buffer}

Insert an item.

Parameters:
Name Type Description
index Number
item Buffer
Source:
Returns:
Type
Buffer

inspect() → {String}

Inspect the stack.

Source:
Returns:

Human-readable stack.

Type
String

(private) length_getter() → {Number}

Getter to retrieve stack items length.

Source:
Returns:
Type
Number

(private) length_setter(value) → {Number}

Setter to set stack items length.

Parameters:
Name Type Description
value Number
Source:
Returns:
Type
Number

pop() → {Buffer|null}

Pop a stack item.

Source:
See:
  • Array#pop
Returns:
Type
Buffer | null

push(item) → {Number}

Push item onto stack.

Parameters:
Name Type Description
item Buffer
Source:
See:
  • Array#push
Returns:

Stack size.

Type
Number

remove(index) → {Buffer}

Remove an item.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
Buffer

set(index, value) → {Buffer}

Set stack item at index.

Parameters:
Name Type Description
index Number
value Buffer
Source:
Returns:
Type
Buffer

shift() → {Buffer|null}

Shift a stack item.

Source:
See:
  • Array#shift
Returns:
Type
Buffer | null

slice(start, end) → {Stack}

Slice out part of the stack items.

Parameters:
Name Type Description
start Number
end Number
Source:
See:
  • Array#slice
Returns:
Type
Stack

splice(index, remove, insertnullable) → {Array:.<Buffer:>}

Splice stack items.

Parameters:
Name Type Attributes Description
index Number
remove Number
insert Buffer <nullable>
Source:
See:
  • Array#splice
Returns:
Type
Array:.<Buffer:>

swap(i1, i2)

Swap stack values.

Parameters:
Name Type Description
i1 Number

Index 1.

i2 Number

Index 2.

Source:

toASM(decodenullable) → {String}

Format the stack as bitcoind asm.

Parameters:
Name Type Attributes Description
decode Boolean <nullable>

Attempt to decode hash types.

Source:
Returns:

Human-readable script.

Type
String

top(index) → {Buffer|null}

Get a stack item relative to the top of the stack.

Parameters:
Name Type Description
index Number
Source:
Returns:
Type
Buffer | null
Example
stack.top(-1);

toString() → {String}

Convert the stack to a string.

Source:
Returns:

Human-readable stack.

Type
String

unshift(item) → {Number}

Unshift item from stack.

Parameters:
Name Type Description
item Buffer
Source:
See:
  • Array#unshift
Returns:
Type
Number