Table of Contents

Class CachingClientTransport

Namespace
NArk.Core.Transport
Assembly
NArk.Core.dll

Caching decorator for IClientTransport that caches GetServerInfoAsync responses. Server info (network, dust limit, signer key) rarely changes during operation. All other methods are passed through to the underlying transport.

public class CachingClientTransport : IClientTransport, IServerInfoCacheInvalidation
Inheritance
CachingClientTransport
Implements
Inherited Members

Constructors

CachingClientTransport(IClientTransport, ILogger<CachingClientTransport>?, TimeSpan?, TimeSpan?)

public CachingClientTransport(IClientTransport inner, ILogger<CachingClientTransport>? logger = null, TimeSpan? cacheExpiry = null, TimeSpan? fetchTimeout = null)

Parameters

inner IClientTransport
logger ILogger<CachingClientTransport>
cacheExpiry TimeSpan?
fetchTimeout TimeSpan?

Fields

DefaultCacheExpiry

public static readonly TimeSpan DefaultCacheExpiry

Field Value

TimeSpan

DefaultFetchTimeout

public static readonly TimeSpan DefaultFetchTimeout

Field Value

TimeSpan

Properties

HasValidServerInfoCache

Checks if the server info cache currently has valid data.

public bool HasValidServerInfoCache { get; }

Property Value

bool

Methods

ConfirmRegistrationAsync(string, CancellationToken)

public Task ConfirmRegistrationAsync(string intentId, CancellationToken cancellationToken)

Parameters

intentId string
cancellationToken CancellationToken

Returns

Task

DeleteIntent(ArkIntent, CancellationToken)

public Task DeleteIntent(ArkIntent intent, CancellationToken cancellationToken = default)

Parameters

intent ArkIntent
cancellationToken CancellationToken

Returns

Task

FinalizeTx(string, string[], CancellationToken)

public Task FinalizeTx(string arkTxId, string[] finalCheckpointTxs, CancellationToken cancellationToken)

Parameters

arkTxId string
finalCheckpointTxs string[]
cancellationToken CancellationToken

Returns

Task

GetAssetDetailsAsync(string, CancellationToken)

public Task<ArkAssetDetails> GetAssetDetailsAsync(string assetId, CancellationToken cancellationToken = default)

Parameters

assetId string
cancellationToken CancellationToken

Returns

Task<ArkAssetDetails>

GetEventStreamAsync(GetEventStreamRequest, CancellationToken)

public IAsyncEnumerable<BatchEvent> GetEventStreamAsync(GetEventStreamRequest req, CancellationToken cancellationToken)

Parameters

req GetEventStreamRequest
cancellationToken CancellationToken

Returns

IAsyncEnumerable<BatchEvent>

GetIntentsByProofAsync(string, string, CancellationToken)

Retrieves registered intents by providing a BIP-322 proof of ownership of any input.

public Task<ArkIntent[]> GetIntentsByProofAsync(string proof, string message, CancellationToken cancellationToken = default)

Parameters

proof string
message string
cancellationToken CancellationToken

Returns

Task<ArkIntent[]>

GetPendingTxAsync(string, string, CancellationToken)

Retrieves Arkade transactions the server has registered as pending — i.e. the user called SubmitTx(string, string[], CancellationToken) (server locked the inputs as in-flight) but FinalizeTx(string, string[], CancellationToken) never followed. The server enforces "you must finalize that exact pending tx; you cannot spend those inputs another way", so this endpoint is the only way to recover stranded VTXOs after a crash between Submit and Finalize. Authentication uses a BIP-322-style proof of ownership over any input the SDK believes belongs to the wallet — same shape as GetIntentsByProofAsync(string, string, CancellationToken).

public Task<PendingArkTransaction[]> GetPendingTxAsync(string proof, string message, CancellationToken cancellationToken = default)

Parameters

proof string
message string
cancellationToken CancellationToken

Returns

Task<PendingArkTransaction[]>

GetServerInfoAsync(CancellationToken)

Gets server info with caching. Returns cached value if valid, otherwise fetches from server.

