Table of Contents

Interface IWalletStorage

Namespace
NArk.Abstractions.Wallets
Assembly
NArk.Abstractions.dll

Persistence for wallet records.

public interface IWalletStorage

Methods

DeleteWallet(string, CancellationToken)

Deletes the wallet. Returns true if it existed.

Task<bool> DeleteWallet(string walletId, CancellationToken ct = default)

Parameters

walletId string
ct CancellationToken

Returns

Task<bool>

GetWalletById(string, CancellationToken)

Returns the wallet with the given ID, or null.

Task<ArkWalletInfo?> GetWalletById(string walletId, CancellationToken ct = default)

Parameters

walletId string
ct CancellationToken

Returns

Task<ArkWalletInfo>

GetWalletsByIds(IEnumerable<string>, CancellationToken)

Returns wallets matching the given IDs; silently omits IDs not found.

Task<IReadOnlyList<ArkWalletInfo>> GetWalletsByIds(IEnumerable<string> walletIds, CancellationToken ct = default)

Parameters

walletIds IEnumerable<string>
ct CancellationToken

Returns

Task<IReadOnlyList<ArkWalletInfo>>

LoadAllWallets(CancellationToken)

Returns all wallets in storage.

Task<IReadOnlySet<ArkWalletInfo>> LoadAllWallets(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<IReadOnlySet<ArkWalletInfo>>

LoadWallet(string, CancellationToken)

Loads a wallet by ID or public-key fingerprint. Throws if not found.

Task<ArkWalletInfo> LoadWallet(string walletIdentifierOrFingerprint, CancellationToken ct = default)

Parameters

walletIdentifierOrFingerprint string
ct CancellationToken

Returns

Task<ArkWalletInfo>

SaveWallet(ArkWalletInfo, CancellationToken)

Creates or replaces a wallet record.

Task SaveWallet(ArkWalletInfo wallet, CancellationToken ct = default)

Parameters

wallet ArkWalletInfo
ct CancellationToken

Returns

Task

SetMetadataValue(string, string, string?, CancellationToken)

Sparse-update one key in the wallet's Metadata JSON store. Pass value: null to remove the key. Concurrent calls targeting different keys are safe — the implementation must not clobber keys it didn't touch.

Task SetMetadataValue(string walletId, string key, string? value, CancellationToken ct = default)

Parameters

walletId string
key string
value string
ct CancellationToken

Returns

Task

Remarks

Designed for per-wallet bookkeeping the SDK accumulates over time (sync cursors, recovery state, etc.) without requiring a schema migration per concern. Throws if the wallet doesn't exist.

UpdateDestination(string, string?, CancellationToken)

Updates the wallet's sweep destination address. Pass null to clear it.

Task UpdateDestination(string walletId, string? destination, CancellationToken ct = default)

Parameters

walletId string
destination string
ct CancellationToken

Returns

Task

UpdateLastUsedIndex(string, int, CancellationToken)

Updates the HD derivation high-water mark for the wallet.

Task UpdateLastUsedIndex(string walletId, int lastUsedIndex, CancellationToken ct = default)

Parameters

walletId string
lastUsedIndex int
ct CancellationToken

Returns

Task

UpsertWallet(ArkWalletInfo, bool, CancellationToken)

Inserts or optionally updates a wallet. Returns true when a new record was created.

Task<bool> UpsertWallet(ArkWalletInfo wallet, bool updateIfExists = true, CancellationToken ct = default)

Parameters

wallet ArkWalletInfo
updateIfExists bool
ct CancellationToken

Returns

Task<bool>

Events

WalletDeleted

Raised after a wallet is deleted, carrying the wallet ID.

event EventHandler<string>? WalletDeleted

Event Type

EventHandler<string>

WalletSaved

Raised after a wallet is created or updated.

event EventHandler<ArkWalletInfo>? WalletSaved

Event Type

EventHandler<ArkWalletInfo>