Table of Contents

Class HdWalletRecoveryService

Namespace
NArk.Core.Recovery
Assembly
NArk.Core.dll

Iteratively probes derivation indices of an HD wallet to recover contracts that were used before the wallet was imported into local storage. Each index is probed by every registered IContractDiscoveryProvider (arkd indexer, on-chain boarding, …) and the union of results determines whether the index counts as used.

public class HdWalletRecoveryService
Inheritance
HdWalletRecoveryService
Inherited Members

Remarks

The scan stops once GapLimit consecutive unused indices are seen, or once MaxIndex is reached. Discovered contracts are persisted via IContractStorage and wallet.LastUsedIndex is bumped to HighestUsedIndex + 1 so future derivations don't collide with recovered scripts.

Constructors

HdWalletRecoveryService(IEnumerable<IContractDiscoveryProvider>, IWalletStorage, IContractStorage, IClientTransport, ILogger<HdWalletRecoveryService>?)

Iteratively probes derivation indices of an HD wallet to recover contracts that were used before the wallet was imported into local storage. Each index is probed by every registered IContractDiscoveryProvider (arkd indexer, on-chain boarding, …) and the union of results determines whether the index counts as used.

public HdWalletRecoveryService(IEnumerable<IContractDiscoveryProvider> providers, IWalletStorage walletStorage, IContractStorage contractStorage, IClientTransport clientTransport, ILogger<HdWalletRecoveryService>? logger = null)

Parameters

providers IEnumerable<IContractDiscoveryProvider>
walletStorage IWalletStorage
contractStorage IContractStorage
clientTransport IClientTransport
logger ILogger<HdWalletRecoveryService>

Remarks

The scan stops once GapLimit consecutive unused indices are seen, or once MaxIndex is reached. Discovered contracts are persisted via IContractStorage and wallet.LastUsedIndex is bumped to HighestUsedIndex + 1 so future derivations don't collide with recovered scripts.

Methods

ScanAsync(string, RecoveryOptions?, CancellationToken)

Scan an HD wallet's derivation indices for prior usage.

public Task<RecoveryReport> ScanAsync(string walletId, RecoveryOptions? options = null, CancellationToken cancellationToken = default)

Parameters

walletId string

The wallet to recover. MUST be a HD wallet.

options RecoveryOptions

Scan configuration. Defaults to Default.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<RecoveryReport>

A RecoveryReport describing what was found.

Exceptions

InvalidOperationException

If the wallet is not HD, has no AccountDescriptor, or is unknown.