public Task<ArkServerInfo> GetServerInfoAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<ArkServerInfo>

GetVirtualTxsAsync(IReadOnlyList<string>, CancellationToken)

Returns raw tx hex for the given virtual transaction IDs.

public Task<IReadOnlyList<string>> GetVirtualTxsAsync(IReadOnlyList<string> txids, CancellationToken cancellationToken = default)

Parameters

txids IReadOnlyList<string>
cancellationToken CancellationToken

Returns

Task<IReadOnlyList<string>>

GetVtxoByScriptsAsSnapshot(IReadOnlySet<string>, DateTimeOffset?, DateTimeOffset?, CancellationToken)

Queries arkd indexer for VTXOs by scripts, filtered to those updated within the given time range.

public IAsyncEnumerable<ArkVtxo> GetVtxoByScriptsAsSnapshot(IReadOnlySet<string> scripts, DateTimeOffset? after, DateTimeOffset? before, CancellationToken cancellationToken = default)

Parameters

scripts IReadOnlySet<string>
after DateTimeOffset?
before DateTimeOffset?
cancellationToken CancellationToken

Returns

IAsyncEnumerable<ArkVtxo>

GetVtxoByScriptsAsSnapshot(IReadOnlySet<string>, CancellationToken)

public IAsyncEnumerable<ArkVtxo> GetVtxoByScriptsAsSnapshot(IReadOnlySet<string> scripts, CancellationToken cancellationToken = default)

Parameters

scripts IReadOnlySet<string>
cancellationToken CancellationToken

Returns

IAsyncEnumerable<ArkVtxo>

GetVtxoChainAsync(OutPoint, string?, string?, CancellationToken)

Returns the chain of virtual txs for the given VTXO, ordered leaf→root: the VTXO's own tx first, then each ancestor in turn, ending at the on-chain Commitment anchor.

When intentProof and intentMessage are supplied (a BIP-322-style ownership proof built by CreateGetVtxoChainOwnershipProofAsync(ArkCoin, IArkadeWalletSigner, Network, CancellationToken)), the call authenticates against the Arkade indexer: on servers running with withheld/private tx exposure this is what makes the indexer return the chain (and, for withheld, the fully-signed virtual txs) instead of stripping it. The proof is presented on the first page; the server issues an auth token that transparently drives cursor pagination for the remaining pages.

When the proof is omitted the call uses the legacy anonymous outpoint lookup, which only returns data on servers configured with public tx exposure.

public Task<IReadOnlyList<VtxoChainEntry>> GetVtxoChainAsync(OutPoint vtxoOutpoint, string? intentProof = null, string? intentMessage = null, CancellationToken cancellationToken = default)

Parameters

vtxoOutpoint OutPoint
intentProof string
intentMessage string
cancellationToken CancellationToken

Returns

Task<IReadOnlyList<VtxoChainEntry>>

GetVtxoTreeAsync(OutPoint, CancellationToken)

Returns the full VTXO tree structure for a batch outpoint.

public Task<IReadOnlyList<VtxoTreeNode>> GetVtxoTreeAsync(OutPoint batchOutpoint, CancellationToken cancellationToken = default)

Parameters

batchOutpoint OutPoint
cancellationToken CancellationToken

Returns

Task<IReadOnlyList<VtxoTreeNode>>

GetVtxosByOutpoints(IReadOnlyCollection<OutPoint>, bool, CancellationToken)

Queries arkd indexer for VTXOs by outpoints, optionally filtering by spent status.

public IAsyncEnumerable<ArkVtxo> GetVtxosByOutpoints(IReadOnlyCollection<OutPoint> outpoints, bool spentOnly = false, CancellationToken cancellationToken = default)

Parameters

outpoints IReadOnlyCollection<OutPoint>
spentOnly bool
cancellationToken CancellationToken

Returns

IAsyncEnumerable<ArkVtxo>

InvalidateServerInfoCache(ServerInfoChangedEventArgs?)

