### Build bitcoinjs-lib for Browser
Source: https://bitcoinjs.github.io/bitcoinjs-lib/index.html
Commands to install dependencies and bundle the library into a standalone JavaScript file using browserify.
```bash
$ npm install bitcoinjs-lib browserify
$ npx browserify --standalone bitcoin -o bitcoinjs-lib.js <<< "module.exports = require('bitcoinjs-lib');"
```
--------------------------------
### Import Bundled Library as ESM
Source: https://bitcoinjs.github.io/bitcoinjs-lib/index.html
Example of importing the generated standalone script as an ESM module in a browser environment.
```html
```
--------------------------------
### PSBT Fee and Rate Information
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods to get the fee and fee rate of the transaction.
```APIDOC
## getFee
### Description
Gets the total fee of the transaction.
### Method
getFee
### Returns
bigint
## getFeeRate
### Description
Gets the fee rate of the transaction.
### Method
getFeeRate
### Returns
number
```
--------------------------------
### Library Overview
Source: https://bitcoinjs.github.io/bitcoinjs-lib/modules.html
Overview of the core components available in bitcoinjs-lib v7.0.1.
```APIDOC
## bitcoinjs-lib v7.0.1 Overview
### Namespaces
- address
- crypto
- networks
- payments
- script
### Classes
- Block
- Psbt
- Transaction
### Interfaces
- HDSigner
- HDSignerAsync
- PsbtTxInput
- PsbtTxOutput
- Signer
- SignerAsync
- TxInput
- TxOutput
### Functions
- initEccLib
- toXOnly
```
--------------------------------
### Adding Inputs and Outputs
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods to add inputs and outputs to the PSBT instance.
```APIDOC
## Methods
### addInput
- **inputData** (PsbtInputExtended) - Required - The input data to add.
### addInputs
- **inputDatas** (PsbtInputExtended[]) - Required - An array of input data to add.
### addOutput
- **outputData** (PsbtOutputExtended) - Required - The output data to add.
### addOutputs
- **outputDatas** (PsbtOutputExtended[]) - Required - An array of output data to add.
```
--------------------------------
### Psbt Constructor
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Creates a new instance of the Psbt class.
```APIDOC
## Constructor
### Description
Creates a new Psbt instance.
### Parameters
- **opts** (PsbtOptsOptional) - Optional - Configuration options.
- **data** (Psbt) - Optional - Initial data for the PSBT.
### Response
- **Psbt** (Object) - A new instance of the Psbt class.
```
--------------------------------
### RIPEMD-160 Create Method
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/crypto.ripemd160.html
Explains how to create a new RIPEMD-160 hash instance.
```APIDOC
## Method create
### create
* **create()** - Returns: Hash
* Description: Creates a new instance of the RIPEMD160 hash object.
```
--------------------------------
### Static PSBT Factory Methods
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods to instantiate a PSBT object from different data formats.
```APIDOC
## Static Factory Methods
### Methods
- **fromBase64(data, opts?)** - Creates a Psbt from a base64 string.
- **fromBuffer(buffer, opts?)** - Creates a Psbt from a buffer.
- **fromHex(data, opts?)** - Creates a Psbt from a hex string.
### Parameters
- **data/buffer** (string/Uint8Array) - Required - The serialized PSBT data.
- **opts** (PsbtOptsOptional) - Optional - Configuration options.
### Response
- **Psbt** - Returns a new Psbt instance.
```
--------------------------------
### SHA256 Create Method
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/crypto.sha256.html
Details on how to create a SHA256 hash instance.
```APIDOC
## Method create
### create
* **create()**: Hash
### Returns
* **Hash** - A new instance of the SHA256 hash object.
```
--------------------------------
### Function initEccLib
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/initEccLib.html
Initializes or clears the ECC library instance used by bitcoinjs-lib.
```APIDOC
## initEccLib
### Description
Initializes the ECC library with the provided instance. If `eccLib` is `undefined`, the library will be cleared. If `eccLib` is a new instance, it will be verified before setting it as the active library.
### Parameters
- **eccLib** (undefined | TinySecp256k1Interface) - Required - The instance of the ECC library to initialize.
- **opts** (object) - Optional - Extra initialization options.
- **DANGER_DO_NOT_VERIFY_ECCLIB** (boolean) - Optional - If true, skips ECC verification. Not recommended.
### Returns
- **void**
```
--------------------------------
### Function fromOutputScript
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/address.fromOutputScript.html
Converts an output script to a Bitcoin address.
```APIDOC
## Function fromOutputScript
### Description
Converts an output script to a Bitcoin address.
### Method
N/A (This is a function, not an API endpoint)
### Endpoint
N/A
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
N/A
### Response
#### Success Response (200)
- **string** - The Bitcoin address corresponding to the output script.
#### Response Example
N/A
### Throws
If the output script has no matching address.
```
--------------------------------
### Block Static Methods
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Block.html
Static utility methods for the Block class, including Merkle root calculation and block instantiation from buffers or hex strings.
```APIDOC
## Block Static Methods
### calculateMerkleRoot
- **Parameters**:
- **transactions** (Transaction[]) - Required
- **forWitness** (boolean) - Optional
- **Returns**: Uint8Array
### calculateTarget
- **Parameters**:
- **bits** (number) - Required
- **Returns**: Uint8Array
### fromBuffer
- **Parameters**:
- **buffer** (Uint8Array) - Required
- **Returns**: Block
### fromHex
- **Parameters**:
- **hex** (string) - Required
- **Returns**: Block
```
--------------------------------
### toOutputScript Function
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/address.toOutputScript.html
Converts a Bitcoin address to its corresponding output script.
```APIDOC
## Function toOutputScript
### Description
Converts a Bitcoin address to its corresponding output script.
### Method
N/A (This is a function, not an API endpoint)
### Endpoint
N/A
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
N/A
### Response
#### Success Response (200)
- **outputScript** (Uint8Array) - The corresponding output script as a Buffer.
#### Response Example
N/A
### Throws
- If the address has an invalid prefix or no matching script.
```
--------------------------------
### p2wpkh Payment Object Creation
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/payments.p2wpkh.html
This snippet demonstrates how to create a p2wpkh payment object using the `p2wpkh` function.
```APIDOC
## Function p2wpkh
### Description
Creates a pay-to-witness-public-key-hash (p2wpkh) payment object.
### Method
N/A (This is a function call, not an HTTP endpoint)
### Endpoint
N/A
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Parameters
* **a** (Payment) - Required - The payment object containing the necessary data.
* **opts** (PaymentOpts) - Optional - Optional payment options.
### Returns
* **Payment** - The p2wpkh payment object.
### Throws
If the required data is missing or invalid.
### Request Example
```javascript
// Assuming 'payment' and 'paymentOpts' are defined elsewhere
const p2wpkhPayment = bitcoin.payments.p2wpkh(payment, paymentOpts);
```
### Response
#### Success Response (200)
N/A (This is a function return value, not an HTTP response)
#### Response Example
```javascript
// Example of a returned Payment object structure (simplified)
{
name: 'p2wpkh',
pubkey: Buffer.from('...'),
address: 'tb1q...'
}
```
```
--------------------------------
### Interface PaymentOpts
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/payments.PaymentOpts.html
Defines the optional configuration properties for payment operations in bitcoinjs-lib.
```APIDOC
## Interface PaymentOpts
### Description
Configuration options for payment operations.
### Properties
- **allowIncomplete** (boolean) - Optional - If true, allows the creation of incomplete payments.
- **validate** (boolean) - Optional - If true, enables validation for the payment operation.
```
--------------------------------
### P2WSH Payment Creation
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/payments.p2wsh.html
This snippet demonstrates how to create a P2WSH payment object using the `p2wsh` function.
```APIDOC
## Function p2wsh
### Description
Creates a Pay-to-Witness-Script-Hash (P2WSH) payment object.
### Method
N/A (This is a function call, not an HTTP endpoint)
### Endpoint
N/A
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
```javascript
// Assuming 'payment' and 'paymentOpts' are defined elsewhere
p2wsh(payment, paymentOpts);
```
### Response
#### Success Response (Payment Object)
- **Payment** - The P2WSH payment object.
#### Response Example
```javascript
// Example of a Payment object structure (actual structure may vary)
{
name: 'p2wsh',
payment: {
// ... payment details ...
}
}
```
#### Throws
If the required data is missing or invalid.
```
--------------------------------
### Global and Index-based Key-Value Additions
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods to add unknown key-value pairs to the global PSBT or specific inputs/outputs.
```APIDOC
## Methods
### addUnknownKeyValToGlobal
- **keyVal** (KeyValue) - Required - The key-value pair to add to the global scope.
### addUnknownKeyValToInput
- **inputIndex** (number) - Required - The index of the input.
- **keyVal** (KeyValue) - Required - The key-value pair to add.
### addUnknownKeyValToOutput
- **outputIndex** (number) - Required - The index of the output.
- **keyVal** (KeyValue) - Required - The key-value pair to add.
```
--------------------------------
### Namespace networks
Source: https://bitcoinjs.github.io/bitcoinjs-lib/modules/networks.html
Overview of the network configuration module used for defining Bitcoin and variant network parameters.
```APIDOC
## Namespace networks
### Description
This module defines the network configurations for Bitcoin and its variants, including message prefixes, Bech32 address format, BIP32 key derivation prefixes, and other address-related configurations. It supports Bitcoin, Bitcoin testnet, and Bitcoin regtest networks.
### Interfaces
- **Network**: Defines the structure for network-specific configurations.
### Variables
- **bitcoin**: Configuration object for the Bitcoin mainnet.
- **regtest**: Configuration object for the Bitcoin regtest network.
- **testnet**: Configuration object for the Bitcoin testnet.
```
--------------------------------
### Function toStack
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/script.toStack.html
Converts the given chunks into a stack of buffers.
```APIDOC
## toStack
### Description
Converts the given chunks into a stack of buffers.
### Parameters
#### Path Parameters
- **chunks** (Uint8Array | (number | Uint8Array)[]) - Required - The chunks to convert.
### Returns
- **Uint8Array[]** - The stack of buffers.
```
--------------------------------
### PSBT Input Signing
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods for signing all inputs or specific inputs of a PSBT, supporting both synchronous and asynchronous operations, and HD key signing.
```APIDOC
## signAllInputs
### Description
Signs all inputs of the PSBT using a provided key pair.
### Method
signAllInputs
### Parameters
- **keyPair** (Signer) - The key pair for signing.
- **sighashTypes** (number[]) - Optional. Array of sighash types to use.
### Returns
this
## signAllInputsAsync
### Description
Asynchronously signs all inputs of the PSBT using a provided key pair.
### Method
signAllInputsAsync
### Parameters
- **keyPair** (Signer | SignerAsync) - The key pair for signing.
- **sighashTypes** (number[]) - Optional. Array of sighash types to use.
### Returns
Promise
## signAllInputsHD
### Description
Signs all inputs of the PSBT using an HD key pair.
### Method
signAllInputsHD
### Parameters
- **hdKeyPair** (HDSigner) - The HD key pair for signing.
- **sighashTypes** (number[]) - Array of sighash types to use.
### Returns
this
## signAllInputsHDAsync
### Description
Asynchronously signs all inputs of the PSBT using an HD key pair.
### Method
signAllInputsHDAsync
### Parameters
- **hdKeyPair** (HDSigner | HDSignerAsync) - The HD key pair for signing.
- **sighashTypes** (number[]) - Array of sighash types to use.
### Returns
Promise
## signInput
### Description
Signs a specific input of the PSBT using a provided key pair.
### Method
signInput
### Parameters
- **inputIndex** (number) - The index of the input to sign.
- **keyPair** (Signer) - The key pair for signing.
- **sighashTypes** (number[]) - Optional. Array of sighash types to use.
### Returns
this
## signInputAsync
### Description
Asynchronously signs a specific input of the PSBT using a provided key pair.
### Method
signInputAsync
### Parameters
- **inputIndex** (number) - The index of the input to sign.
- **keyPair** (Signer | SignerAsync) - The key pair for signing.
- **sighashTypes** (number[]) - Optional. Array of sighash types to use.
### Returns
Promise
## signInputHD
### Description
Signs a specific input of the PSBT using an HD key pair.
### Method
signInputHD
### Parameters
- **inputIndex** (number) - The index of the input to sign.
- **hdKeyPair** (HDSigner) - The HD key pair for signing.
- **sighashTypes** (number[]) - Array of sighash types to use.
### Returns
this
## signInputHDAsync
### Description
Asynchronously signs a specific input of the PSBT using an HD key pair.
### Method
signInputHDAsync
### Parameters
- **inputIndex** (number) - The index of the input to sign.
- **hdKeyPair** (HDSigner | HDSignerAsync) - The HD key pair for signing.
- **sighashTypes** (number[]) - Array of sighash types to use.
### Returns
Promise
## signTaprootInput
### Description
Signs a Taproot input of the PSBT using a provided key pair.
### Method
signTaprootInput
### Parameters
- **inputIndex** (number) - The index of the input to sign.
- **keyPair** (Signer) - The key pair for signing.
- **tapLeafHashToSign** (Uint8Array) - Optional. The Taproot leaf hash to sign.
- **sighashTypes** (number[]) - Optional. Array of sighash types to use.
### Returns
this
## signTaprootInputAsync
### Description
Asynchronously signs a Taproot input of the PSBT using a provided key pair.
### Method
signTaprootInputAsync
### Parameters
- **inputIndex** (number) - The index of the input to sign.
- **keyPair** (Signer | SignerAsync) - The key pair for signing.
- **tapLeafHash** (Uint8Array) - Optional. The Taproot leaf hash.
- **sighashTypes** (number[]) - Optional. Array of sighash types to use.
### Returns
Promise
```
--------------------------------
### Block Class Methods
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Block.html
Instance methods for the Block class to retrieve block data, verify proof-of-work, and serialize block information.
```APIDOC
## Block Instance Methods
### byteLength
- **Parameters**:
- **headersOnly** (boolean) - Optional
- **allowWitness** (boolean) - Optional, default: true
- **Returns**: number
### checkProofOfWork
- **Returns**: boolean
### checkTxRoots
- **Returns**: boolean
### getHash
- **Returns**: Uint8Array
### getId
- **Returns**: string
### getUTCDate
- **Returns**: Date
### getWitnessCommit
- **Returns**: null | Uint8Array
### hasWitness
- **Returns**: boolean
### hasWitnessCommit
- **Returns**: boolean
### toBuffer
- **Parameters**:
- **headersOnly** (boolean) - Optional
- **Returns**: Uint8Array
### toHex
- **Parameters**:
- **headersOnly** (boolean) - Optional
- **Returns**: string
### weight
- **Returns**: number
```
--------------------------------
### P2SH Payment Creation
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/payments.p2sh.html
This snippet details how to create a P2SH payment object using the `p2sh` function.
```APIDOC
## Function p2sh
### Description
Creates a Pay-to-Script-Hash (P2SH) payment object.
### Method
N/A (This is a function call, not an HTTP endpoint)
### Endpoint
N/A
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Parameters
* **a** (Payment) - Required - The payment object containing the necessary data.
* **opts** (PaymentOpts) - Optional - Optional payment options.
### Returns
* **Payment** - The P2SH payment object.
### Throws
If the required data is not provided or if the data is invalid.
### Request Example
```javascript
// Example usage (assuming Payment and PaymentOpts are defined elsewhere)
const payment = p2sh(paymentData, paymentOptions);
```
### Response
#### Success Response (200)
* **Payment** (object) - The created P2SH payment object.
#### Response Example
```json
{
"payment": "{... P2SH payment details ...}"
}
```
```
--------------------------------
### Function p2pk
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/payments.p2pk.html
Creates a pay-to-public-key (P2PK) payment object.
```APIDOC
## p2pk(a, opts?)
### Description
Creates a pay-to-public-key (P2PK) payment object.
### Parameters
#### Path Parameters
- **a** (Payment) - Required - The payment object containing the necessary data.
- **opts** (PaymentOpts) - Optional - Optional payment options.
### Returns
- **Payment** - The P2PK payment object.
### Throws
- Throws an error if the required data is not provided or if the data is invalid.
```
--------------------------------
### Function toXOnly
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/toXOnly.html
Converts a public key to an X-only public key.
```APIDOC
## Function toXOnly
### Description
Converts a public key to an X-only public key.
### Parameters
- **pubKey** (Uint8Array) - Required - The public key to convert.
### Returns
- **Uint8Array** - The X-only public key.
```
--------------------------------
### PSBT Sequence and Locktime Settings
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods to set the sequence number for inputs and the locktime for the transaction.
```APIDOC
## setInputSequence
### Description
Sets the sequence number for a specific input.
### Method
setInputSequence
### Parameters
- **inputIndex** (number) - The index of the input.
- **sequence** (number) - The sequence number to set.
### Returns
this
## setLocktime
### Description
Sets the locktime for the transaction.
### Method
setLocktime
### Parameters
- **locktime** (number) - The locktime value to set.
### Returns
this
```
--------------------------------
### Bitcoin Network Configuration
Source: https://bitcoinjs.github.io/bitcoinjs-lib/variables/networks.bitcoin.html
Details regarding the bitcoin network constant used for configuration.
```APIDOC
## Variable bitcoin
### Description
Represents the Bitcoin network configuration used by the library.
### Type
Network
```
--------------------------------
### TxInput Interface
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/TxInput.html
Defines the structure of a transaction input in bitcoinjs-lib.
```APIDOC
## Interface TxInput
### Description
Represents a transaction input in the Bitcoin protocol.
### Properties
- **hash** (Uint8Array) - The transaction hash of the previous output.
- **index** (number) - The output index of the previous transaction.
- **script** (Uint8Array) - The scriptSig or witness script.
- **sequence** (number) - The sequence number, typically used for nLockTime.
- **witness** (Uint8Array[]) - The witness data for SegWit transactions.
```
--------------------------------
### PSBT Manipulation Methods
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods for cloning, combining, and extracting transaction data from a PSBT.
```APIDOC
## clone
### Description
Creates a deep clone of the PSBT.
### Method
clone
### Returns
Psbt
## combine
### Description
Combines multiple PSBTs into the current one.
### Method
combine
### Parameters
- **...those** (Psbt[]) - The PSBTs to combine.
### Returns
this
## extractTransaction
### Description
Extracts the unsigned transaction from the PSBT. Optionally disables fee checks.
### Method
extractTransaction
### Parameters
- **disableFeeCheck** (boolean) - Optional. If true, fee checks are disabled.
### Returns
Transaction
```
--------------------------------
### Interface TxOutput
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/TxOutput.html
Definition of the TxOutput interface used for transaction outputs.
```APIDOC
## Interface TxOutput
### Description
Represents a transaction output containing a script and a value.
### Properties
- **script** (Uint8Array) - The output script.
- **value** (bigint) - The value of the output.
```
--------------------------------
### Function p2pkh
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/payments.p2pkh.html
Creates a Pay-to-Public-Key-Hash (P2PKH) payment object.
```APIDOC
## p2pkh(a, opts?)
### Description
Creates a Pay-to-Public-Key-Hash (P2PKH) payment object.
### Parameters
- **a** (Payment) - Required - The payment object containing the necessary data.
- **opts** (PaymentOpts) - Optional - Optional payment options.
### Returns
- **Payment** - The P2PKH payment object.
### Throws
- Throws an error if the required data is not provided or if the data is invalid.
```
--------------------------------
### HDSigner Interface
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/HDSigner.html
The HDSigner interface provides methods for hierarchical deterministic key management.
```APIDOC
## Interface HDSigner
An interface for hierarchical deterministic signing.
### Hierarchy
- HDSignerBase
- HDSigner
### Properties
- **fingerprint** (Uint8Array) - The first 4 bytes of the sha256-ripemd160 of the publicKey.
- **publicKey** (Uint8Array) - DER format compressed publicKey buffer.
### Methods
- **derivePath**(path: string): HDSigner
- Derives a new HDSigner instance for the given path.
- The path string must match /^m(/\d+'?)+\/$/ ex. m/44'/0'/0'/1/23 levels with ' must be hard derivations.
#### Parameters
- **path** (string) - The derivation path.
#### Returns
- HDSigner - A new HDSigner instance.
- **sign**(hash: Uint8Array): Uint8Array
- Signs the provided hash.
- Input hash (the "message digest") for the signature algorithm.
#### Parameters
- **hash** (Uint8Array) - The hash to sign.
#### Returns
- Uint8Array - A 64 byte signature (32 byte r and 32 byte s in that order).
```
--------------------------------
### Interface PsbtTxInput
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/PsbtTxInput.html
Defines the properties required for a PSBT transaction input.
```APIDOC
## PsbtTxInput Interface
### Description
Represents an input for a Partially Signed Bitcoin Transaction (PSBT). This interface extends TransactionInput.
### Properties
- **hash** (Uint8Array) - The transaction hash of the input.
- **index** (number) - The output index of the previous transaction.
- **sequence** (number) - Optional. The sequence number for the input.
```
--------------------------------
### Crypto Namespace Functions
Source: https://bitcoinjs.github.io/bitcoinjs-lib/modules/crypto.html
Overview of the available cryptographic hashing functions provided by the crypto module.
```APIDOC
## Crypto Namespace Functions
### Description
The crypto module provides a set of standard hashing functions used within the bitcoinjs-lib library.
### Functions
- **hash160**: Computes the RIPEMD160(SHA256(data)) hash.
- **hash256**: Computes the SHA256(SHA256(data)) hash.
- **ripemd160**: Computes the RIPEMD160 hash.
- **sha1**: Computes the SHA1 hash.
- **sha256**: Computes the SHA256 hash.
- **taggedHash**: Computes a tagged hash as defined in BIP340.
### Variables
- **TAGGED_HASH_PREFIXES**: A collection of prefixes used for tagged hashing.
- **TAGS**: Constants related to tagged hashing.
```
--------------------------------
### Script Namespace Functions
Source: https://bitcoinjs.github.io/bitcoinjs-lib/modules/script.html
Overview of available functions for script processing and validation within the bitcoinjs-lib script module.
```APIDOC
## Script Namespace Functions
### Description
Provides utilities for working with Bitcoin scripts, including decompiling, compiling, converting to/from ASM, stack manipulation, and script validation.
### Functions
- **compile**: Compiles script tokens into a Buffer.
- **countNonPushOnlyOPs**: Counts operations that are not push operations.
- **decompile**: Decompiles a Buffer into script tokens.
- **fromASM**: Converts an ASM string to a Buffer.
- **isCanonicalPubKey**: Validates if a public key is canonical.
- **isCanonicalScriptSignature**: Validates if a script signature is canonical.
- **isDefinedHashType**: Checks if a hash type is defined.
- **isPushOnly**: Checks if a script is push-only.
- **toASM**: Converts a Buffer to an ASM string.
- **toStack**: Converts a script Buffer to a stack array.
```
--------------------------------
### PSBT Input/Output Information
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods to check for HD keys or public keys in PSBT inputs and outputs.
```APIDOC
## getInputType
### Description
Gets the script type of a specific input.
### Method
getInputType
### Parameters
- **inputIndex** (number) - The index of the input.
### Returns
AllScriptType
## inputHasHDKey
### Description
Checks if a specific input contains an HD key.
### Method
inputHasHDKey
### Parameters
- **inputIndex** (number) - The index of the input.
- **root** (HDSigner) - The root HD key to check against.
### Returns
boolean
## inputHasPubkey
### Description
Checks if a specific input contains a given public key.
### Method
inputHasPubkey
### Parameters
- **inputIndex** (number) - The index of the input.
- **pubkey** (Uint8Array) - The public key to check for.
### Returns
boolean
## outputHasHDKey
### Description
Checks if a specific output contains an HD key.
### Method
outputHasHDKey
### Parameters
- **outputIndex** (number) - The index of the output.
- **root** (HDSigner) - The root HD key to check against.
### Returns
boolean
## outputHasPubkey
### Description
Checks if a specific output contains a given public key.
### Method
outputHasPubkey
### Parameters
- **outputIndex** (number) - The index of the output.
- **pubkey** (Uint8Array) - The public key to check for.
### Returns
boolean
```
--------------------------------
### Address Encoding and Decoding Functions
Source: https://bitcoinjs.github.io/bitcoinjs-lib/modules/address.html
Functions for converting between address formats and output scripts.
```APIDOC
## Functions
### fromBase58Check
Decodes a Base58Check encoded address.
### fromBech32
Decodes a Bech32 encoded address.
### fromOutputScript
Decodes an output script into an address.
### toBase58Check
Encodes data into a Base58Check address.
### toBech32
Encodes data into a Bech32 address.
### toOutputScript
Encodes an address into an output script.
```
--------------------------------
### PsbtTxOutput Interface
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/PsbtTxOutput.html
Defines the structure for transaction outputs within a PSBT (Partially Signed Bitcoin Transaction).
```APIDOC
## Interface PsbtTxOutput
### Description
Represents a transaction output within a Partially Signed Bitcoin Transaction (PSBT).
### Hierarchy
* TransactionOutput
* PsbtTxOutput
### Properties
#### address
- **Type**: `undefined | string`
- **Description**: The address associated with the output, if available.
#### script
- **Type**: `Uint8Array`
- **Description**: The scriptPubKey of the output.
#### value
- **Type**: `bigint`
- **Description**: The value (in satoshis) of the output.
```
--------------------------------
### Payment Interface
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/payments.Payment.html
Details the structure and properties of the Payment interface.
```APIDOC
## Interface Payment
This interface defines the structure for payment-related data within the bitcoinjs-lib.
### Properties
- **address** (string) - Optional - The payment address.
- **data** (Uint8Array[]) - Optional - Associated data.
- **hash** (Uint8Array) - Optional - The hash of the payment.
- **input** (Uint8Array) - Optional - The input script.
- **internalPubkey** (Uint8Array) - Optional - The internal public key.
- **m** (number) - Optional - The minimum number of signatures required (for multisig).
- **n** (number) - Optional - The total number of public keys (for multisig).
- **name** (string) - Optional - A descriptive name for the payment.
- **network** (Network) - Optional - The network configuration (e.g., mainnet, testnet).
- **output** (Uint8Array) - Optional - The output script.
- **pubkey** (Uint8Array) - Optional - The public key.
- **pubkeys** (Uint8Array[]) - Optional - An array of public keys.
- **redeem** (Payment) - Optional - Nested payment details for redeem scripts.
- **redeemVersion** (number) - Optional - The version of the redeem script.
- **scriptTree** (Taptree) - Optional - The tapscript tree for Taproot.
- **signature** (Uint8Array) - Optional - A single signature.
- **signatures** (Uint8Array[]) - Optional - An array of signatures.
- **witness** (Uint8Array[]) - Optional - The witness data.
```
--------------------------------
### SignerAsync Interface
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/SignerAsync.html
Details the properties and methods available for the SignerAsync interface.
```APIDOC
## Interface SignerAsync
### Description
Represents an asynchronous signer capable of signing cryptographic hashes.
### Properties
- **network** (any) - Optional - The network configuration.
- **publicKey** (Uint8Array) - Required - The public key associated with the signer.
### Methods
- **getPublicKey?()**: Uint8Array - Optional method to retrieve the public key.
- **sign**(hash: Uint8Array, lowR?: boolean): Promise - Signs a hash using the signer. The `lowR` parameter is optional.
- **signSchnorr?**(hash: Uint8Array): Promise - Optional method to sign a hash using the Schnorr signature algorithm.
```
--------------------------------
### PSBT Serialization
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods for serializing the PSBT into different formats.
```APIDOC
## toBase64
### Description
Serializes the PSBT to a Base64 string.
### Method
toBase64
### Returns
string
## toBuffer
### Description
Serializes the PSBT to a buffer (Uint8Array).
### Method
toBuffer
### Returns
Uint8Array
## toHex
### Description
Serializes the PSBT to a hexadecimal string.
### Method
toHex
### Returns
string
```
--------------------------------
### PSBT Version Setting
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Method to set the version of the transaction.
```APIDOC
## setVersion
### Description
Sets the version of the transaction.
### Method
setVersion
### Parameters
- **version** (number) - The transaction version.
### Returns
this
```
--------------------------------
### toBech32 Function
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/address.toBech32.html
Converts a buffer to a Bech32 or Bech32m encoded string.
```APIDOC
## Function toBech32
### Description
Converts a buffer to a Bech32 or Bech32m encoded string.
### Parameters
#### Path Parameters
- **data** (Uint8Array) - Required - The buffer to be encoded.
- **version** (number) - Required - The version number to be used in the encoding.
- **prefix** (string) - Required - The prefix string to be used in the encoding.
### Returns
- **string** - The Bech32 or Bech32m encoded string.
```
--------------------------------
### p2tr Function
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/payments.p2tr.html
Creates a Pay-to-Taproot (P2TR) payment object.
```APIDOC
## p2tr
### Description
Creates a Pay-to-Taproot (P2TR) payment object.
### Parameters
- **a** (Payment) - Required - The payment object containing the necessary data for P2TR.
- **opts** (PaymentOpts) - Optional - Optional payment options.
### Returns
- **Payment** - The P2TR payment object.
### Throws
- If the provided data is invalid or insufficient.
```
--------------------------------
### Namespace payments
Source: https://bitcoinjs.github.io/bitcoinjs-lib/modules/payments.html
Provides functionality for creating and managing Bitcoin payment objects. This module supports multiple Bitcoin address types for payments, including P2PKH, P2SH, P2WPKH, P2WSH, and P2TR.
```APIDOC
## Namespace: payments
### Description
Provides functionality for creating and managing Bitcoin payment objects. This module supports multiple Bitcoin address types for payments, including:
* P2PKH (Pay-to-PubKey-Hash)
* P2SH (Pay-to-Script-Hash)
* P2WPKH (Pay-to-Witness-PubKey-Hash)
* P2WSH (Pay-to-Witness-Script-Hash)
* P2TR (Taproot)
The `Payment` interface defines the structure of a payment object used for constructing various payment types, with fields for signatures, public keys, redeem scripts, and more.
### Interfaces
- Payment
- PaymentOpts
### Type Aliases
- PaymentCreator
- PaymentFunction
- Stack
- StackElement
- StackFunction
### Functions
- embed
- p2ms
- p2pk
- p2pkh
- p2sh
- p2tr
- p2wpkh
- p2wsh
```
--------------------------------
### Address Conversion - fromBech32
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/address.fromBech32.html
Converts a Bech32 or Bech32m encoded address to its corresponding data representation.
```APIDOC
## Function fromBech32
### Description
Converts a Bech32 or Bech32m encoded address to its corresponding data representation.
### Method
N/A (This is a library function, not an API endpoint)
### Endpoint
N/A
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
```javascript
// Example usage (assuming bitcoinjs-lib is imported)
// const { fromBech32 } = require('bitcoinjs-lib');
// const address = 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq';
// const decoded = fromBech32(address);
// console.log(decoded);
```
### Response
#### Success Response (Bech32Result)
An object containing the version, prefix, and data of the address.
- **version** (number) - The version byte of the address.
- **prefix** (string) - The human-readable part (HRP) of the address.
- **data** (Buffer) - The witness program or script hash.
#### Response Example
```json
{
"version": 0,
"prefix": "bc",
"data":
}
```
#### Throws
If the address uses the wrong encoding.
```
--------------------------------
### Function toASM
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/script.toASM.html
Converts script chunks into an ASM string representation.
```APIDOC
## toASM(chunks)
### Description
Converts the given chunks into an ASM (Assembly) string representation. If the chunks parameter is a Buffer, it will be decompiled into a Stack before conversion.
### Parameters
- **chunks** (Uint8Array | (number | Uint8Array)[]) - Required - The chunks to convert into ASM.
### Returns
- **string** - The ASM string representation of the chunks.
```
--------------------------------
### Function fromASM
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/script.fromASM.html
Converts an ASM string to a Uint8Array buffer.
```APIDOC
## fromASM
### Description
Converts an ASM string to a Uint8Array.
### Parameters
#### Path Parameters
- **asm** (string) - Required - The ASM string to convert.
### Response
#### Success Response (200)
- **result** (Uint8Array) - The converted Buffer.
```
--------------------------------
### PSBT Fee Rate Configuration
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Method to set the maximum allowed fee rate for the transaction.
```APIDOC
## setMaximumFeeRate
### Description
Sets the maximum fee rate (satoshi per byte) for the transaction.
### Method
setMaximumFeeRate
### Parameters
- **satoshiPerByte** (number) - The maximum fee rate in satoshi per byte.
### Returns
void
```
--------------------------------
### Transaction Serialization
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Transaction.html
Methods for converting transaction objects to and from buffers or hex strings.
```APIDOC
## toBuffer
### Description
Serializes the transaction to a buffer.
### Parameters
#### Parameters
- **buffer** (Uint8Array) - Optional - Target buffer.
- **initialOffset** (number) - Optional - Offset in the buffer.
### Response
- **Returns** (Uint8Array) - The serialized transaction.
## fromHex
### Description
Creates a Transaction instance from a hex string.
### Parameters
#### Parameters
- **hex** (string) - Required - The hex-encoded transaction.
### Response
- **Returns** (Transaction) - The parsed transaction object.
```
--------------------------------
### PSBT Global and Input Updates
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Methods for updating global transaction data and specific input data within a PSBT.
```APIDOC
## updateGlobal
### Description
Updates global transaction data in the PSBT.
### Method
updateGlobal
### Parameters
- **updateData** (PsbtGlobalUpdate) - An object containing the global data to update.
### Returns
this
## updateInput
### Description
Updates data for a specific input in the PSBT.
### Method
updateInput
### Parameters
- **inputIndex** (number) - The index of the input to update.
- **updateData** (PsbtInputUpdate) - An object containing the input data to update.
### Returns
this
```
--------------------------------
### Function toBase58Check
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/address.toBase58Check.html
Converts a hash to a Base58Check-encoded string using a provided version byte.
```APIDOC
## toBase58Check
### Description
Converts a hash to a Base58Check-encoded string.
### Parameters
- **hash** (Uint8Array) - Required - The hash to be encoded.
- **version** (number) - Required - The version byte to be prepended to the encoded string.
### Returns
- **string** - The Base58Check-encoded string.
```
--------------------------------
### Function decompile
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/script.decompile.html
Decompiles a script buffer into an array of chunks.
```APIDOC
## Function decompile
### Description
Decompiles a script buffer into an array of chunks.
### Method
N/A (This is a function, not an API endpoint)
### Endpoint
N/A
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
N/A
### Response
#### Success Response (200)
- **(number | Uint8Array)[] | null** - The decompiled chunks or null if decompilation fails.
#### Response Example
N/A
### Parameters
#### buffer
- **buffer** (Uint8Array | (number | Uint8Array)[]) - Required - The script buffer to decompile.
```
--------------------------------
### HDSignerAsync Interface
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/HDSignerAsync.html
The HDSignerAsync interface provides an asynchronous signing capability, extending the functionality of HDSignerBase.
```APIDOC
## Interface HDSignerAsync
Same as above but with async sign method
### Properties
- **fingerprint** (Uint8Array)
- **publicKey** (Uint8Array)
### Methods
- **derivePath**(path: string): HDSignerAsync
- **sign**(hash: Uint8Array): Promise
### Hierarchy
- HDSignerBase
- HDSignerAsync
## Properties
### fingerprint
- **fingerprint** (Uint8Array) - The first 4 bytes of the sha256-ripemd160 of the publicKey
### publicKey
- **publicKey** (Uint8Array) - DER format compressed publicKey buffer
## Methods
### derivePath
#### Description
Derives a child key from the current HD key using the specified path.
#### Parameters
- **path** (string) - The derivation path (e.g., "m/44'/0'/0'/0/0").
#### Returns
- **HDSignerAsync** - A new HDSignerAsync instance representing the derived key.
### sign
#### Description
Asynchronously signs a given hash using the private key associated with this HD signer.
#### Parameters
- **hash** (Uint8Array) - The hash to be signed.
#### Returns
- **Promise** - A promise that resolves to the signature as a Uint8Array.
```
--------------------------------
### RIPEMD-160 Properties
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/crypto.ripemd160.html
Details the properties of the RIPEMD-160 hash algorithm, such as block length and output length.
```APIDOC
## Properties
### blockLen
* **blockLen** (number) - The block length of the hash algorithm.
### outputLen
* **outputLen** (number) - The output length (digest size) of the hash algorithm.
```
--------------------------------
### Function fromBase58Check
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/address.fromBase58Check.html
Decodes a base58check encoded Bitcoin address and returns the version and hash.
```APIDOC
## fromBase58Check(address)
### Description
Decodes a base58check encoded Bitcoin address and returns the version and hash.
### Parameters
#### Path Parameters
- **address** (string) - Required - The base58check encoded Bitcoin address to decode.
### Returns
- **Base58CheckResult** (object) - An object containing the version and hash of the decoded address.
### Throws
- If the address is too short or too long.
```
--------------------------------
### Function p2ms
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/payments.p2ms.html
Creates a Pay-to-Multisig (P2MS) payment object.
```APIDOC
## p2ms(a, opts?)
### Description
Creates a Pay-to-Multisig (P2MS) payment object.
### Parameters
- **a** (Payment) - Required - The payment object.
- **opts** (PaymentOpts) - Optional - Optional payment options.
### Returns
- **Payment** - The created payment object.
### Throws
- If the provided data is not valid.
```
--------------------------------
### Compile Script Chunks
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/script.compile.html
The compile function takes an array of script chunks and returns a compiled Uint8Array. It can throw an error if compilation fails.
```APIDOC
## compile(chunks)
### Description
Compiles an array of script chunks into a Uint8Array.
### Method
N/A (This is a function signature, not an HTTP endpoint)
### Endpoint
N/A
### Parameters
#### Path Parameters
N/A
#### Query Parameters
N/A
#### Request Body
- **chunks** (Uint8Array | Stack) - Required - The chunks to compile.
### Request Example
N/A
### Response
#### Success Response (200)
- **Uint8Array** - The compiled script as a Uint8Array.
#### Response Example
N/A
### Throws
Error if compilation fails.
```
--------------------------------
### TAGS Constant Reference
Source: https://bitcoinjs.github.io/bitcoinjs-lib/variables/crypto.TAGS.html
Documentation for the readonly TAGS constant used in bitcoinjs-lib.
```APIDOC
## TAGS Constant
### Description
A readonly constant containing a list of tags used for cryptographic operations within the library, including BIP0340 and Taproot related identifiers.
### Values
- **BIP0340/challenge**
- **BIP0340/aux**
- **BIP0340/nonce**
- **TapLeaf**
- **TapBranch**
- **TapSighash**
- **TapTweak**
- **KeyAgg list**
- **KeyAgg coefficient**
```
--------------------------------
### Interface Bech32Result
Source: https://bitcoinjs.github.io/bitcoinjs-lib/interfaces/address.Bech32Result.html
Defines the structure of the object returned after decoding a Bech32 address.
```APIDOC
## Interface Bech32Result
### Description
Represents the result of a Bech32 decoding operation.
### Properties
- **data** (Uint8Array) - Address data: 20 bytes for P2WPKH, 32 bytes for P2WSH or P2TR.
- **prefix** (string) - Address prefix: 'bc' for P2WPKH, P2WSH, or P2TR.
- **version** (number) - Address version: 0x00 for P2WPKH or P2WSH, 0x01 for P2TR.
```
--------------------------------
### updateOutput
Source: https://bitcoinjs.github.io/bitcoinjs-lib/classes/Psbt.html
Updates a specific output within the PSBT.
```APIDOC
## updateOutput
### Description
Updates an output at the specified index with new data.
### Parameters
#### Path Parameters
- **outputIndex** (number) - Required - The index of the output to update.
- **updateData** (PsbtOutputUpdate) - Required - The data to apply to the output.
### Response
- **this** (Psbt) - Returns the current PSBT instance.
```
--------------------------------
### Type Alias StackFunction
Source: https://bitcoinjs.github.io/bitcoinjs-lib/types/payments.StackFunction.html
Documentation for the StackFunction type alias used in bitcoinjs-lib.
```APIDOC
## Type Alias StackFunction
### Description
A type alias representing a function that returns a Stack object.
### Definition
StackFunction: (() => Stack)
```
--------------------------------
### RIPEMD-160 Hash Function
Source: https://bitcoinjs.github.io/bitcoinjs-lib/functions/crypto.ripemd160.html
Provides details on the RIPEMD-160 hash function, including its parameters and return types.
```APIDOC
## Function ripemd160
RIPEMD-160 - a hash function from 1990s.
### Parameters
* **msg** (Input) - Description: Input message to be hashed.
### Returns
* **Uint8Array** - The resulting hash digest.
```