bitcoinjs-lib

  • Version 5.2.0
  • Published
  • 227 kB
  • 15 dependencies
  • MIT license

Install

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

Overview

Client-side Bitcoin JavaScript library

Index

Variables

Classes

Interfaces

Type Aliases

Namespaces

Variables

variable opcodes

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

    Classes

    class Block

    class Block {}

      property bits

      bits: number;

        property merkleRoot

        merkleRoot?: any;

          property nonce

          nonce: number;

            property prevHash

            prevHash?: any;

              property timestamp

              timestamp: number;

                property transactions

                transactions?: Transaction[];

                  property version

                  version: number;

                    property witnessCommit

                    witnessCommit?: any;

                      method byteLength

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

                        method calculateMerkleRoot

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

                          method calculateTarget

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

                            method checkProofOfWork

                            checkProofOfWork: () => boolean;

                              method checkTxRoots

                              checkTxRoots: () => boolean;

                                method fromBuffer

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

                                  method fromHex

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

                                    method getHash

                                    getHash: () => any;

                                      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) => any;

                                                  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?: any);

                                                        property data

                                                        readonly data: any;

                                                          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: any) => this;

                                                                              method addUnknownKeyValToInput

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

                                                                                method addUnknownKeyValToOutput

                                                                                addUnknownKeyValToOutput: (outputIndex: number, keyVal: any) => 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) => this;

                                                                                              method fromBase64

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

                                                                                                method fromBuffer

                                                                                                static fromBuffer: (buffer: any, 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: any) => boolean;

                                                                                                              method outputHasHDKey

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

                                                                                                                method outputHasPubkey

                                                                                                                outputHasPubkey: (outputIndex: number, pubkey: any) => 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 toBase64

                                                                                                                                          toBase64: () => string;

                                                                                                                                            method toBuffer

                                                                                                                                            toBuffer: () => any;

                                                                                                                                              method toHex

                                                                                                                                              toHex: () => string;

                                                                                                                                                method updateGlobal

                                                                                                                                                updateGlobal: (updateData: any) => this;

                                                                                                                                                  method updateInput

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

                                                                                                                                                    method updateOutput

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

                                                                                                                                                      method validateSignaturesOfAllInputs

                                                                                                                                                      validateSignaturesOfAllInputs: () => boolean;

                                                                                                                                                        method validateSignaturesOfInput

                                                                                                                                                        validateSignaturesOfInput: (inputIndex: number, pubkey?: any) => boolean;

                                                                                                                                                          class Transaction

                                                                                                                                                          class 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_NONE

                                                                                                                                                                            static readonly SIGHASH_NONE: number;

                                                                                                                                                                              property SIGHASH_SINGLE

                                                                                                                                                                              static readonly SIGHASH_SINGLE: number;

                                                                                                                                                                                property version

                                                                                                                                                                                version: number;

                                                                                                                                                                                  method addInput

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

                                                                                                                                                                                    method addOutput

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

                                                                                                                                                                                      method byteLength

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

                                                                                                                                                                                        method clone

                                                                                                                                                                                        clone: () => Transaction;

                                                                                                                                                                                          method fromBuffer

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

                                                                                                                                                                                            method fromHex

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

                                                                                                                                                                                              method getHash

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

                                                                                                                                                                                                method getId

                                                                                                                                                                                                getId: () => string;

                                                                                                                                                                                                  method hashForSignature

                                                                                                                                                                                                  hashForSignature: (inIndex: number, prevOutScript: any, hashType: number) => any;
                                                                                                                                                                                                  • 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: any,
                                                                                                                                                                                                  value: number,
                                                                                                                                                                                                  hashType: number
                                                                                                                                                                                                  ) => any;

                                                                                                                                                                                                    method hasWitnesses

                                                                                                                                                                                                    hasWitnesses: () => boolean;

                                                                                                                                                                                                      method isCoinbase

                                                                                                                                                                                                      isCoinbase: () => boolean;

                                                                                                                                                                                                        method isCoinbaseHash

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

                                                                                                                                                                                                          method setInputScript

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

                                                                                                                                                                                                            method setWitness

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

                                                                                                                                                                                                              method toBuffer

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

                                                                                                                                                                                                                method toHex

                                                                                                                                                                                                                toHex: () => string;

                                                                                                                                                                                                                  method virtualSize

                                                                                                                                                                                                                  virtualSize: () => number;

                                                                                                                                                                                                                    method weight

                                                                                                                                                                                                                    weight: () => number;

                                                                                                                                                                                                                      class TransactionBuilder

                                                                                                                                                                                                                      class TransactionBuilder {}

                                                                                                                                                                                                                        constructor

                                                                                                                                                                                                                        constructor(network?: Network, maximumFeeRate?: number);

                                                                                                                                                                                                                          property maximumFeeRate

                                                                                                                                                                                                                          maximumFeeRate: number;

                                                                                                                                                                                                                            property network

                                                                                                                                                                                                                            network: Network;

                                                                                                                                                                                                                              method addInput

                                                                                                                                                                                                                              addInput: (
                                                                                                                                                                                                                              txHash: Buffer | string | Transaction,
                                                                                                                                                                                                                              vout: number,
                                                                                                                                                                                                                              sequence?: number,
                                                                                                                                                                                                                              prevOutScript?: any
                                                                                                                                                                                                                              ) => number;

                                                                                                                                                                                                                                method addOutput

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

                                                                                                                                                                                                                                  method build

                                                                                                                                                                                                                                  build: () => Transaction;

                                                                                                                                                                                                                                    method buildIncomplete

                                                                                                                                                                                                                                    buildIncomplete: () => Transaction;

                                                                                                                                                                                                                                      method fromTransaction

                                                                                                                                                                                                                                      static fromTransaction: (
                                                                                                                                                                                                                                      transaction: Transaction,
                                                                                                                                                                                                                                      network?: Network
                                                                                                                                                                                                                                      ) => TransactionBuilder;

                                                                                                                                                                                                                                        method setLockTime

                                                                                                                                                                                                                                        setLockTime: (locktime: number) => void;

                                                                                                                                                                                                                                          method setLowR

                                                                                                                                                                                                                                          setLowR: (setting?: boolean) => boolean;

                                                                                                                                                                                                                                            method setVersion

                                                                                                                                                                                                                                            setVersion: (version: number) => void;

                                                                                                                                                                                                                                              method sign

                                                                                                                                                                                                                                              sign: (
                                                                                                                                                                                                                                              signParams: number | TxbSignArg,
                                                                                                                                                                                                                                              keyPair?: Signer,
                                                                                                                                                                                                                                              redeemScript?: any,
                                                                                                                                                                                                                                              hashType?: number,
                                                                                                                                                                                                                                              witnessValue?: number,
                                                                                                                                                                                                                                              witnessScript?: any
                                                                                                                                                                                                                                              ) => void;

                                                                                                                                                                                                                                                Interfaces

                                                                                                                                                                                                                                                interface ECPairInterface

                                                                                                                                                                                                                                                interface ECPairInterface extends Signer {}

                                                                                                                                                                                                                                                  property compressed

                                                                                                                                                                                                                                                  compressed: boolean;

                                                                                                                                                                                                                                                    property lowR

                                                                                                                                                                                                                                                    lowR: boolean;

                                                                                                                                                                                                                                                      property network

                                                                                                                                                                                                                                                      network: Network;

                                                                                                                                                                                                                                                        property privateKey

                                                                                                                                                                                                                                                        privateKey?: Buffer;

                                                                                                                                                                                                                                                          method toWIF

                                                                                                                                                                                                                                                          toWIF: () => string;

                                                                                                                                                                                                                                                            method verify

                                                                                                                                                                                                                                                            verify: (hash: any, signature: any) => boolean;

                                                                                                                                                                                                                                                              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 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 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: () => any;

                                                                                                                                                                                                                                                                                                                                  method sign

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

                                                                                                                                                                                                                                                                                                                                    interface SignerAsync

                                                                                                                                                                                                                                                                                                                                    interface SignerAsync {}

                                                                                                                                                                                                                                                                                                                                      property network

                                                                                                                                                                                                                                                                                                                                      network?: any;

                                                                                                                                                                                                                                                                                                                                        property publicKey

                                                                                                                                                                                                                                                                                                                                        publicKey: Buffer;

                                                                                                                                                                                                                                                                                                                                          method getPublicKey

                                                                                                                                                                                                                                                                                                                                          getPublicKey: () => any;

                                                                                                                                                                                                                                                                                                                                            method sign

                                                                                                                                                                                                                                                                                                                                            sign: (hash: any, lowR?: boolean) => 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 OpCode

                                                                                                                                                                                                                                                                                                                                                                type OpCode = number;

                                                                                                                                                                                                                                                                                                                                                                  type PaymentCreator

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

                                                                                                                                                                                                                                                                                                                                                                    type Stack

                                                                                                                                                                                                                                                                                                                                                                    type Stack = StackElement[];

                                                                                                                                                                                                                                                                                                                                                                      type StackElement

                                                                                                                                                                                                                                                                                                                                                                      type StackElement = Buffer | number;

                                                                                                                                                                                                                                                                                                                                                                        Namespaces

                                                                                                                                                                                                                                                                                                                                                                        namespace address

                                                                                                                                                                                                                                                                                                                                                                        module 'types/address.d.ts' {}

                                                                                                                                                                                                                                                                                                                                                                          function fromBase58Check

                                                                                                                                                                                                                                                                                                                                                                          fromBase58Check: (address: string) => Base58CheckResult;

                                                                                                                                                                                                                                                                                                                                                                            function fromBech32

                                                                                                                                                                                                                                                                                                                                                                            fromBech32: (address: string) => Bech32Result;

                                                                                                                                                                                                                                                                                                                                                                              function fromOutputScript

                                                                                                                                                                                                                                                                                                                                                                              fromOutputScript: (output: any, network?: Network) => string;

                                                                                                                                                                                                                                                                                                                                                                                function toBase58Check

                                                                                                                                                                                                                                                                                                                                                                                toBase58Check: (hash: any, version: number) => string;

                                                                                                                                                                                                                                                                                                                                                                                  function toBech32

                                                                                                                                                                                                                                                                                                                                                                                  toBech32: (data: any, version: number, prefix: string) => string;

                                                                                                                                                                                                                                                                                                                                                                                    function toOutputScript

                                                                                                                                                                                                                                                                                                                                                                                    toOutputScript: (address: string, network?: Network) => any;

                                                                                                                                                                                                                                                                                                                                                                                      interface Base58CheckResult

                                                                                                                                                                                                                                                                                                                                                                                      interface Base58CheckResult {}

                                                                                                                                                                                                                                                                                                                                                                                        property hash

                                                                                                                                                                                                                                                                                                                                                                                        hash: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                          property version

                                                                                                                                                                                                                                                                                                                                                                                          version: number;

                                                                                                                                                                                                                                                                                                                                                                                            interface Bech32Result

                                                                                                                                                                                                                                                                                                                                                                                            interface Bech32Result {}

                                                                                                                                                                                                                                                                                                                                                                                              property data

                                                                                                                                                                                                                                                                                                                                                                                              data: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                property prefix

                                                                                                                                                                                                                                                                                                                                                                                                prefix: string;

                                                                                                                                                                                                                                                                                                                                                                                                  property version

                                                                                                                                                                                                                                                                                                                                                                                                  version: number;

                                                                                                                                                                                                                                                                                                                                                                                                    namespace crypto

                                                                                                                                                                                                                                                                                                                                                                                                    module 'types/crypto.d.ts' {}

                                                                                                                                                                                                                                                                                                                                                                                                      function hash160

                                                                                                                                                                                                                                                                                                                                                                                                      hash160: (buffer: any) => any;

                                                                                                                                                                                                                                                                                                                                                                                                        function hash256

                                                                                                                                                                                                                                                                                                                                                                                                        hash256: (buffer: any) => any;

                                                                                                                                                                                                                                                                                                                                                                                                          function ripemd160

                                                                                                                                                                                                                                                                                                                                                                                                          ripemd160: (buffer: any) => any;

                                                                                                                                                                                                                                                                                                                                                                                                            function sha1

                                                                                                                                                                                                                                                                                                                                                                                                            sha1: (buffer: any) => any;

                                                                                                                                                                                                                                                                                                                                                                                                              function sha256

                                                                                                                                                                                                                                                                                                                                                                                                              sha256: (buffer: any) => any;

                                                                                                                                                                                                                                                                                                                                                                                                                namespace ECPair

                                                                                                                                                                                                                                                                                                                                                                                                                module 'types/ecpair.d.ts' {}

                                                                                                                                                                                                                                                                                                                                                                                                                  function fromPrivateKey

                                                                                                                                                                                                                                                                                                                                                                                                                  fromPrivateKey: (buffer: any, options?: ECPairOptions) => ECPair;

                                                                                                                                                                                                                                                                                                                                                                                                                    function fromPublicKey

                                                                                                                                                                                                                                                                                                                                                                                                                    fromPublicKey: (buffer: any, options?: ECPairOptions) => ECPair;

                                                                                                                                                                                                                                                                                                                                                                                                                      function fromWIF

                                                                                                                                                                                                                                                                                                                                                                                                                      fromWIF: (wifString: string, network?: Network | Network[]) => ECPair;

                                                                                                                                                                                                                                                                                                                                                                                                                        function makeRandom

                                                                                                                                                                                                                                                                                                                                                                                                                        makeRandom: (options?: ECPairOptions) => ECPair;

                                                                                                                                                                                                                                                                                                                                                                                                                          interface ECPairInterface

                                                                                                                                                                                                                                                                                                                                                                                                                          interface ECPairInterface extends Signer {}

                                                                                                                                                                                                                                                                                                                                                                                                                            property compressed

                                                                                                                                                                                                                                                                                                                                                                                                                            compressed: boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                              property lowR

                                                                                                                                                                                                                                                                                                                                                                                                                              lowR: boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                property network

                                                                                                                                                                                                                                                                                                                                                                                                                                network: Network;

                                                                                                                                                                                                                                                                                                                                                                                                                                  property privateKey

                                                                                                                                                                                                                                                                                                                                                                                                                                  privateKey?: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                                                    method toWIF

                                                                                                                                                                                                                                                                                                                                                                                                                                    toWIF: () => string;

                                                                                                                                                                                                                                                                                                                                                                                                                                      method verify

                                                                                                                                                                                                                                                                                                                                                                                                                                      verify: (hash: any, signature: any) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                        interface Signer

                                                                                                                                                                                                                                                                                                                                                                                                                                        interface Signer {}

                                                                                                                                                                                                                                                                                                                                                                                                                                          property network

                                                                                                                                                                                                                                                                                                                                                                                                                                          network?: any;

                                                                                                                                                                                                                                                                                                                                                                                                                                            property publicKey

                                                                                                                                                                                                                                                                                                                                                                                                                                            publicKey: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                                                              method getPublicKey

                                                                                                                                                                                                                                                                                                                                                                                                                                              getPublicKey: () => any;

                                                                                                                                                                                                                                                                                                                                                                                                                                                method sign

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                  interface SignerAsync

                                                                                                                                                                                                                                                                                                                                                                                                                                                  interface SignerAsync {}

                                                                                                                                                                                                                                                                                                                                                                                                                                                    property network

                                                                                                                                                                                                                                                                                                                                                                                                                                                    network?: any;

                                                                                                                                                                                                                                                                                                                                                                                                                                                      property publicKey

                                                                                                                                                                                                                                                                                                                                                                                                                                                      publicKey: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                                                                        method getPublicKey

                                                                                                                                                                                                                                                                                                                                                                                                                                                        getPublicKey: () => any;

                                                                                                                                                                                                                                                                                                                                                                                                                                                          method sign

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                            namespace networks

                                                                                                                                                                                                                                                                                                                                                                                                                                                            module 'types/networks.d.ts' {}

                                                                                                                                                                                                                                                                                                                                                                                                                                                              variable bitcoin

                                                                                                                                                                                                                                                                                                                                                                                                                                                              const bitcoin: Network;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                variable regtest

                                                                                                                                                                                                                                                                                                                                                                                                                                                                const regtest: Network;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  variable testnet

                                                                                                                                                                                                                                                                                                                                                                                                                                                                  const testnet: Network;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    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 'types/payments/index.d.ts' {}

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    function embed

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      function p2ms

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        function p2pk

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          function p2pkh

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            function p2sh

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              function p2wpkh

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                function p2wsh

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  interface Payment

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  interface Payment {}

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    property address

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    address?: string;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      property data

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      data?: Buffer[];

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        property hash

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        hash?: Buffer;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          property input

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          input?: 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 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 'types/script.d.ts' {}

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    variable number

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    const number: typeof scriptNumber;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      variable OPS

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        variable signature

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        const signature: typeof scriptSignature;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          function compile

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          compile: (chunks: Buffer | Stack) => any;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            function decompile

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

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              function fromASM

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              fromASM: (asm: string) => any;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                function isCanonicalPubKey

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                isCanonicalPubKey: (buffer: any) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  function isCanonicalScriptSignature

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  isCanonicalScriptSignature: (buffer: any) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    function isDefinedHashType

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    isDefinedHashType: (hashType: number) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      function isPushOnly

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      isPushOnly: (value: Stack) => boolean;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        function toASM

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        toASM: (chunks: Buffer | Array<number | Buffer>) => string;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          function toStack

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          toStack: (chunks: Buffer | Array<number | Buffer>) => Buffer[];

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            type OpCode

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            type OpCode = number;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Package Files (18)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Dependencies (15)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Dev Dependencies (21)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              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>