Manages the unrolling process of a VTXO 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 VTXO ${doneStep.vtxoTxid}`);
break;
}
}

Implements

Constructors

Properties

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

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