btcutil-js - v0.2.0
    Preparing search index...

    Variable txscriptConst

    txscript: {
        assembleTaprootScriptTree(
            internalKey: Bytes,
            leaves: TapLeafInput[],
        ): Promise<TapScriptTreeResult>;
        calcMultiSigStats(script: Bytes): Promise<MultiSigStats>;
        calcSignatureHash(
            script: Bytes,
            hashType: number,
            rawTx: Bytes,
            inputIndex: number,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        calcTaprootSignatureHash(
            hashType: number,
            rawTx: Bytes,
            inputIndex: number,
            prevOuts: PrevOut[],
        ): Promise<Uint8Array<ArrayBufferLike>>;
        calcWitnessSigHash(
            script: Bytes,
            hashType: number,
            rawTx: Bytes,
            inputIndex: number,
            amount: number,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        computePkScript(
            sigScript: Bytes,
            witness: Bytes[],
            network?: Network,
        ): Promise<PkScriptInfo>;
        computeTaprootKeyNoScript(
            internalKey: Bytes,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        computeTaprootOutputKey(
            internalKey: Bytes,
            scriptRoot?: Bytes,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        disasmString(script: Bytes): Promise<string>;
        extractPkScriptAddrs(
            script: Bytes,
            network?: Network,
        ): Promise<PkScriptAddrsResult>;
        extractWitnessProgramInfo(script: Bytes): Promise<WitnessProgramInfo>;
        getScriptClass(script: Bytes): Promise<string>;
        getSigOpCount(script: Bytes): Promise<number>;
        isMultisigScript(script: Bytes): Promise<boolean>;
        isNullData(script: Bytes): Promise<boolean>;
        isPayToPubKey(script: Bytes): Promise<boolean>;
        isPayToPubKeyHash(script: Bytes): Promise<boolean>;
        isPayToScriptHash(script: Bytes): Promise<boolean>;
        isPayToTaproot(script: Bytes): Promise<boolean>;
        isPayToWitnessPubKeyHash(script: Bytes): Promise<boolean>;
        isPayToWitnessScriptHash(script: Bytes): Promise<boolean>;
        isPushOnlyScript(script: Bytes): Promise<boolean>;
        isUnspendable(script: Bytes): Promise<boolean>;
        isWitnessProgram(script: Bytes): Promise<boolean>;
        multiSigScript(
            pubKeys: Bytes[],
            nRequired: number,
            network?: Network,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        nullDataScript(data: Bytes): Promise<Uint8Array<ArrayBufferLike>>;
        parseControlBlock(controlBlock: Bytes): Promise<ControlBlockInfo>;
        parsePkScript(script: Bytes, network?: Network): Promise<PkScriptInfo>;
        payToAddrScript(
            address: string,
            network?: Network,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        payToTaprootScript(pubKey: Bytes): Promise<Uint8Array<ArrayBufferLike>>;
        pushedData(script: Bytes): Promise<Uint8Array<ArrayBufferLike>[]>;
        rawTxInSignature(
            rawTx: Bytes,
            inputIndex: number,
            subScript: Bytes,
            hashType: number,
            privKey: Bytes,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        rawTxInTaprootSignature(
            rawTx: Bytes,
            inputIndex: number,
            merkleRoot: Bytes,
            hashType: number,
            privKey: Bytes,
            prevOuts: PrevOut[],
        ): Promise<Uint8Array<ArrayBufferLike>>;
        rawTxInWitnessSignature(
            rawTx: Bytes,
            inputIndex: number,
            amount: number,
            subScript: Bytes,
            hashType: number,
            privKey: Bytes,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        scriptHasOpSuccess(script: Bytes): Promise<boolean>;
        tweakTaprootPrivKey(
            privKey: Bytes,
            scriptRoot?: Bytes,
        ): Promise<Uint8Array<ArrayBufferLike>>;
        witnessSignature(
            rawTx: Bytes,
            inputIndex: number,
            amount: number,
            subScript: Bytes,
            hashType: number,
            privKey: Bytes,
            compress: boolean,
        ): Promise<Uint8Array<ArrayBufferLike>[]>;
    } = ...

    Bitcoin transaction script analysis, creation, taproot, and signing.

    Type Declaration

    • assembleTaprootScriptTree: function
    • calcMultiSigStats: function
      • Get multisig script statistics (number of pubkeys and required sigs). Calls Go: txscript.CalcMultiSigStats() from btcd/txscript.

        Parameters

        Returns Promise<MultiSigStats>

    • calcSignatureHash: function
      • Compute a legacy (pre-segwit) signature hash. Calls Go: txscript.CalcSignatureHash() from btcd/txscript.

        Parameters

        • script: Bytes
        • hashType: number
        • rawTx: Bytes
        • inputIndex: number

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • calcTaprootSignatureHash: function
      • Compute a BIP-341 taproot signature hash. Requires prevOuts for all inputs. Calls Go: txscript.CalcTaprootSignatureHash() from btcd/txscript.

        Parameters

        • hashType: number
        • rawTx: Bytes
        • inputIndex: number
        • prevOuts: PrevOut[]

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • calcWitnessSigHash: function
      • Compute a BIP-143 witness v0 signature hash. Calls Go: txscript.CalcWitnessSigHash() from btcd/txscript.

        Parameters

        • script: Bytes
        • hashType: number
        • rawTx: Bytes
        • inputIndex: number
        • amount: number

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • computePkScript: function
    • computeTaprootKeyNoScript: function
      • Compute the taproot output key for a key-only spend (no script tree). Calls Go: txscript.ComputeTaprootKeyNoScript() from btcd/txscript.

        Parameters

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • computeTaprootOutputKey: function
      • Compute the taproot output key from an internal key and optional script root. Calls Go: txscript.ComputeTaprootOutputKey() from btcd/txscript.

        Parameters

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • disasmString: function
      • Disassemble a script to human-readable opcodes. Calls Go: txscript.DisasmString() from btcd/txscript.

        Parameters

        Returns Promise<string>

    • extractPkScriptAddrs: function
    • extractWitnessProgramInfo: function
    • getScriptClass: function
      • Get the standard script class name. Calls Go: txscript.GetScriptClass() from btcd/txscript.

        Parameters

        Returns Promise<string>

    • getSigOpCount: function
      • Count signature operations in a script. Calls Go: txscript.GetSigOpCount() from btcd/txscript.

        Parameters

        Returns Promise<number>

    • isMultisigScript: function
      • Calls Go: txscript.IsMultisigScript() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isNullData: function
      • Calls Go: txscript.IsNullData() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isPayToPubKey: function
      • Calls Go: txscript.IsPayToPubKey() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isPayToPubKeyHash: function
      • Calls Go: txscript.IsPayToPubKeyHash() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isPayToScriptHash: function
      • Calls Go: txscript.IsPayToScriptHash() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isPayToTaproot: function
      • Calls Go: txscript.IsPayToTaproot() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isPayToWitnessPubKeyHash: function
      • Calls Go: txscript.IsPayToWitnessPubKeyHash() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isPayToWitnessScriptHash: function
      • Calls Go: txscript.IsPayToWitnessScriptHash() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isPushOnlyScript: function
      • Calls Go: txscript.IsPushOnlyScript() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isUnspendable: function
      • Calls Go: txscript.IsUnspendable() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • isWitnessProgram: function
      • Calls Go: txscript.IsWitnessProgram() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • multiSigScript: function
      • Create a multisig script from public keys (hex[]). Calls Go: txscript.MultiSigScript() from btcd/txscript.

        Parameters

        • pubKeys: Bytes[]
        • nRequired: number
        • network: Network = 'mainnet'

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • nullDataScript: function
      • Create an OP_RETURN null data script. Calls Go: txscript.NullDataScript() from btcd/txscript.

        Parameters

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • parseControlBlock: function
    • parsePkScript: function
    • payToAddrScript: function
      • Create a pkScript that pays to the given address. Calls Go: txscript.PayToAddrScript() from btcd/txscript.

        Parameters

        • address: string
        • network: Network = 'mainnet'

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • payToTaprootScript: function
      • Create a P2TR script from a 32-byte x-only public key (hex). Calls Go: txscript.PayToTaprootScript() from btcd/txscript.

        Parameters

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • pushedData: function
      • Extract all data pushes from a script. Calls Go: txscript.PushedData() from btcd/txscript.

        Parameters

        Returns Promise<Uint8Array<ArrayBufferLike>[]>

    • rawTxInSignature: function
      • Create a legacy input signature (DER-encoded + hashType byte). Calls Go: txscript.RawTxInSignature() from btcd/txscript.

        Parameters

        • rawTx: Bytes
        • inputIndex: number
        • subScript: Bytes
        • hashType: number
        • privKey: Bytes

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • rawTxInTaprootSignature: function
      • Create a taproot key-path signature. Requires prevOuts for all inputs. Calls Go: txscript.RawTxInTaprootSignature() from btcd/txscript.

        Parameters

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • rawTxInWitnessSignature: function
      • Create a witness v0 input signature (DER-encoded + hashType byte). Calls Go: txscript.RawTxInWitnessSignature() from btcd/txscript.

        Parameters

        • rawTx: Bytes
        • inputIndex: number
        • amount: number
        • subScript: Bytes
        • hashType: number
        • privKey: Bytes

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • scriptHasOpSuccess: function
      • Calls Go: txscript.ScriptHasOpSuccess() from btcd/txscript.

        Parameters

        Returns Promise<boolean>

    • tweakTaprootPrivKey: function
      • Tweak a private key for taproot key-path spending. Calls Go: txscript.TweakTaprootPrivKey() from btcd/txscript.

        Parameters

        Returns Promise<Uint8Array<ArrayBufferLike>>

    • witnessSignature: function
      • Create a complete witness stack (signature + pubkey) for a P2WPKH spend. Calls Go: txscript.WitnessSignature() from btcd/txscript.

        Parameters

        • rawTx: Bytes
        • inputIndex: number
        • amount: number
        • subScript: Bytes
        • hashType: number
        • privKey: Bytes
        • compress: boolean

        Returns Promise<Uint8Array<ArrayBufferLike>[]>