Class TransactionBuilder<T>Abstract

Allows to build a transaction like you would on Ethereum.

The transaction builder class

TransactionBuilder

Type Parameters

Hierarchy (view full)

Constructors

Properties

Methods

Constructors

Properties

_maximumFeeRate: number = 100000000

The maximum fee rate of the transaction

chalk: ChalkInstance
enableLogs: boolean
estimatedFees: bigint = 0n

The estimated fees of the transaction

feeOutput: null | PsbtOutputExtended = null

Output that will be used to pay the fees

feeRate: number

The fee rate of the transaction

finalized: boolean = false
from: string

The address where the transaction is sent from

hideLogs: boolean
ignoreSignatureErrors: boolean = false
inputs: PsbtInputExtended[] = []

The inputs of the transaction

isBrowser: boolean = false

Is the transaction being generated inside a browser?

isPubKeyDestination: boolean

Is the destionation P2PK

logColor: string = '#785def'
moduleName: string
network: Network

The network where the transaction will be broadcasted

nonWitnessUtxo?: Buffer

Add a non-witness utxo to the transaction

optionalOutputs: undefined | PsbtOutputExtended[]

The transaction parameters

outputs: PsbtOutputExtended[] = []

The outputs of the transaction

overflowFees: bigint = 0n

The overflow fees of the transaction

priorityFee: bigint

The opnet priority fee of the transaction

regenerated: boolean = false
scriptData: null | Payment = null

The script data of the transaction

sequence: number = TransactionSequence.REPLACE_BY_FEE

The sequence of the transaction

sighashTypes: undefined | number[]

The sighash types of the transaction

signed: boolean = false

Was the transaction signed?

signer: ECPairInterface | Signer

The signer of the transaction

tapData: null | Payment = null

The tap data of the transaction

tapLeafScript: null | TapLeafScript = null

The tap leaf script

to: undefined | string

The address where the transaction is sent to

totalInputAmount: bigint

The total amount of satoshis in the inputs

transaction: Psbt

The transaction itself.

transactionFee: bigint = 0n

Cost in satoshis of the transaction fee

tweakedSigner?: ECPairInterface

Tweaked signer

type: T
updateInputs: UpdateInput[] = []

Inputs to update later on.

utxos: UTXO[]

The utxos used in the transaction

LOCK_LEAF_SCRIPT: Buffer = ...
MINIMUM_DUST: bigint = 330n

Methods

  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • Rest...args: string[]

    Returns void

  • Returns void

  • Returns void

  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • msg1: string
    • highlight1: string
    • msg2: string
    • highlight2: string
    • msg3: string

    Returns void

  • Parameters

    • checkPartialSigs: boolean = false

    Returns Promise<void>

    Generates the transaction minimal signatures

  • Returns string

  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • Rest...args: string[]

    Returns void

  • Protected

    Builds the transaction.

    Parameters

    • transaction: Psbt

      The transaction to build

    • checkPartialSigs: boolean = false

    Returns Promise<boolean>

    • If something went wrong while building the transaction
  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • Rest...args: string[]

    Returns void

  • Pre-estimate the transaction fees

    Parameters

    • feeRate: bigint

      The fee rate

    • numInputs: bigint

      The number of inputs

    • numOutputs: bigint

      The number of outputs

    • numSignatures: bigint

      The number of signatures

    • numPubkeys: bigint

      The number of public keys

    Returns bigint

    • The estimated transaction fees
  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • prefix: string

    Returns void

  • Protected

    Signs an input of the transaction.

    Parameters

    • transaction: Psbt

      The transaction to sign

    • input: PsbtInput

      The input to sign

    • i: number

      The index of the input

    • Optionalsigner: ECPairInterface | Signer

      The signer to use

    Returns Promise<void>

  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • Rest...args: string[]

    Returns void

  • Parameters

    • Rest...args: string[]

    Returns void

  • Pre-estimate the transaction fees for a Taproot transaction

    Parameters

    • feeRate: bigint

      The fee rate in satoshis per virtual byte

    • numInputs: bigint

      The number of inputs

    • numOutputs: bigint

      The number of outputs

    • numWitnessElements: bigint

      The number of witness elements (e.g., number of control blocks and witnesses)

    • witnessElementSize: bigint

      The average size of each witness element in bytes

    • emptyWitness: bigint

      The amount of empty witnesses

    • OptionaltaprootControlWitnessSize: bigint = 32n

      The size of the control block witness in bytes

    • OptionaltaprootScriptSize: bigint = 139n

      The size of the taproot script in bytes

    Returns bigint

    • The estimated transaction fees