@btc-stamps/tx-builder - v0.1.7
    Preparing search index...

    Class BranchAndBoundSelector

    Branch and Bound UTXO selection algorithm for optimal coin selection

    Implements the Branch and Bound algorithm to find the optimal set of UTXOs that minimizes transaction fees. This algorithm explores different combinations to find exact matches or minimal change amounts.

    Features:

    • Finds changeless solutions when possible (40% target success rate)
    • Minimizes total fees over time using waste metric
    • Bitcoin Core compatible implementation
    • O(n²) pruning for efficiency
    const selector = new BranchAndBoundSelector();
    const result = selector.select(utxos, {
    targetValue: 100000,
    feeRate: 10,
    changeAddress: 'bc1q...'
    });

    Hierarchy

    • BaseSelector
      • BranchAndBoundSelector
    Index

    Constructors

    Properties

    DUST_THRESHOLD: 546
    INPUT_SIZE: 148
    OUTPUT_SIZE: 34
    TRANSACTION_OVERHEAD: 10

    Methods

    • Calculate change amount

      Parameters

      • inputValue: number
      • targetValue: number
      • fee: number

      Returns number

    • Enhanced waste calculation with Bitcoin Core alignment

      Parameters

      • inputs: UTXO[]
      • targetValue: number
      • feeRate: number
      • longTermFeeRate: number = ...

      Returns number

    • Create selection result

      Parameters

      • inputs: UTXO[]
      • targetValue: number
      • feeRate: number
      • hasChange: boolean

      Returns SelectionSuccess

    • Estimate transaction fee

      Parameters

      • numInputs: number
      • numOutputs: number
      • feeRate: number

      Returns number

    • Estimate transaction size in vBytes

      Parameters

      • numInputs: number
      • numOutputs: number

      Returns number

    • Filter UTXOs based on confirmation requirements

      Parameters

      • utxos: UTXO[]
      • minConfirmations: number = 0

      Returns UTXO[]

    • Get algorithm performance metrics

      Returns {
          costOfChange: number;
          longTermFeeRate: number;
          maxDepth: number;
          maxIterations: number;
      }

    • Check if amount is dust

      Parameters

      • amount: number
      • OptionaldustThreshold: number

      Returns boolean

    • Sort UTXOs by value (ascending)

      Parameters

      • utxos: UTXO[]
      • descending: boolean = false

      Returns UTXO[]