Class: Witness

script.Witness(optionsopt)

Witness Refers to the witness vector of segregated witness transactions.

Constructor

new Witness(optionsopt)

Create a witness.

Extends:
  • Stack
Parameters:
Name Type Attributes Description
options Array.<Buffer> | WitnessOptions <optional>

Array of stack items.

Properties:
Name Type Attributes Description
items Array.<Buffer>
redeem Script <nullable>
length Number
Source:

Extends

  • Stack

Methods

(static) fromArray(items) → {Witness}

Insantiate witness from an array of buffers.

Parameters:
Name Type Description
items Array.<Buffer>
Source:
Returns:
Type
Witness

(static) fromItems(items) → {Witness}

Insantiate witness from an array of buffers.

Parameters:
Name Type Description
items Array.<Buffer>
Source:
Returns:
Type
Witness

(static) fromStack(stack) → {Witness}

Insantiate witness from a stack.

Parameters:
Name Type Description
stack Stack
Source:
Returns:
Type
Witness

(static) isWitness(obj) → {Boolean}

Test an object to see if it is a Witness.

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

compile() → {Witness}

Compile witness (NOP).

Source:
Returns:
Type
Witness

encode() → {Buffer}

Encode witness.

Source:
Returns:
Type
Buffer

format() → {String}

Inspect a Witness object.

Source:
Returns:

Human-readable script.

Type
String

(private) fromArray(items)

Inject properties from an array of buffers.

Parameters:
Name Type Description
items Array.<Buffer>
Source:

(private) fromItems(items)

Inject properties from an array of buffers.

Parameters:
Name Type Description
items Array.<Buffer>
Source:

fromJSON(json)

Inject properties from json object.

Parameters:
Name Type Description
json Array.<String>
Source:

fromOptions(options) → {this}

Inject properties from options object.

Parameters:
Name Type Description
options Array.<Buffer> | WitnessOptions
Source:
Returns:
Type
this

fromStack(stack)

Inject properties from a stack.

Parameters:
Name Type Description
stack Stack
Source:

fromString(items)

Inject items from string.

Parameters:
Name Type Description
items String | Array.<String>
Source:

getInputAddress() → {Address|null}

"Guess" the address of the witness. This method is not 100% reliable.

Source:
Returns:
Type
Address | null

getInputType() → {ScriptType}

"Guess" the type of the witness. This method is not 100% reliable.

Source:
Returns:
Type
ScriptType

getJSON() → {Array.<String>}

Convert witness to a hex string.

Source:
Returns:
Type
Array.<String>

getMultisigInput() → {Array.<Buffer>|null}

Get multisig signatures key if present. Always returns null.

Source:
Returns:
Type
Array.<Buffer> | null

getPubkeyhashInput() → {Array}

Get P2PKH signature and key if present.

Source:
Returns:

[sig, key]

Type
Array

getPubkeyInput() → {Buffer|null}

Get P2PK signature if present. Always returns null.

Source:
Returns:
Type
Buffer | null

getRedeem() → (nullable) {Script}

Grab and deserialize the redeem script from the witness.

Source:
Returns:

Redeem script.

Type
Script

getScripthashInput() → {Buffer|null}

Get P2SH redeem script if present.

Source:
Returns:
Type
Buffer | null

getSize() → {Number}

Calculate size of the witness excluding the varint size bytes.

Source:
Returns:
Type
Number

getVarSize() → {Number}

Calculate size of the witness including the varint size bytes.

Source:
Returns:
Type
Number

indexOf(data) → {Number}

Find a data element in a witness.

Parameters:
Name Type Description
data Buffer

Data element to match against.

Source:
Returns:

Index (-1 if not present).

Type
Number

inject(witness) → {this}

Inject properties from witness. Used for cloning.

Parameters:
Name Type Description
witness this
Source:
Returns:
Type
this

isMultisigInput() → {Boolean}

"Test" whether the witness is a multisig input. Always returns false.

Source:
Returns:
Type
Boolean

isPubkeyhashInput() → {Boolean}

"Guess" whether the witness is a pubkeyhash input. This method is not 100% reliable.

Source:
Returns:
Type
Boolean

isPubkeyInput() → {Boolean}

"Test" whether the witness is a pubkey input. Always returns false.

Source:
Returns:
Type
Boolean

isScripthashInput() → {Boolean}

"Guess" whether the witness is a scripthash input. This method is not 100% reliable.

Source:
Returns:
Type
Boolean

isUnknownInput() → {Boolean}

"Guess" whether the witness is an unknown/non-standard type. This method is not 100% reliable.

Source:
Returns:
Type
Boolean

read(br)

Inject properties from buffer reader.

Parameters:
Name Type Description
br bio.BufferReader
Source:

test(filter) → {Boolean}

Test the witness against a bloom filter.

Parameters:
Name Type Description
filter BloomFilter
Source:
Returns:
Type
Boolean

toArray() → {Array.<Buffer>}

Convert witness to an array of buffers.

Source:
Returns:
Type
Array.<Buffer>

toItems() → {Array.<Buffer>}

Convert witness to an array of buffers.

Source:
Returns:
Type
Array.<Buffer>

toStack() → {Stack}

Convert witness to a stack.

Source:
Returns:
Type
Stack

write(bw) → {BufioWriter}

Write witness to a buffer writer.

Parameters:
Name Type Description
bw BufioWriter
Source:
Returns:
Type
BufioWriter