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

    Class Session

    Manages the unrolling process of a virtual output back to the Bitcoin blockchain.

    The Session class implements an async iterator that processes the unrolling steps:

    1. WAIT: Waits for a transaction to be confirmed onchain (if it's in mempool)
    2. UNROLL: Broadcasts the next transaction in the chain to the blockchain
    3. DONE: Indicates the unrolling process is complete

    The unrolling process works by traversing the transaction chain from the root (most recent) to the leaf (oldest), broadcasting each transaction that isn't already onchain.

    const session = await Unroll.Session.create(vtxoOutpoint, bumper, explorer, indexer);

    // iterate over the steps
    for await (const doneStep of session) {
    switch (doneStep.type) {
    case Unroll.StepType.WAIT:
    console.log(`Transaction ${doneStep.txid} confirmed`);
    break;
    case Unroll.StepType.UNROLL:
    console.log(`Broadcasting transaction ${doneStep.tx.id}`);
    break;
    case Unroll.StepType.DONE:
    console.log(`Unrolling complete for virtual output ${doneStep.vtxoTxid}`);
    break;
    }
    }

    Implements

    Index

    Constructors

    Properties

    bumper: AnchorBumper
    explorer: OnchainProvider
    toUnroll: Outpoint & { chain: ChainTx[] }
    virtualTxRepository?: VirtualTxRepository

    Optional virtual-tx repository. When provided, each step's raw tx is read from the repo first and fetched from the indexer on a miss, then cached best-effort for later exits. Omitted ⇒ exact previous behaviour (indexer only).

    Methods

    • Iterate over the steps to be executed and execute them

      Returns AsyncIterator<Step>

      An async iterator over the executed steps

    • Get the next step to be executed

      Returns Promise<Step & { do: () => Promise<void> }>

      The next step to be executed + the function to execute it