Table of Contents

Class VirtualTxService

Namespace
NArk.Core.Services
Assembly
NArk.Core.dll

Fetches, stores, and prunes virtual transaction data for VTXOs. Virtual txs form the tree of pre-signed transactions from commitment tx to VTXO leaf. This data is required for unilateral exit (broadcasting the chain to claim funds on-chain).

public class VirtualTxService
Inheritance
VirtualTxService
Inherited Members

Constructors

VirtualTxService(IClientTransport, IVirtualTxStorage, IVtxoChainProofProvider, ILogger<VirtualTxService>?)

Fetches, stores, and prunes virtual transaction data for VTXOs. Virtual txs form the tree of pre-signed transactions from commitment tx to VTXO leaf. This data is required for unilateral exit (broadcasting the chain to claim funds on-chain).

public VirtualTxService(IClientTransport transport, IVirtualTxStorage storage, IVtxoChainProofProvider proofProvider, ILogger<VirtualTxService>? logger = null)

Parameters

transport IClientTransport
storage IVirtualTxStorage
proofProvider IVtxoChainProofProvider
logger ILogger<VirtualTxService>

Methods

EnsureHexPopulatedAsync(OutPoint, CancellationToken)

public Task EnsureHexPopulatedAsync(OutPoint vtxoOutpoint, CancellationToken cancellationToken = default)

Parameters

vtxoOutpoint OutPoint
cancellationToken CancellationToken

Returns

Task

FetchAndStoreBranchAsync(OutPoint, VirtualTxMode, CancellationToken)

Fetch and store the virtual tx branch for a VTXO. In Lite mode, stores only txids and expiry. In Full mode, also fetches and stores raw tx hex.

public Task FetchAndStoreBranchAsync(OutPoint vtxoOutpoint, VirtualTxMode mode = VirtualTxMode.Full, CancellationToken cancellationToken = default)

Parameters

vtxoOutpoint OutPoint
mode VirtualTxMode
cancellationToken CancellationToken

Returns

Task

IsBranchBroadcastReadyAsync(OutPoint, CancellationToken)

True when every off-chain row of the VTXO's stored branch is fully signed — i.e. broadcastable from storage alone, with no operator refetch. Commitment rows are on-chain anchors and are skipped. Returns false when the branch is missing, has a null-hex off-chain row, or still holds a sig-less template.

public Task<bool> IsBranchBroadcastReadyAsync(OutPoint vtxoOutpoint, CancellationToken cancellationToken = default)

Parameters

vtxoOutpoint OutPoint
cancellationToken CancellationToken

Returns

Task<bool>

PruneForSpentVtxosAsync(IReadOnlyCollection<OutPoint>, CancellationToken)

Prune virtual tx data for spent VTXOs. Removes branch entries, then cleans up orphaned VirtualTx rows.

public Task PruneForSpentVtxosAsync(IReadOnlyCollection<OutPoint> spentOutpoints, CancellationToken cancellationToken = default)

Parameters

spentOutpoints IReadOnlyCollection<OutPoint>
cancellationToken CancellationToken

Returns

Task