Caravan Documentation
    Preparing search index...

    Function createOutputScript

    • Creates an output script for a given Bitcoin address.

      This function validates the provided address and creates an appropriate output script based on the address type (P2PKH, P2SH, P2WPKH,P2TR or P2WSH). It supports both mainnet, testnet and regtest addresses.

      Parameters

      • destinationAddress: string

        The Bitcoin address to create an output script for.

      • network: Network

        The Bitcoin network (mainnet ,testnet or regtest) the address belongs to.

      Returns Buffer

      The output script as a Buffer.

      If the address is invalid or unsupported, or if the output script cannot be created.

      const script = createOutputScript('1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2', Network.MAINNET);