• Computes the virtual size (vsize) of a Bitcoin transaction based on specified inputs and outputs.

    Parameters

    • inputs: {}[]

      Array of OutputInstance representing the inputs of the transaction.

    • outputs: {}[]

      Array of OutputInstance representing the outputs of the transaction.

    • Optional signaturesPerInput: PartialSig[][]

      Optional array of arrays containing signatures. The outer array corresponds to each input in the transaction. The inner array contains signatures for each public key associated with the respective input.

      If provided, enables calculation of exact signature sizes. Defaults to assuming 72 bytes per signature. Mainly used for testing and accurate fee estimation.

    Returns number

    The computed virtual size (vsize) of the transaction, rounded up to the nearest integer.

    NOTE: When the descriptor in an input is addr(address), it is assumed that any addr(SH_TYPE_ADDRESS) is in fact a Segwit SH_WPKH (Script Hash-Witness Public Key Hash). For inputs using arbitrary scripts (not standard addresses), use a descriptor in the format sh(MINISCRIPT).

    Example

    const vsizeValue = vsize(
    [new Output({ descriptor: 'addr(...)' })], // inputs
    [new Output({ descriptor: 'addr(...)' })] // outputs
    );

    See

    https://bitcoinerlab.com/modules/descriptors for details on OutputInstance and descriptors.