@arkade-os/sdk Documentation - v0.4.21
    Preparing search index...

    Class Script

    Virtual Hash Time Lock Contract (VHTLC) script implementation.

    VHTLC enables atomic swaps and conditional payments in the Arkade protocol. It provides multiple spending paths:

    • claim: Receiver can claim funds by revealing the preimage
    • refund: Sender and receiver can collaboratively refund
    • refundWithoutReceiver: Sender can refund after locktime expires
    • unilateralClaim: Receiver can claim unilaterally after delay
    • unilateralRefund: Sender and receiver can refund unilaterally after delay
    • unilateralRefundWithoutReceiver: Sender can refund unilaterally after delay
    const vhtlc = new VHTLC.Script({
    sender: alicePubKey,
    receiver: bobPubKey,
    server: serverPubKey,
    preimageHash: hash160(secret),
    refundLocktime: BigInt(chainTip + 10),
    unilateralClaimDelay: { type: 'blocks', value: 100n },
    unilateralRefundDelay: { type: 'blocks', value: 102n },
    unilateralRefundWithoutReceiverDelay: { type: 'blocks', value: 103n }
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    claimScript: string
    leaves: TapLeafScript[]
    options: VHTLC.Options
    refundScript: string
    refundWithoutReceiverScript: string
    scripts: Bytes[]

    Raw tapscript bytes for each leaf

    tweakedPublicKey: Bytes
    unilateralClaimScript: string
    unilateralRefundScript: string
    unilateralRefundWithoutReceiverScript: string

    Accessors

    • get pkScript(): Bytes

      Returns Bytes

    Methods

    • Build the Arkade address corresponding to this virtual output script.

      Parameters

      • prefix: string

        Bech32 human-readable prefix

      • serverPubKey: Bytes

        32-byte Arkade server public key

      Returns ArkAddress

      Arkade address for this script

      ArkAddress

    • Encode the virtual output script to a TapTree byte representation.

      Returns Bytes

      Encoded TapTree bytes

      decode

    • Look up a tapleaf script by its hex-encoded tapscript body.

      Parameters

      • scriptHex: string

        Hex-encoded tapscript body without the leaf version byte

      Returns TapLeafScript

      Matching tapleaf script

      Error if no matching leaf exists

    • Build the Taproot onchain address corresponding to this virtual output script.

      Parameters

      • network: BTC_NETWORK

        Bitcoin network descriptor

      Returns string

      Taproot onchain address

      address

    • Decode a virtual output script from an encoded TapTree.

      Parameters

      • tapTree: Bytes

        Encoded TapTree bytes

      Returns VtxoScript

      Decoded virtual output script

      Error if the TapTree cannot be decoded into a valid script set

      encode