Constructor
new Witness(items)
Create a witness.
Extends:
- Stack
Parameters:
Name | Type | Description |
---|---|---|
items |
Array.<Buffer> | Object | 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) fromJSON(json) → {Witness}
Insantiate witness from a hex string.
Parameters:
Name | Type | Description |
---|---|---|
json |
String |
- Source:
Returns:
- Type
- Witness
(static) fromOptions(options) → {Witness}
Instantiate witness from options.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Returns:
- Type
- Witness
(static) fromRaw(data, encnullable) → {Witness}
Create a witness from a serialized buffer.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Buffer | String | Serialized witness. |
|
enc |
String |
<nullable> |
Either |
- Source:
Returns:
- Type
- Witness
(static) fromReader(br)
Create a witness from a buffer reader.
Parameters:
Name | Type | Description |
---|---|---|
br |
BufferReader |
- Source:
(static) fromStack(stack) → {Witness}
Insantiate witness from a stack.
Parameters:
Name | Type | Description |
---|---|---|
stack |
Stack |
- Source:
Returns:
- Type
- Witness
(static) fromString(items) → {Witness}
Parse a test script/array string into a witness object. Must contain only stack items (no non-push opcodes).
Parameters:
Name | Type | Description |
---|---|---|
items |
String | Array.<String> | Script string. |
- Source:
Throws:
Parse error.
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
clone() → {Witness}
Clone the witness object.
- Source:
Returns:
A clone of the current witness object.
- Type
- Witness
compile() → {Witness}
Compile witness (NOP).
- Source:
Returns:
- Type
- Witness
(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:
(private) fromJSON(json)
Inject properties from json object.
Parameters:
Name | Type | Description |
---|---|---|
json |
String |
- Source:
(private) fromOptions(options)
Inject properties from options object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
(private) fromRaw(data)
Inject properties from serialized data.
Parameters:
Name | Type | Description |
---|---|---|
data |
Buffer |
- Source:
(private) fromReader(br)
Inject properties from buffer reader.
Parameters:
Name | Type | Description |
---|---|---|
br |
BufferReader |
- Source:
(private) fromStack(stack)
Inject properties from a stack.
Parameters:
Name | Type | Description |
---|---|---|
stack |
Stack |
- Source:
(private) 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
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() → {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
(private) inject(witness) → {Witness}
Inject properties from witness. Used for cloning.
Parameters:
Name | Type | Description |
---|---|---|
witness |
Witness |
- Source:
Returns:
- Type
- Witness
inspectSymbol() → {String}
Inspect a Witness object.
- Source:
Returns:
Human-readable script.
- Type
- String
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
test(filter) → {Boolean}
Test the witness against a bloom filter.
Parameters:
Name | Type | Description |
---|---|---|
filter |
Bloom |
- 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>
toJSON() → {String}
Convert witness to a hex string.
- Source:
Returns:
- Type
- String
toRaw(enc) → {Buffer|String}
Encode the witness to a Buffer.
Parameters:
Name | Type | Description |
---|---|---|
enc |
String | Encoding, either |
- Source:
Returns:
Serialized script.
- Type
- Buffer | String
toStack() → {Stack}
Convert witness to a stack.
- Source:
Returns:
- Type
- Stack
toWriter(bw)
Write witness to a buffer writer.
Parameters:
Name | Type | Description |
---|---|---|
bw |
BufferWriter |
- Source: