bitcoinjs-lib

  • Version 6.1.7
  • Published
  • 262 kB
  • 6 dependencies
  • MIT license

Install

npm i bitcoinjs-lib
yarn add bitcoinjs-lib
pnpm add bitcoinjs-lib

Overview

Client-side Bitcoin JavaScript library

Index

Variables

Functions

Classes

Interfaces

Type Aliases

Namespaces

Variables

variable opcodes

const opcodes: { [key: string]: number };

    Functions

    function initEccLib

    initEccLib: (
    eccLib: TinySecp256k1Interface | undefined,
    opts?: { DANGER_DO_NOT_VERIFY_ECCLIB: boolean }
    ) => void;
    • 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.

      Parameter eccLib

      The instance of the ECC library to initialize.

      Parameter opts

      Extra initialization options. Use {DANGER_DO_NOT_VERIFY_ECCLIB:true} if ecc verification should not be executed. Not recommended!

    Classes

    class Block

    class Block {}

      property bits

      bits: number;

        property merkleRoot

        merkleRoot?: Buffer;

          property nonce

          nonce: number;

            property prevHash

            prevHash?: Buffer;

              property timestamp

              timestamp: number;

                property transactions

                transactions?: Transaction[];

                  property version

                  version: number;

                    property witnessCommit

                    witnessCommit?: Buffer;

                      method byteLength

                      byteLength: (headersOnly?: boolean, allowWitness?: boolean) => number;

                        method calculateMerkleRoot

                        static calculateMerkleRoot: (
                        transactions: Transaction[],
                        forWitness?: boolean
                        ) => Buffer;

                          method calculateTarget

                          static calculateTarget: (bits: number) => Buffer;

                            method checkProofOfWork

                            checkProofOfWork: () => boolean;

                              method checkTxRoots

                              checkTxRoots: () => boolean;

                                method fromBuffer

                                static fromBuffer: (buffer: Buffer) => Block;

                                  method fromHex

                                  static fromHex: (hex: string) => Block;

                                    method getHash

                                    getHash: () => Buffer;

                                      method getId

                                      getId: () => string;

                                        method getUTCDate

                                        getUTCDate: () => Date;

                                          method getWitnessCommit

                                          getWitnessCommit: () => Buffer | null;

                                            method hasWitness

                                            hasWitness: () => boolean;

                                              method hasWitnessCommit

                                              hasWitnessCommit: () => boolean;

                                                method toBuffer

                                                toBuffer: (headersOnly?: boolean) => Buffer;

                                                  method toHex

                                                  toHex: (headersOnly?: boolean) => string;

                                                    method weight

                                                    weight: () => number;

                                                      class Psbt

                                                      class Psbt {}
                                                      • Psbt class can parse and generate a PSBT binary based off of the BIP174. There are 6 roles that this class fulfills. (Explained in BIP174)

                                                        Creator: This can be done with new Psbt()

                                                        Updater: This can be done with psbt.addInput(input), psbt.addInputs(inputs), psbt.addOutput(output), psbt.addOutputs(outputs) when you are looking to add new inputs and outputs to the PSBT, and psbt.updateGlobal(itemObject), psbt.updateInput(itemObject), psbt.updateOutput(itemObject) addInput requires hash: Buffer | string; and index: number; as attributes and can also include any attributes that are used in updateInput method. addOutput requires script: Buffer; and value: number; and likewise can include data for updateOutput. For a list of what attributes should be what types. Check the bip174 library. Also, check the integration tests for some examples of usage.

                                                        Signer: There are a few methods. signAllInputs and signAllInputsAsync, which will search all input information for your pubkey or pubkeyhash, and only sign inputs where it finds your info. Or you can explicitly sign a specific input with signInput and signInputAsync. For the async methods you can create a SignerAsync object and use something like a hardware wallet to sign with. (You must implement this)

                                                        Combiner: psbts can be combined easily with psbt.combine(psbt2, psbt3, psbt4 ...) the psbt calling combine will always have precedence when a conflict occurs. Combine checks if the internal bitcoin transaction is the same, so be sure that all sequences, version, locktime, etc. are the same before combining.

                                                        Input Finalizer: This role is fairly important. Not only does it need to construct the input scriptSigs and witnesses, but it SHOULD verify the signatures etc. Before running psbt.finalizeAllInputs() please run psbt.validateSignaturesOfAllInputs() Running any finalize method will delete any data in the input(s) that are no longer needed due to the finalized scripts containing the information.

                                                        Transaction Extractor: This role will perform some checks before returning a Transaction object. Such as fee rate not being larger than maximumFeeRate etc.

                                                      constructor

                                                      constructor(opts?: PsbtOptsOptional, data?: PsbtBase);

                                                        property data

                                                        readonly data: PsbtBase;

                                                          property inputCount

                                                          readonly inputCount: number;

                                                            property locktime

                                                            locktime: number;

                                                              property txInputs

                                                              readonly txInputs: PsbtTxInput[];

                                                                property txOutputs

                                                                readonly txOutputs: PsbtTxOutput[];

                                                                  property version

                                                                  version: number;

                                                                    method addInput

                                                                    addInput: (inputData: PsbtInputExtended) => this;

                                                                      method addInputs

                                                                      addInputs: (inputDatas: PsbtInputExtended[]) => this;

                                                                        method addOutput

                                                                        addOutput: (outputData: PsbtOutputExtended) => this;

                                                                          method addOutputs

                                                                          addOutputs: (outputDatas: PsbtOutputExtended[]) => this;

                                                                            method addUnknownKeyValToGlobal

                                                                            addUnknownKeyValToGlobal: (keyVal: KeyValue) => this;

                                                                              method addUnknownKeyValToInput

                                                                              addUnknownKeyValToInput: (inputIndex: number, keyVal: KeyValue) => this;

                                                                                method addUnknownKeyValToOutput

                                                                                addUnknownKeyValToOutput: (outputIndex: number, keyVal: KeyValue) => this;

                                                                                  method clearFinalizedInput

                                                                                  clearFinalizedInput: (inputIndex: number) => this;

                                                                                    method clone

                                                                                    clone: () => Psbt;

                                                                                      method combine

                                                                                      combine: (...those: Psbt[]) => this;

                                                                                        method extractTransaction

                                                                                        extractTransaction: (disableFeeCheck?: boolean) => Transaction;

                                                                                          method finalizeAllInputs

                                                                                          finalizeAllInputs: () => this;

                                                                                            method finalizeInput

                                                                                            finalizeInput: (
                                                                                            inputIndex: number,
                                                                                            finalScriptsFunc?: FinalScriptsFunc | FinalTaprootScriptsFunc
                                                                                            ) => this;

                                                                                              method finalizeTaprootInput

                                                                                              finalizeTaprootInput: (
                                                                                              inputIndex: number,
                                                                                              tapLeafHashToFinalize?: Buffer,
                                                                                              finalScriptsFunc?: FinalTaprootScriptsFunc
                                                                                              ) => this;

                                                                                                method fromBase64

                                                                                                static fromBase64: (data: string, opts?: PsbtOptsOptional) => Psbt;

                                                                                                  method fromBuffer

                                                                                                  static fromBuffer: (buffer: Buffer, opts?: PsbtOptsOptional) => Psbt;

                                                                                                    method fromHex

                                                                                                    static fromHex: (data: string, opts?: PsbtOptsOptional) => Psbt;

                                                                                                      method getFee

                                                                                                      getFee: () => number;

                                                                                                        method getFeeRate

                                                                                                        getFeeRate: () => number;

                                                                                                          method getInputType

                                                                                                          getInputType: (inputIndex: number) => AllScriptType;

                                                                                                            method inputHasHDKey

                                                                                                            inputHasHDKey: (inputIndex: number, root: HDSigner) => boolean;

                                                                                                              method inputHasPubkey

                                                                                                              inputHasPubkey: (inputIndex: number, pubkey: Buffer) => boolean;

                                                                                                                method outputHasHDKey

                                                                                                                outputHasHDKey: (outputIndex: number, root: HDSigner) => boolean;

                                                                                                                  method outputHasPubkey

                                                                                                                  outputHasPubkey: (outputIndex: number, pubkey: Buffer) => boolean;

                                                                                                                    method setInputSequence

                                                                                                                    setInputSequence: (inputIndex: number, sequence: number) => this;

                                                                                                                      method setLocktime

                                                                                                                      setLocktime: (locktime: number) => this;

                                                                                                                        method setMaximumFeeRate

                                                                                                                        setMaximumFeeRate: (satoshiPerByte: number) => void;

                                                                                                                          method setVersion

                                                                                                                          setVersion: (version: number) => this;

                                                                                                                            method signAllInputs

                                                                                                                            signAllInputs: (keyPair: Signer, sighashTypes?: number[]) => this;

                                                                                                                              method signAllInputsAsync

                                                                                                                              signAllInputsAsync: (
                                                                                                                              keyPair: Signer | SignerAsync,
                                                                                                                              sighashTypes?: number[]
                                                                                                                              ) => Promise<void>;

                                                                                                                                method signAllInputsHD

                                                                                                                                signAllInputsHD: (hdKeyPair: HDSigner, sighashTypes?: number[]) => this;

                                                                                                                                  method signAllInputsHDAsync

                                                                                                                                  signAllInputsHDAsync: (
                                                                                                                                  hdKeyPair: HDSigner | HDSignerAsync,
                                                                                                                                  sighashTypes?: number[]
                                                                                                                                  ) => Promise<void>;

                                                                                                                                    method signInput

                                                                                                                                    signInput: (
                                                                                                                                    inputIndex: number,
                                                                                                                                    keyPair: Signer,
                                                                                                                                    sighashTypes?: number[]
                                                                                                                                    ) => this;

                                                                                                                                      method signInputAsync

                                                                                                                                      signInputAsync: (
                                                                                                                                      inputIndex: number,
                                                                                                                                      keyPair: Signer | SignerAsync,
                                                                                                                                      sighashTypes?: number[]
                                                                                                                                      ) => Promise<void>;

                                                                                                                                        method signInputHD

                                                                                                                                        signInputHD: (
                                                                                                                                        inputIndex: number,
                                                                                                                                        hdKeyPair: HDSigner,
                                                                                                                                        sighashTypes?: number[]
                                                                                                                                        ) => this;

                                                                                                                                          method signInputHDAsync

                                                                                                                                          signInputHDAsync: (
                                                                                                                                          inputIndex: number,
                                                                                                                                          hdKeyPair: HDSigner | HDSignerAsync,
                                                                                                                                          sighashTypes?: number[]
                                                                                                                                          ) => Promise<void>;

                                                                                                                                            method signTaprootInput

                                                                                                                                            signTaprootInput: (
                                                                                                                                            inputIndex: number,
                                                                                                                                            keyPair: Signer,
                                                                                                                                            tapLeafHashToSign?: Buffer,
                                                                                                                                            sighashTypes?: number[]
                                                                                                                                            ) => this;

                                                                                                                                              method signTaprootInputAsync

                                                                                                                                              signTaprootInputAsync: (
                                                                                                                                              inputIndex: number,
                                                                                                                                              keyPair: Signer | SignerAsync,
                                                                                                                                              tapLeafHash?: Buffer,
                                                                                                                                              sighashTypes?: number[]
                                                                                                                                              ) => Promise<void>;

                                                                                                                                                method toBase64

                                                                                                                                                toBase64: () => string;

                                                                                                                                                  method toBuffer

                                                                                                                                                  toBuffer: () => Buffer;

                                                                                                                                                    method toHex

                                                                                                                                                    toHex: () => string;

                                                                                                                                                      method updateGlobal

                                                                                                                                                      updateGlobal: (updateData: PsbtGlobalUpdate) => this;

                                                                                                                                                        method updateInput

                                                                                                                                                        updateInput: (inputIndex: number, updateData: PsbtInputUpdate) => this;

                                                                                                                                                          method updateOutput

                                                                                                                                                          updateOutput: (outputIndex: number, updateData: PsbtOutputUpdate) => this;

                                                                                                                                                            method validateSignaturesOfAllInputs

                                                                                                                                                            validateSignaturesOfAllInputs: (validator: ValidateSigFunction) => boolean;

                                                                                                                                                              method validateSignaturesOfInput

                                                                                                                                                              validateSignaturesOfInput: (
                                                                                                                                                              inputIndex: number,
                                                                                                                                                              validator: ValidateSigFunction,
                                                                                                                                                              pubkey?: Buffer
                                                                                                                                                              ) => boolean;

                                                                                                                                                                class Transaction

                                                                                                                                                                class Transaction {}
                                                                                                                                                                • Represents a Bitcoin transaction.

                                                                                                                                                                property ADVANCED_TRANSACTION_FLAG

                                                                                                                                                                static readonly ADVANCED_TRANSACTION_FLAG: number;

                                                                                                                                                                  property ADVANCED_TRANSACTION_MARKER

                                                                                                                                                                  static readonly ADVANCED_TRANSACTION_MARKER: number;

                                                                                                                                                                    property DEFAULT_SEQUENCE

                                                                                                                                                                    static readonly DEFAULT_SEQUENCE: number;

                                                                                                                                                                      property ins

                                                                                                                                                                      ins: Input[];

                                                                                                                                                                        property locktime

                                                                                                                                                                        locktime: number;

                                                                                                                                                                          property outs

                                                                                                                                                                          outs: Output[];

                                                                                                                                                                            property SIGHASH_ALL

                                                                                                                                                                            static readonly SIGHASH_ALL: number;

                                                                                                                                                                              property SIGHASH_ANYONECANPAY

                                                                                                                                                                              static readonly SIGHASH_ANYONECANPAY: number;

                                                                                                                                                                                property SIGHASH_DEFAULT

                                                                                                                                                                                static readonly SIGHASH_DEFAULT: number;

                                                                                                                                                                                  property SIGHASH_INPUT_MASK

                                                                                                                                                                                  static readonly SIGHASH_INPUT_MASK: number;

                                                                                                                                                                                    property SIGHASH_NONE

                                                                                                                                                                                    static readonly SIGHASH_NONE: number;

                                                                                                                                                                                      property SIGHASH_OUTPUT_MASK

                                                                                                                                                                                      static readonly SIGHASH_OUTPUT_MASK: number;

                                                                                                                                                                                        property SIGHASH_SINGLE

                                                                                                                                                                                        static readonly SIGHASH_SINGLE: number;

                                                                                                                                                                                          property version

                                                                                                                                                                                          version: number;

                                                                                                                                                                                            method addInput

                                                                                                                                                                                            addInput: (
                                                                                                                                                                                            hash: Buffer,
                                                                                                                                                                                            index: number,
                                                                                                                                                                                            sequence?: number,
                                                                                                                                                                                            scriptSig?: Buffer
                                                                                                                                                                                            ) => number;

                                                                                                                                                                                              method addOutput

                                                                                                                                                                                              addOutput: (scriptPubKey: Buffer, value: number) => number;

                                                                                                                                                                                                method byteLength

                                                                                                                                                                                                byteLength: (_ALLOW_WITNESS?: boolean) => number;

                                                                                                                                                                                                  method clone

                                                                                                                                                                                                  clone: () => Transaction;

                                                                                                                                                                                                    method fromBuffer

                                                                                                                                                                                                    static fromBuffer: (buffer: Buffer, _NO_STRICT?: boolean) => Transaction;

                                                                                                                                                                                                      method fromHex

                                                                                                                                                                                                      static fromHex: (hex: string) => Transaction;

                                                                                                                                                                                                        method getHash

                                                                                                                                                                                                        getHash: (forWitness?: boolean) => Buffer;

                                                                                                                                                                                                          method getId

                                                                                                                                                                                                          getId: () => string;

                                                                                                                                                                                                            method hashForSignature

                                                                                                                                                                                                            hashForSignature: (
                                                                                                                                                                                                            inIndex: number,
                                                                                                                                                                                                            prevOutScript: Buffer,
                                                                                                                                                                                                            hashType: number
                                                                                                                                                                                                            ) => Buffer;
                                                                                                                                                                                                            • Hash transaction for signing a specific input.

                                                                                                                                                                                                              Bitcoin uses a different hash for each signed transaction input. This method copies the transaction, makes the necessary changes based on the hashType, and then hashes the result. This hash can then be used to sign the provided transaction input.

                                                                                                                                                                                                            method hashForWitnessV0

                                                                                                                                                                                                            hashForWitnessV0: (
                                                                                                                                                                                                            inIndex: number,
                                                                                                                                                                                                            prevOutScript: Buffer,
                                                                                                                                                                                                            value: number,
                                                                                                                                                                                                            hashType: number
                                                                                                                                                                                                            ) => Buffer;

                                                                                                                                                                                                              method hashForWitnessV1

                                                                                                                                                                                                              hashForWitnessV1: (
                                                                                                                                                                                                              inIndex: number,
                                                                                                                                                                                                              prevOutScripts: Buffer[],
                                                                                                                                                                                                              values: number[],
                                                                                                                                                                                                              hashType: number,
                                                                                                                                                                                                              leafHash?: Buffer,
                                                                                                                                                                                                              annex?: Buffer
                                                                                                                                                                                                              ) => Buffer;

                                                                                                                                                                                                                method hasWitnesses

                                                                                                                                                                                                                hasWitnesses: () => boolean;

                                                                                                                                                                                                                  method isCoinbase

                                                                                                                                                                                                                  isCoinbase: () => boolean;

                                                                                                                                                                                                                    method isCoinbaseHash

                                                                                                                                                                                                                    static isCoinbaseHash: (buffer: Buffer) => boolean;

                                                                                                                                                                                                                      method setInputScript

                                                                                                                                                                                                                      setInputScript: (index: number, scriptSig: Buffer) => void;

                                                                                                                                                                                                                        method setWitness

                                                                                                                                                                                                                        setWitness: (index: number, witness: Buffer[]) => void;

                                                                                                                                                                                                                          method stripWitnesses

                                                                                                                                                                                                                          stripWitnesses: () => void;

                                                                                                                                                                                                                            method toBuffer

                                                                                                                                                                                                                            toBuffer: (buffer?: Buffer, initialOffset?: number) => Buffer;

                                                                                                                                                                                                                              method toHex

                                                                                                                                                                                                                              toHex: () => string;

                                                                                                                                                                                                                                method virtualSize

                                                                                                                                                                                                                                virtualSize: () => number;

                                                                                                                                                                                                                                  method weight

                                                                                                                                                                                                                                  weight: () => number;

                                                                                                                                                                                                                                    Interfaces

                                                                                                                                                                                                                                    interface HDSigner

                                                                                                                                                                                                                                    interface HDSigner extends HDSignerBase {}

                                                                                                                                                                                                                                      method derivePath

                                                                                                                                                                                                                                      derivePath: (path: string) => HDSigner;
                                                                                                                                                                                                                                      • The path string must match /^m(/\d+'?)+$/ ex. m/44'/0'/0'/1/23 levels with ' must be hard derivations

                                                                                                                                                                                                                                      method sign

                                                                                                                                                                                                                                      sign: (hash: Buffer) => Buffer;
                                                                                                                                                                                                                                      • Input hash (the "message digest") for the signature algorithm Return a 64 byte signature (32 byte r and 32 byte s in that order)

                                                                                                                                                                                                                                      interface HDSignerAsync

                                                                                                                                                                                                                                      interface HDSignerAsync extends HDSignerBase {}
                                                                                                                                                                                                                                      • Same as above but with async sign method

                                                                                                                                                                                                                                      method derivePath

                                                                                                                                                                                                                                      derivePath: (path: string) => HDSignerAsync;

                                                                                                                                                                                                                                        method sign

                                                                                                                                                                                                                                        sign: (hash: Buffer) => Promise<Buffer>;

                                                                                                                                                                                                                                          interface Network

                                                                                                                                                                                                                                          interface Network {}

                                                                                                                                                                                                                                            property bech32

                                                                                                                                                                                                                                            bech32: string;

                                                                                                                                                                                                                                              property bip32

                                                                                                                                                                                                                                              bip32: Bip32;

                                                                                                                                                                                                                                                property messagePrefix

                                                                                                                                                                                                                                                messagePrefix: string;

                                                                                                                                                                                                                                                  property pubKeyHash

                                                                                                                                                                                                                                                  pubKeyHash: number;

                                                                                                                                                                                                                                                    property scriptHash

                                                                                                                                                                                                                                                    scriptHash: number;

                                                                                                                                                                                                                                                      property wif

                                                                                                                                                                                                                                                      wif: number;

                                                                                                                                                                                                                                                        interface Payment

                                                                                                                                                                                                                                                        interface Payment {}

                                                                                                                                                                                                                                                          property address

                                                                                                                                                                                                                                                          address?: string;

                                                                                                                                                                                                                                                            property data

                                                                                                                                                                                                                                                            data?: Buffer[];

                                                                                                                                                                                                                                                              property hash

                                                                                                                                                                                                                                                              hash?: Buffer;

                                                                                                                                                                                                                                                                property input

                                                                                                                                                                                                                                                                input?: Buffer;

                                                                                                                                                                                                                                                                  property internalPubkey

                                                                                                                                                                                                                                                                  internalPubkey?: Buffer;

                                                                                                                                                                                                                                                                    property m

                                                                                                                                                                                                                                                                    m?: number;

                                                                                                                                                                                                                                                                      property n

                                                                                                                                                                                                                                                                      n?: number;

                                                                                                                                                                                                                                                                        property name

                                                                                                                                                                                                                                                                        name?: string;

                                                                                                                                                                                                                                                                          property network

                                                                                                                                                                                                                                                                          network?: Network;

                                                                                                                                                                                                                                                                            property output

                                                                                                                                                                                                                                                                            output?: Buffer;

                                                                                                                                                                                                                                                                              property pubkey

                                                                                                                                                                                                                                                                              pubkey?: Buffer;

                                                                                                                                                                                                                                                                                property pubkeys

                                                                                                                                                                                                                                                                                pubkeys?: Buffer[];

                                                                                                                                                                                                                                                                                  property redeem

                                                                                                                                                                                                                                                                                  redeem?: Payment;

                                                                                                                                                                                                                                                                                    property redeemVersion

                                                                                                                                                                                                                                                                                    redeemVersion?: number;

                                                                                                                                                                                                                                                                                      property scriptTree

                                                                                                                                                                                                                                                                                      scriptTree?: Taptree;

                                                                                                                                                                                                                                                                                        property signature

                                                                                                                                                                                                                                                                                        signature?: Buffer;

                                                                                                                                                                                                                                                                                          property signatures

                                                                                                                                                                                                                                                                                          signatures?: Buffer[];

                                                                                                                                                                                                                                                                                            property witness

                                                                                                                                                                                                                                                                                            witness?: Buffer[];

                                                                                                                                                                                                                                                                                              interface PaymentOpts

                                                                                                                                                                                                                                                                                              interface PaymentOpts {}

                                                                                                                                                                                                                                                                                                property allowIncomplete

                                                                                                                                                                                                                                                                                                allowIncomplete?: boolean;

                                                                                                                                                                                                                                                                                                  property validate

                                                                                                                                                                                                                                                                                                  validate?: boolean;

                                                                                                                                                                                                                                                                                                    interface PsbtTxInput

                                                                                                                                                                                                                                                                                                    interface PsbtTxInput extends TransactionInput {}

                                                                                                                                                                                                                                                                                                      property hash

                                                                                                                                                                                                                                                                                                      hash: Buffer;

                                                                                                                                                                                                                                                                                                        interface PsbtTxOutput

                                                                                                                                                                                                                                                                                                        interface PsbtTxOutput extends TransactionOutput {}

                                                                                                                                                                                                                                                                                                          property address

                                                                                                                                                                                                                                                                                                          address: string | undefined;

                                                                                                                                                                                                                                                                                                            interface Signer

                                                                                                                                                                                                                                                                                                            interface Signer {}

                                                                                                                                                                                                                                                                                                              property network

                                                                                                                                                                                                                                                                                                              network?: any;

                                                                                                                                                                                                                                                                                                                property publicKey

                                                                                                                                                                                                                                                                                                                publicKey: Buffer;

                                                                                                                                                                                                                                                                                                                  method getPublicKey

                                                                                                                                                                                                                                                                                                                  getPublicKey: () => Buffer;

                                                                                                                                                                                                                                                                                                                    method sign

                                                                                                                                                                                                                                                                                                                    sign: (hash: Buffer, lowR?: boolean) => Buffer;

                                                                                                                                                                                                                                                                                                                      method signSchnorr

                                                                                                                                                                                                                                                                                                                      signSchnorr: (hash: Buffer) => Buffer;

                                                                                                                                                                                                                                                                                                                        interface SignerAsync

                                                                                                                                                                                                                                                                                                                        interface SignerAsync {}

                                                                                                                                                                                                                                                                                                                          property network

                                                                                                                                                                                                                                                                                                                          network?: any;

                                                                                                                                                                                                                                                                                                                            property publicKey

                                                                                                                                                                                                                                                                                                                            publicKey: Buffer;

                                                                                                                                                                                                                                                                                                                              method getPublicKey

                                                                                                                                                                                                                                                                                                                              getPublicKey: () => Buffer;

                                                                                                                                                                                                                                                                                                                                method sign

                                                                                                                                                                                                                                                                                                                                sign: (hash: Buffer, lowR?: boolean) => Promise<Buffer>;

                                                                                                                                                                                                                                                                                                                                  method signSchnorr

                                                                                                                                                                                                                                                                                                                                  signSchnorr: (hash: Buffer) => Promise<Buffer>;

                                                                                                                                                                                                                                                                                                                                    interface TxInput

                                                                                                                                                                                                                                                                                                                                    interface Input {}

                                                                                                                                                                                                                                                                                                                                      property hash

                                                                                                                                                                                                                                                                                                                                      hash: Buffer;

                                                                                                                                                                                                                                                                                                                                        property index

                                                                                                                                                                                                                                                                                                                                        index: number;

                                                                                                                                                                                                                                                                                                                                          property script

                                                                                                                                                                                                                                                                                                                                          script: Buffer;

                                                                                                                                                                                                                                                                                                                                            property sequence

                                                                                                                                                                                                                                                                                                                                            sequence: number;

                                                                                                                                                                                                                                                                                                                                              property witness

                                                                                                                                                                                                                                                                                                                                              witness: Buffer[];

                                                                                                                                                                                                                                                                                                                                                interface TxOutput

                                                                                                                                                                                                                                                                                                                                                interface Output {}

                                                                                                                                                                                                                                                                                                                                                  property script

                                                                                                                                                                                                                                                                                                                                                  script: Buffer;

                                                                                                                                                                                                                                                                                                                                                    property value

                                                                                                                                                                                                                                                                                                                                                    value: number;

                                                                                                                                                                                                                                                                                                                                                      Type Aliases

                                                                                                                                                                                                                                                                                                                                                      type PaymentCreator

                                                                                                                                                                                                                                                                                                                                                      type PaymentCreator = (a: Payment, opts?: PaymentOpts) => Payment;

                                                                                                                                                                                                                                                                                                                                                        type Stack

                                                                                                                                                                                                                                                                                                                                                        type Stack = StackElement[];

                                                                                                                                                                                                                                                                                                                                                          type StackElement

                                                                                                                                                                                                                                                                                                                                                          type StackElement = Buffer | number;

                                                                                                                                                                                                                                                                                                                                                            type TaggedHashPrefix

                                                                                                                                                                                                                                                                                                                                                            type TaggedHashPrefix = (typeof TAGS)[number];

                                                                                                                                                                                                                                                                                                                                                              Namespaces

                                                                                                                                                                                                                                                                                                                                                              namespace address

                                                                                                                                                                                                                                                                                                                                                              module 'src/address.d.ts' {}
                                                                                                                                                                                                                                                                                                                                                              • bitcoin address decode and encode tools, include base58、bech32 and output script

                                                                                                                                                                                                                                                                                                                                                                networks support bitcoin、bitcoin testnet and bitcoin regtest

                                                                                                                                                                                                                                                                                                                                                                addresses support P2PKH、P2SH、P2WPKH、P2WSH、P2TR and so on

                                                                                                                                                                                                                                                                                                                                                              function fromBase58Check

                                                                                                                                                                                                                                                                                                                                                              fromBase58Check: (address: string) => Base58CheckResult;
                                                                                                                                                                                                                                                                                                                                                              • decode address with base58 specification, return address version and address hash if valid

                                                                                                                                                                                                                                                                                                                                                              function fromBech32

                                                                                                                                                                                                                                                                                                                                                              fromBech32: (address: string) => Bech32Result;
                                                                                                                                                                                                                                                                                                                                                              • decode address with bech32 specification, return address version、address prefix and address data if valid

                                                                                                                                                                                                                                                                                                                                                              function fromOutputScript

                                                                                                                                                                                                                                                                                                                                                              fromOutputScript: (output: Buffer, network?: Network) => string;
                                                                                                                                                                                                                                                                                                                                                              • decode address from output script with network, return address if matched

                                                                                                                                                                                                                                                                                                                                                              function toBase58Check

                                                                                                                                                                                                                                                                                                                                                              toBase58Check: (hash: Buffer, version: number) => string;
                                                                                                                                                                                                                                                                                                                                                              • encode address hash to base58 address with version

                                                                                                                                                                                                                                                                                                                                                              function toBech32

                                                                                                                                                                                                                                                                                                                                                              toBech32: (data: Buffer, version: number, prefix: string) => string;
                                                                                                                                                                                                                                                                                                                                                              • encode address hash to bech32 address with version and prefix

                                                                                                                                                                                                                                                                                                                                                              function toOutputScript

                                                                                                                                                                                                                                                                                                                                                              toOutputScript: (address: string, network?: Network) => Buffer;
                                                                                                                                                                                                                                                                                                                                                              • encodes address to output script with network, return output script if address matched

                                                                                                                                                                                                                                                                                                                                                              interface Base58CheckResult

                                                                                                                                                                                                                                                                                                                                                              interface Base58CheckResult {}
                                                                                                                                                                                                                                                                                                                                                              • base58check decode result

                                                                                                                                                                                                                                                                                                                                                              property hash

                                                                                                                                                                                                                                                                                                                                                              hash: Buffer;
                                                                                                                                                                                                                                                                                                                                                              • address hash

                                                                                                                                                                                                                                                                                                                                                              property version

                                                                                                                                                                                                                                                                                                                                                              version: number;
                                                                                                                                                                                                                                                                                                                                                              • address version: 0x00 for P2PKH, 0x05 for P2SH

                                                                                                                                                                                                                                                                                                                                                              interface Bech32Result

                                                                                                                                                                                                                                                                                                                                                              interface Bech32Result {}
                                                                                                                                                                                                                                                                                                                                                              • bech32 decode result

                                                                                                                                                                                                                                                                                                                                                              property data

                                                                                                                                                                                                                                                                                                                                                              data: Buffer;
                                                                                                                                                                                                                                                                                                                                                              • address data:20 bytes for P2WPKH, 32 bytes for P2WSH、P2TR

                                                                                                                                                                                                                                                                                                                                                              property prefix

                                                                                                                                                                                                                                                                                                                                                              prefix: string;
                                                                                                                                                                                                                                                                                                                                                              • address prefix: bc for P2WPKH、P2WSH、P2TR

                                                                                                                                                                                                                                                                                                                                                              property version

                                                                                                                                                                                                                                                                                                                                                              version: number;
                                                                                                                                                                                                                                                                                                                                                              • address version: 0x00 for P2WPKH、P2WSH, 0x01 for P2TR

                                                                                                                                                                                                                                                                                                                                                              namespace crypto

                                                                                                                                                                                                                                                                                                                                                              module 'src/crypto.d.ts' {}
                                                                                                                                                                                                                                                                                                                                                              • An object mapping tags to their tagged hash prefix of [SHA256(tag) | SHA256(tag)]

                                                                                                                                                                                                                                                                                                                                                              variable TAGGED_HASH_PREFIXES

                                                                                                                                                                                                                                                                                                                                                              const TAGGED_HASH_PREFIXES: TaggedHashPrefixes;
                                                                                                                                                                                                                                                                                                                                                              • Defines the tagged hash prefixes used in the crypto module.

                                                                                                                                                                                                                                                                                                                                                              variable TAGS

                                                                                                                                                                                                                                                                                                                                                              const TAGS: readonly [
                                                                                                                                                                                                                                                                                                                                                              'BIP0340/challenge',
                                                                                                                                                                                                                                                                                                                                                              'BIP0340/aux',
                                                                                                                                                                                                                                                                                                                                                              'BIP0340/nonce',
                                                                                                                                                                                                                                                                                                                                                              'TapLeaf',
                                                                                                                                                                                                                                                                                                                                                              'TapBranch',
                                                                                                                                                                                                                                                                                                                                                              'TapSighash',
                                                                                                                                                                                                                                                                                                                                                              'TapTweak',
                                                                                                                                                                                                                                                                                                                                                              'KeyAgg list',
                                                                                                                                                                                                                                                                                                                                                              'KeyAgg coefficient'
                                                                                                                                                                                                                                                                                                                                                              ];

                                                                                                                                                                                                                                                                                                                                                                function hash160

                                                                                                                                                                                                                                                                                                                                                                hash160: (buffer: Buffer) => Buffer;

                                                                                                                                                                                                                                                                                                                                                                  function hash256

                                                                                                                                                                                                                                                                                                                                                                  hash256: (buffer: Buffer) => Buffer;

                                                                                                                                                                                                                                                                                                                                                                    function ripemd160

                                                                                                                                                                                                                                                                                                                                                                    ripemd160: (buffer: Buffer) => Buffer;

                                                                                                                                                                                                                                                                                                                                                                      function sha1

                                                                                                                                                                                                                                                                                                                                                                      sha1: (buffer: Buffer) => Buffer;

                                                                                                                                                                                                                                                                                                                                                                        function sha256

                                                                                                                                                                                                                                                                                                                                                                        sha256: (buffer: Buffer) => Buffer;

                                                                                                                                                                                                                                                                                                                                                                          function taggedHash

                                                                                                                                                                                                                                                                                                                                                                          taggedHash: (prefix: TaggedHashPrefix, data: Buffer) => Buffer;

                                                                                                                                                                                                                                                                                                                                                                            type TaggedHashPrefix

                                                                                                                                                                                                                                                                                                                                                                            type TaggedHashPrefix = (typeof TAGS)[number];

                                                                                                                                                                                                                                                                                                                                                                              namespace networks

                                                                                                                                                                                                                                                                                                                                                                              module 'src/networks.d.ts' {}
                                                                                                                                                                                                                                                                                                                                                                              • Represents a Bitcoin network configuration,including messagePrefix, bech32, bip32, pubKeyHash, scriptHash, wif. Support bitcoin、bitcoin testnet and bitcoin regtest.

                                                                                                                                                                                                                                                                                                                                                                              variable bitcoin

                                                                                                                                                                                                                                                                                                                                                                              const bitcoin: Network;
                                                                                                                                                                                                                                                                                                                                                                              • Represents the Bitcoin network configuration.

                                                                                                                                                                                                                                                                                                                                                                              variable regtest

                                                                                                                                                                                                                                                                                                                                                                              const regtest: Network;
                                                                                                                                                                                                                                                                                                                                                                              • Represents the regtest network configuration.

                                                                                                                                                                                                                                                                                                                                                                              variable testnet

                                                                                                                                                                                                                                                                                                                                                                              const testnet: Network;
                                                                                                                                                                                                                                                                                                                                                                              • Represents the testnet network configuration.

                                                                                                                                                                                                                                                                                                                                                                              interface Network

                                                                                                                                                                                                                                                                                                                                                                              interface Network {}

                                                                                                                                                                                                                                                                                                                                                                                property bech32

                                                                                                                                                                                                                                                                                                                                                                                bech32: string;

                                                                                                                                                                                                                                                                                                                                                                                  property bip32

                                                                                                                                                                                                                                                                                                                                                                                  bip32: Bip32;

                                                                                                                                                                                                                                                                                                                                                                                    property messagePrefix

                                                                                                                                                                                                                                                                                                                                                                                    messagePrefix: string;

                                                                                                                                                                                                                                                                                                                                                                                      property pubKeyHash

                                                                                                                                                                                                                                                                                                                                                                                      pubKeyHash: number;

                                                                                                                                                                                                                                                                                                                                                                                        property scriptHash

                                                                                                                                                                                                                                                                                                                                                                                        scriptHash: number;

                                                                                                                                                                                                                                                                                                                                                                                          property wif

                                                                                                                                                                                                                                                                                                                                                                                          wif: number;

                                                                                                                                                                                                                                                                                                                                                                                            namespace payments

                                                                                                                                                                                                                                                                                                                                                                                            module 'src/payments/index.d.ts' {}
                                                                                                                                                                                                                                                                                                                                                                                            • Represents a payment object, which is used to create a payment.

                                                                                                                                                                                                                                                                                                                                                                                              Supports P2PKH、P2SH、P2WPKH、P2WSH、P2TR and so on

                                                                                                                                                                                                                                                                                                                                                                                            function embed

                                                                                                                                                                                                                                                                                                                                                                                            embed: (a: Payment, opts?: PaymentOpts) => Payment;
                                                                                                                                                                                                                                                                                                                                                                                            • Embeds data in a Bitcoin payment.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter a

                                                                                                                                                                                                                                                                                                                                                                                              The payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter opts

                                                                                                                                                                                                                                                                                                                                                                                              Optional payment options.

                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                              The modified payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Throws

                                                                                                                                                                                                                                                                                                                                                                                              {TypeError} If there is not enough data or if the output is invalid.

                                                                                                                                                                                                                                                                                                                                                                                            function p2ms

                                                                                                                                                                                                                                                                                                                                                                                            p2ms: (a: Payment, opts?: PaymentOpts) => Payment;
                                                                                                                                                                                                                                                                                                                                                                                            • Represents a function that creates a Pay-to-Multisig (P2MS) payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter a

                                                                                                                                                                                                                                                                                                                                                                                              The payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter opts

                                                                                                                                                                                                                                                                                                                                                                                              Optional payment options.

                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                              The created payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Throws

                                                                                                                                                                                                                                                                                                                                                                                              {TypeError} If the provided data is not valid.

                                                                                                                                                                                                                                                                                                                                                                                            function p2pk

                                                                                                                                                                                                                                                                                                                                                                                            p2pk: (a: Payment, opts?: PaymentOpts) => Payment;
                                                                                                                                                                                                                                                                                                                                                                                            • Creates a pay-to-public-key (P2PK) payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter a

                                                                                                                                                                                                                                                                                                                                                                                              The payment object containing the necessary data.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter opts

                                                                                                                                                                                                                                                                                                                                                                                              Optional payment options.

                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                              The P2PK payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Throws

                                                                                                                                                                                                                                                                                                                                                                                              {TypeError} If the required data is not provided or if the data is invalid.

                                                                                                                                                                                                                                                                                                                                                                                            function p2pkh

                                                                                                                                                                                                                                                                                                                                                                                            p2pkh: (a: Payment, opts?: PaymentOpts) => Payment;
                                                                                                                                                                                                                                                                                                                                                                                            • Creates a Pay-to-Public-Key-Hash (P2PKH) payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter a

                                                                                                                                                                                                                                                                                                                                                                                              The payment object containing the necessary data.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter opts

                                                                                                                                                                                                                                                                                                                                                                                              Optional payment options.

                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                              The P2PKH payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Throws

                                                                                                                                                                                                                                                                                                                                                                                              {TypeError} If the required data is not provided or if the data is invalid.

                                                                                                                                                                                                                                                                                                                                                                                            function p2sh

                                                                                                                                                                                                                                                                                                                                                                                            p2sh: (a: Payment, opts?: PaymentOpts) => Payment;
                                                                                                                                                                                                                                                                                                                                                                                            • Creates a Pay-to-Script-Hash (P2SH) payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter a

                                                                                                                                                                                                                                                                                                                                                                                              The payment object containing the necessary data.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter opts

                                                                                                                                                                                                                                                                                                                                                                                              Optional payment options.

                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                              The P2SH payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Throws

                                                                                                                                                                                                                                                                                                                                                                                              {TypeError} If the required data is not provided or if the data is invalid.

                                                                                                                                                                                                                                                                                                                                                                                            function p2tr

                                                                                                                                                                                                                                                                                                                                                                                            p2tr: (a: Payment, opts?: PaymentOpts) => Payment;
                                                                                                                                                                                                                                                                                                                                                                                            • Creates a Pay-to-Taproot (P2TR) payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter a

                                                                                                                                                                                                                                                                                                                                                                                              The payment object containing the necessary data for P2TR.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter opts

                                                                                                                                                                                                                                                                                                                                                                                              Optional payment options.

                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                              The P2TR payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Throws

                                                                                                                                                                                                                                                                                                                                                                                              {TypeError} If the provided data is invalid or insufficient.

                                                                                                                                                                                                                                                                                                                                                                                            function p2wpkh

                                                                                                                                                                                                                                                                                                                                                                                            p2wpkh: (a: Payment, opts?: PaymentOpts) => Payment;
                                                                                                                                                                                                                                                                                                                                                                                            • Creates a pay-to-witness-public-key-hash (p2wpkh) payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter a

                                                                                                                                                                                                                                                                                                                                                                                              The payment object containing the necessary data.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter opts

                                                                                                                                                                                                                                                                                                                                                                                              Optional payment options.

                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                              The p2wpkh payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Throws

                                                                                                                                                                                                                                                                                                                                                                                              {TypeError} If the required data is missing or invalid.

                                                                                                                                                                                                                                                                                                                                                                                            function p2wsh

                                                                                                                                                                                                                                                                                                                                                                                            p2wsh: (a: Payment, opts?: PaymentOpts) => Payment;
                                                                                                                                                                                                                                                                                                                                                                                            • Creates a Pay-to-Witness-Script-Hash (P2WSH) payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter a

                                                                                                                                                                                                                                                                                                                                                                                              The payment object containing the necessary data.

                                                                                                                                                                                                                                                                                                                                                                                              Parameter opts

                                                                                                                                                                                                                                                                                                                                                                                              Optional payment options.

                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                              The P2WSH payment object.

                                                                                                                                                                                                                                                                                                                                                                                              Throws

                                                                                                                                                                                                                                                                                                                                                                                              {TypeError} If the required data is missing or invalid.

                                                                                                                                                                                                                                                                                                                                                                                            interface Payment

                                                                                                                                                                                                                                                                                                                                                                                            interface Payment {}

                                                                                                                                                                                                                                                                                                                                                                                              property address

                                                                                                                                                                                                                                                                                                                                                                                              address?: string;

                                                                                                                                                                                                                                                                                                                                                                                                property data

                                                                                                                                                                                                                                                                                                                                                                                                data?: Buffer[];

                                                                                                                                                                                                                                                                                                                                                                                                  property hash

                                                                                                                                                                                                                                                                                                                                                                                                  hash?: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                    property input

                                                                                                                                                                                                                                                                                                                                                                                                    input?: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                      property internalPubkey

                                                                                                                                                                                                                                                                                                                                                                                                      internalPubkey?: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                        property m

                                                                                                                                                                                                                                                                                                                                                                                                        m?: number;

                                                                                                                                                                                                                                                                                                                                                                                                          property n

                                                                                                                                                                                                                                                                                                                                                                                                          n?: number;

                                                                                                                                                                                                                                                                                                                                                                                                            property name

                                                                                                                                                                                                                                                                                                                                                                                                            name?: string;

                                                                                                                                                                                                                                                                                                                                                                                                              property network

                                                                                                                                                                                                                                                                                                                                                                                                              network?: Network;

                                                                                                                                                                                                                                                                                                                                                                                                                property output

                                                                                                                                                                                                                                                                                                                                                                                                                output?: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                                  property pubkey

                                                                                                                                                                                                                                                                                                                                                                                                                  pubkey?: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                                    property pubkeys

                                                                                                                                                                                                                                                                                                                                                                                                                    pubkeys?: Buffer[];

                                                                                                                                                                                                                                                                                                                                                                                                                      property redeem

                                                                                                                                                                                                                                                                                                                                                                                                                      redeem?: Payment;

                                                                                                                                                                                                                                                                                                                                                                                                                        property redeemVersion

                                                                                                                                                                                                                                                                                                                                                                                                                        redeemVersion?: number;

                                                                                                                                                                                                                                                                                                                                                                                                                          property scriptTree

                                                                                                                                                                                                                                                                                                                                                                                                                          scriptTree?: Taptree;

                                                                                                                                                                                                                                                                                                                                                                                                                            property signature

                                                                                                                                                                                                                                                                                                                                                                                                                            signature?: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                                              property signatures

                                                                                                                                                                                                                                                                                                                                                                                                                              signatures?: Buffer[];

                                                                                                                                                                                                                                                                                                                                                                                                                                property witness

                                                                                                                                                                                                                                                                                                                                                                                                                                witness?: Buffer[];

                                                                                                                                                                                                                                                                                                                                                                                                                                  interface PaymentOpts

                                                                                                                                                                                                                                                                                                                                                                                                                                  interface PaymentOpts {}

                                                                                                                                                                                                                                                                                                                                                                                                                                    property allowIncomplete

                                                                                                                                                                                                                                                                                                                                                                                                                                    allowIncomplete?: boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                      property validate

                                                                                                                                                                                                                                                                                                                                                                                                                                      validate?: boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                        type PaymentCreator

                                                                                                                                                                                                                                                                                                                                                                                                                                        type PaymentCreator = (a: Payment, opts?: PaymentOpts) => Payment;

                                                                                                                                                                                                                                                                                                                                                                                                                                          type PaymentFunction

                                                                                                                                                                                                                                                                                                                                                                                                                                          type PaymentFunction = () => Payment;

                                                                                                                                                                                                                                                                                                                                                                                                                                            type Stack

                                                                                                                                                                                                                                                                                                                                                                                                                                            type Stack = StackElement[];

                                                                                                                                                                                                                                                                                                                                                                                                                                              type StackElement

                                                                                                                                                                                                                                                                                                                                                                                                                                              type StackElement = Buffer | number;

                                                                                                                                                                                                                                                                                                                                                                                                                                                type StackFunction

                                                                                                                                                                                                                                                                                                                                                                                                                                                type StackFunction = () => Stack;

                                                                                                                                                                                                                                                                                                                                                                                                                                                  namespace script

                                                                                                                                                                                                                                                                                                                                                                                                                                                  module 'src/script.d.ts' {}
                                                                                                                                                                                                                                                                                                                                                                                                                                                  • Compiles an array of chunks into a Buffer.

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Parameter chunks

                                                                                                                                                                                                                                                                                                                                                                                                                                                    The array of chunks to compile.

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Returns

                                                                                                                                                                                                                                                                                                                                                                                                                                                    The compiled Buffer.

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Throws

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Error if the compilation fails.

                                                                                                                                                                                                                                                                                                                                                                                                                                                  variable number

                                                                                                                                                                                                                                                                                                                                                                                                                                                  const number: typeof scriptNumber;

                                                                                                                                                                                                                                                                                                                                                                                                                                                    variable OPS

                                                                                                                                                                                                                                                                                                                                                                                                                                                    const OPS: { [key: string]: number };

                                                                                                                                                                                                                                                                                                                                                                                                                                                      variable signature

                                                                                                                                                                                                                                                                                                                                                                                                                                                      const signature: typeof scriptSignature;

                                                                                                                                                                                                                                                                                                                                                                                                                                                        function compile

                                                                                                                                                                                                                                                                                                                                                                                                                                                        compile: (chunks: Buffer | Stack) => Buffer;
                                                                                                                                                                                                                                                                                                                                                                                                                                                        • Compiles an array of chunks into a Buffer.

                                                                                                                                                                                                                                                                                                                                                                                                                                                          Parameter chunks

                                                                                                                                                                                                                                                                                                                                                                                                                                                          The array of chunks to compile.

                                                                                                                                                                                                                                                                                                                                                                                                                                                          Returns

                                                                                                                                                                                                                                                                                                                                                                                                                                                          The compiled Buffer.

                                                                                                                                                                                                                                                                                                                                                                                                                                                          Throws

                                                                                                                                                                                                                                                                                                                                                                                                                                                          Error if the compilation fails.

                                                                                                                                                                                                                                                                                                                                                                                                                                                        function countNonPushOnlyOPs

                                                                                                                                                                                                                                                                                                                                                                                                                                                        countNonPushOnlyOPs: (value: Stack) => number;

                                                                                                                                                                                                                                                                                                                                                                                                                                                          function decompile

                                                                                                                                                                                                                                                                                                                                                                                                                                                          decompile: (
                                                                                                                                                                                                                                                                                                                                                                                                                                                          buffer: Buffer | Array<number | Buffer>
                                                                                                                                                                                                                                                                                                                                                                                                                                                          ) => Array<number | Buffer> | null;

                                                                                                                                                                                                                                                                                                                                                                                                                                                            function fromASM

                                                                                                                                                                                                                                                                                                                                                                                                                                                            fromASM: (asm: string) => Buffer;
                                                                                                                                                                                                                                                                                                                                                                                                                                                            • Converts an ASM string to a Buffer.

                                                                                                                                                                                                                                                                                                                                                                                                                                                              Parameter asm

                                                                                                                                                                                                                                                                                                                                                                                                                                                              The ASM string to convert.

                                                                                                                                                                                                                                                                                                                                                                                                                                                              Returns

                                                                                                                                                                                                                                                                                                                                                                                                                                                              The converted Buffer.

                                                                                                                                                                                                                                                                                                                                                                                                                                                            function isCanonicalPubKey

                                                                                                                                                                                                                                                                                                                                                                                                                                                            isCanonicalPubKey: (buffer: Buffer) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                              function isCanonicalScriptSignature

                                                                                                                                                                                                                                                                                                                                                                                                                                                              isCanonicalScriptSignature: (buffer: Buffer) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                function isDefinedHashType

                                                                                                                                                                                                                                                                                                                                                                                                                                                                isDefinedHashType: (hashType: number) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  function isPushOnly

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  isPushOnly: (value: Stack) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    function toASM

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    toASM: (chunks: Buffer | Array<number | Buffer>) => string;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • 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.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Parameter chunks

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      The chunks to convert into ASM.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Returns

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      The ASM string representation of the chunks.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    function toStack

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    toStack: (chunks: Buffer | Array<number | Buffer>) => Buffer[];
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Converts the given chunks into a stack of buffers.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Parameter chunks

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      The chunks to convert.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Returns

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      The stack of buffers.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Package Files (19)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Dependencies (6)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Dev Dependencies (31)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Peer Dependencies (0)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    No peer dependencies.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Badge

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/bitcoinjs-lib.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • Markdown
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/bitcoinjs-lib)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • HTML
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      <a href="https://www.jsdocs.io/package/bitcoinjs-lib"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>