Invalidates the server info cache, forcing the next call to fetch fresh data. Call this on wallet setup/clear or when connection errors occur. Raises ServerInfoChanged so consumers can react (e.g. signer rotation).

public void InvalidateServerInfoCache(ServerInfoChangedEventArgs? args = null)

Parameters

args ServerInfoChangedEventArgs

OpenSubscriptionStreamAsync(IReadOnlySet<string>?, string?, CancellationToken)

Opens a server-streaming subscription for VTXO script events.

When existingSubscriptionId is null, the server creates a new subscription. The first yielded event is always VtxoSubscriptionStarted carrying the server-assigned ID. Pass initialScripts to register the initial watched set at stream-open time (only honoured on new subscriptions).

When existingSubscriptionId is provided, the server reconnects to an existing subscription. If the subscription was GC'd the stream throws a NotFound error; the caller should retry with a null ID to open a fresh subscription.

public IAsyncEnumerable<VtxoSubscriptionEvent> OpenSubscriptionStreamAsync(IReadOnlySet<string>? initialScripts, string? existingSubscriptionId, CancellationToken cancellationToken = default)

Parameters

initialScripts IReadOnlySet<string>
existingSubscriptionId string
cancellationToken CancellationToken

Returns

IAsyncEnumerable<VtxoSubscriptionEvent>

RegisterIntent(ArkIntent, CancellationToken)

public Task<string> RegisterIntent(ArkIntent intent, CancellationToken cancellationToken = default)

Parameters

intent ArkIntent
cancellationToken CancellationToken

Returns

Task<string>

SubmitSignedForfeitTxsAsync(SubmitSignedForfeitTxsRequest, CancellationToken)

public Task SubmitSignedForfeitTxsAsync(SubmitSignedForfeitTxsRequest req, CancellationToken cancellationToken)

Parameters

req SubmitSignedForfeitTxsRequest
cancellationToken CancellationToken

Returns

Task

SubmitTreeNoncesAsync(SubmitTreeNoncesRequest, CancellationToken)

public Task SubmitTreeNoncesAsync(SubmitTreeNoncesRequest treeNonces, CancellationToken cancellationToken)

Parameters

treeNonces SubmitTreeNoncesRequest
cancellationToken CancellationToken

Returns

Task

SubmitTreeSignaturesRequest(SubmitTreeSignaturesRequest, CancellationToken)

public Task SubmitTreeSignaturesRequest(SubmitTreeSignaturesRequest treeSigs, CancellationToken cancellationToken)

Parameters

treeSigs SubmitTreeSignaturesRequest
cancellationToken CancellationToken

Returns

Task

SubmitTx(string, string[], CancellationToken)

public Task<SubmitTxResponse> SubmitTx(string signedArkTx, string[] checkpointTxs, CancellationToken cancellationToken = default)

Parameters

signedArkTx string
checkpointTxs string[]
cancellationToken CancellationToken

Returns

Task<SubmitTxResponse>

UpdateStreamTopicsAsync(string, string[]?, string[]?, CancellationToken)

public Task UpdateStreamTopicsAsync(string streamId, string[]? addTopics, string[]? removeTopics, CancellationToken cancellationToken = default)

Parameters

streamId string
addTopics string[]
removeTopics string[]
cancellationToken CancellationToken

Returns

Task

UpdateSubscriptionScriptsAsync(string, IReadOnlySet<string>?, IReadOnlySet<string>?, CancellationToken)

Updates the script set of an existing subscription in place without tearing the stream down. Both add and remove are optional; when both are null or empty the call is a no-op. Throws NotFound when the subscription was GC'd.

public Task UpdateSubscriptionScriptsAsync(string subscriptionId, IReadOnlySet<string>? add, IReadOnlySet<string>? remove, CancellationToken cancellationToken = default)

Parameters

subscriptionId string
add IReadOnlySet<string>
remove IReadOnlySet<string>
cancellationToken CancellationToken

Returns

Task

Events

ServerInfoChanged

public event EventHandler<ServerInfoChangedEventArgs>? ServerInfoChanged

Event Type

EventHandler<ServerInfoChangedEventArgs>