Caravan Documentation
    Preparing search index...

    Function estimateTransactionVsize

    • Estimates the virtual size (vsize) of a transaction.

      This function calculates the estimated vsize for different address types, including P2SH, P2SH_P2WSH, P2WSH, and P2WPKH. The vsize is crucial for fee estimation in Bitcoin transactions, especially for SegWit transactions where the witness data is discounted.

      Calculation Method:

      1. For non-SegWit (P2SH): vsize = transaction size
      2. For SegWit (P2SH_P2WSH, P2WSH, P2WPKH): vsize = (transaction weight) / 4, rounded up where transaction weight = (base size * 3) + total size

      References:

      Parameters

      • config: {
            addressType?: MultisigAddressType;
            m?: number;
            n?: number;
            numInputs?: number;
            numOutputs?: number;
        } = {}

        Configuration object for the transaction

        • OptionaladdressType?: MultisigAddressType

          The type of address used (P2SH, P2SH_P2WSH, P2WSH, P2WPKH)

        • Optionalm?: number

          Number of required signatures (for multisig)

        • Optionaln?: number

          Total number of possible signers (for multisig)

        • OptionalnumInputs?: number

          Number of inputs in the transaction

        • OptionalnumOutputs?: number

          Number of outputs in the transaction

      Returns number

      The estimated virtual size (vsize) of the transaction in vbytes

      Will throw an error if the address type is unsupported