Usage: new Script(data)
Description: Instantiate a Script from optional data.
| parameters | type | required | Description |
|---|---|---|---|
| data | Object/string/Buffer | yes | from optional data to populate script |
Returns: {Script} A new instance of a Script
Description: Instantiate a Script from a Buffer
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| buff | Buffer | yes | A Buffer of the script |
Returns: {Script} A new valid instance of Script
Description: Instantiate a Script from ASM
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| str | String | yes |
Returns: {Script} A new valid instance of Script
Description: Instantiate a Script from hex representation
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| str | String | yes |
Returns: {Script} A new valid instance of Script
Description: Instantiate a Script from string representation
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| str | String | yes |
Returns: {Script} A new valid instance of Script
Description: Instantiate a new Multisig output script for the given public keys, requiring m of those public keys to spend
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| publicKeys | PublicKey[] | yes | ist of all public keys controlling the output |
| threshold | Number | yes | amount of required signatures to spend the output |
| opts | Object | no | Several options: - noSorting: defaults to false, if true, don't sort the given public keys before creating the script |
Returns: {Script} a new Multisig output script for given public keys, requiring m of those public keys to spend
Description: Instantiate a new Multisig input script for the given public keys, requiring m of those public keys to spend
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| publicKeys | PublicKey[] | yes | ist of all public keys controlling the output |
| threshold | Number | yes | amount of required signatures to spend the output |
| signatures | Array | yes | signatures and array of signature buffers to append to the script |
| opts | Object | no | Several options: - noSorting: defaults to false, if true, don't sort the given public keys before creating the script |
Returns: {Script} a new Multisig input script for given public keys, requiring m of those public keys to spend
Description: Instantiate a new P2SH Multisig input script for the given public keys, requiring m of those public keys to spend
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| publicKeys | PublicKey[] | yes | ist of all public keys controlling the output |
| threshold | Number | yes | amount of required signatures to spend the output |
| signatures | Array | yes | signatures and array of signature buffers to append to the script |
| opts | Object | no | Several options: - noSorting: defaults to false, if true, don't sort the given public keys before creating the script |
Returns: {Script} a new P2SH Multisig input script for the given public keys, requiring m of those public keys to spend
Description: Instantiate a new pay to public key hash output for the given address or public key
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| to | Address/PublicKey | yes | destination address or public key |
Returns: {Script} a new pay to public key hash output for the given address or public key
Description: Instantiate a new pay to public key output for the given public key
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| pubkey | PublicKey | yes | public key |
Returns: {Script} a new pay to public key output for the given public key
Description: Instantiate a new OP_RETURN script with data
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| data | String/Buffer | yes | the data to embed in the output |
| encoding | String | no | The type of string encoding |
Returns: {Script} a new OP_RETURN script with data
Description: Set Script chunks from provided object. Replace any previous chunks.
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| obj | Object | yes |
Returns: {Script}
Description: Adds a script element at the start of the script.
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| obj | String/Number/Opcode/Buffer/Object | yes | a string, number, Opcode, Buffer, or object to add |
Returns: {Script}
Description: Compares a script with another script
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| script | Script | yes | a script to compare with |
Returns: {Script}
Description: Adds a script element to the end of the script.
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| obj | String/Number/Opcode/Buffer/Object | yes | a string, number, Opcode, Buffer, or object to add |
Returns: {Script}
Description: Will return the public key
Parameters: None.
Returns: {PublicKey}
Description: Will return the public key hash
Parameters: None.
Returns: {PublicKey}
Description: Retrieve the associated data for this script. In the case of a pay to public key hash or P2SH, return the hash. In the case of a standard OP_RETURN, return the data
Parameters: None.
Returns: {Buffer}
Description: Retrieve the Script type if it is a known form, or Script.UNKNOWN if it isn't
Parameters: None.
Returns: {string} - Member of Script.types
Description: Retrieve the Script type if it is a known form, or Script.UNKNOWN if it isn't
Parameters: None.
Returns: {string} - Member of Script.types
Description: Retrieve the Script type if it is a known form, or Script.UNKNOWN if it isn't
Parameters: None.
Returns: {string} - Member of Script.types
Description: Verify if script is one of the known types
Parameters: None.
Returns: {Boolean} - if script is one of the known types
Description: Verify if this is a pay to pubkey hash output script
Parameters: None.
Returns: {Boolean} - if this is a pay to pubkey hash output script
Description: Verify if this is a pay to public key hash input script
Parameters: None.
Returns: {Boolean} - if this is a pay to public key hash input script
Description: Verify if this is a public key output script
Parameters: None.
Returns: {Boolean} - if this is a public key output script
Description: Verify if this is a public key input script
Parameters: None.
Returns: {Boolean} - if this is a public key input script
Description: Verify if this is a p2sh output script
Parameters: None.
Returns: {Boolean} - if this is a p2sh output script
Description: Verify if this is a p2sh input script. These are frequently indistinguishable from pubkeyhashin.
Parameters: None.
Returns: {Boolean} - if this is a p2sh input script
Description: Verify if this is a multisig output script.
Parameters: None.
Returns: {Boolean} - if this is a multisig output script
Description: Verify if this is a multisig input script.
Parameters: None.
Returns: {Boolean} - if this is a multisig input script
Description: Verify if this is a valid standard OP_RETURN output
Parameters: None.
Returns: {Boolean} - if this is a valid standard OP_RETURN output
Description: Verify if the script is only composed of data pushing opcodes or small int opcodes (OP_0, OP_1, ..., OP_16)
Parameters: None.
Returns: {Boolean}
Description: Will return an ASM representation of the script
Parameters: None.
Returns: {String}
Description: Will return an hex representation of the script
Parameters: None.
Returns: {String}
Description: Will return a buffer representation of the script
Parameters: None.
Returns: {Buffer} A buffer of the script
Description: Will return an object representation of the script
Parameters: None.
Returns: {Object} A plain object with the script properties
Description: Will output the stringified script
Parameters: None.
Returns: {string}
Description: Will return a string formatted for the console
Parameters: None.
Returns: {string} Public Key hex representation
const script = new Script(...);
script.toInspect() // <Script: 041ff0fe0f7b15ffaa....>Description: Instantiate a PublicKey from an X Point
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| buf | Buffer | yes | A DER hex buffer |
| compressed | Boolean | no | if set to false, will loosen some conditions |
Returns: {PublicKey} A new valid instance of PublicKey
Description: Instantiate a PublicKey from an X Point
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| point | Point | yes | A Point instance |
| compressed | Boolean | no | whether to store this public key as compressed format |
Returns: {PublicKey} A new valid instance of PublicKey
Description: Instantiate a PublicKey from a Buffer
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| str | String | yes | A DER hex string |
| encoding | String | no | The type of string encoding |
Returns: {PublicKey} A new valid instance of PublicKey
Description: Instantiate a PublicKey from an X Point
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| odd | Boolean | yes | If the point is above or below the x axis |
| x | Point | yes | The x point |
Returns: {PublicKey} A new valid instance of PublicKey
Description: Check if there would be any errors when initializing a PublicKey
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| data | String | yes | The encoded data in various formats |
Returns: {null|Error} An error if exists
Description: Check if the parameters are valid
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| data | String | yes | The encoded data in various formats |
Returns: {Boolean} If the public key would be valid
Description: Will output the PublicKey to a DER encoded hex string
Parameters:
| parameters | type | required | Description |
|---|---|---|---|
| network | String/Network | yes | Which network should the address be for |
Returns: {Address} An address generated from the public key
Description: Will output the PublicKey to a DER Buffer
Parameters: None.
Returns: {Buffer} A DER hex encoded buffer
Description: Will return a buffer representation of the public key
Parameters: None.
Returns: {Buffer} A buffer of the public key
Description: Will return an object representation of the public key
Parameters: None.
Returns: {Object} A plain object with the public key properties
Description: Will output the PublicKey to a DER encoded hex string
Parameters: None.
Returns: {string} A DER hex encoded string
Description: Will return a string formatted for the console
Parameters: None.
Returns: {string} Public Key hex representation
const publicKey = new PublicKey(...);
publicKey.toInspect() // <PublicKey: 041ff0fe0f7b15ffaa....>