import { type ValidCreateActionArgs } from '@bsv/sdk/wallet/validationHelpers'; import { AbortActionArgs, AbortActionResult, AcquireCertificateArgs, AcquireCertificateResult, AuthenticatedResult, Beef, BeefParty, CreateActionArgs, CreateActionResult, CreateHmacArgs, CreateHmacResult, CreateSignatureArgs, CreateSignatureResult, DiscoverByAttributesArgs, DiscoverByIdentityKeyArgs, DiscoverCertificatesResult, GetHeaderArgs, GetHeaderResult, GetHeightResult, GetNetworkResult, GetPublicKeyArgs, GetPublicKeyResult, GetVersionResult, InternalizeActionArgs, InternalizeActionResult, ListActionsArgs, ListActionsResult, ListCertificatesArgs, ListCertificatesResult, ListOutputsArgs, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes, ProtoWallet, ProveCertificateArgs, ProveCertificateResult, PubKeyHex, RelinquishCertificateArgs, RelinquishCertificateResult, RelinquishOutputArgs, RelinquishOutputResult, RevealCounterpartyKeyLinkageArgs, RevealCounterpartyKeyLinkageResult, RevealSpecificKeyLinkageArgs, RevealSpecificKeyLinkageResult, SignActionArgs, SignActionResult, Transaction as BsvTransaction, TrustSelf, VerifyHmacArgs, VerifyHmacResult, VerifySignatureArgs, VerifySignatureResult, WalletDecryptArgs, WalletDecryptResult, WalletEncryptArgs, WalletEncryptResult, WalletInterface, LookupResolver, AtomicBEEF, BEEF, KeyDeriverApi, WalletLoggerInterface, MakeWalletLogger, Telemetry, TelemetryConfig } from '@bsv/sdk'; import type { SpendVerifierInterface } from '@bsv/sdk'; import { WalletSettingsManager } from './WalletSettingsManager'; import { WalletStorageManager } from './storage/WalletStorageManager'; import { Monitor } from './monitor/Monitor'; import { WalletSigner } from './signer/WalletSigner'; import { Chain, KeyPair, StorageIdentity, WalletBalance } from './sdk/types'; import { WalletServices } from './sdk/WalletServices.interfaces'; import { PrivilegedKeyManager } from './sdk/PrivilegedKeyManager'; import { StorageCreateActionResult } from './sdk/WalletStorage.interfaces'; import { ActionBatchController, ActionBatchMode } from './signer/actionBatch/ActionBatchWorkspace'; /** * The preferred means of constructing a `Wallet` is with a `WalletArgs` instance. */ /** * Minimal interface the wallet uses to short-circuit identity discovery against the user's local * contacts before hitting the overlay. Installing a source is an explicit local trust-policy * decision: its records are authoritative personal assertions, like a self-signed certificate or * locally installed trust anchor. The authority is scoped to this user's saved identity-key * association and local metadata; it is not an independent third-party certifier attestation or * a transferable trust statement for another wallet. * * The result shape matches what `discoverByIdentityKey` / `discoverByAttributes` return so callers * do not have to special-case contact-sourced records. Contact results are identifiable by their * default `contact` type and empty certificate proof fields. Do not wire network responses or other * unauthenticated third-party data directly into this interface. Authenticating the local store * proves who saved the record, while the prior user/application validation supplies its identity * authority. * * Implementations typically wrap `@bsv/sdk` `ContactsManager` or another on-device source. Reads * are expected to be very fast (single-digit ms against local SQLite is typical). */ export interface ContactSource { /** Look up a contact by identity key. Return `null` (or undefined) if unknown. */ findByIdentityKey: (identityKey: PubKeyHex) => Promise; /** Look up contacts matching a set of attributes. May be a no-op if attribute search is unsupported. */ findByAttributes?: (attributes: Record | string[]) => Promise; } /** * What a {@link ContactSource} returns. Carries enough to synthesize a locally authoritative * `DiscoverCertificatesResult` without touching the overlay. The authority comes from the user's * independent decision to save or validate the contact, not from a third-party certificate. * Consumers must preserve that distinction when rendering or exporting the result. */ export interface ContactRecord { identityKey: PubKeyHex; /** Optional certificate type (e.g. xCert / discordCert) so callers can render a badge. */ type?: string; /** Optional decrypted fields. Whatever the app stored when saving the contact. */ decryptedFields?: Record; /** * Optional local trust metadata. Missing trust defaults to `Infinity`, meaning the user's contact * assertion overrides third-party overlay thresholds by explicit local policy. It does not mean * that an external certifier supplied or cryptographically verified the record. Infinity is * scoped to the local policy decision; it must not be serialized as a universal trust claim. */ certifierInfo?: { name?: string; iconUrl?: string; description?: string; trust?: number; }; } export interface WalletArgs { chain: Chain; keyDeriver: KeyDeriverApi; storage: WalletStorageManager; services?: WalletServices; monitor?: Monitor; privilegedKeyManager?: PrivilegedKeyManager; settingsManager?: WalletSettingsManager; lookupResolver?: LookupResolver; /** * Optional caller-installed, local contact source consulted before the overlay in * `discoverByIdentityKey` / `discoverByAttributes`. A match is a user-authoritative personal * assertion, not an external certifier attestation, and skips the overlay entirely. Only connect * a locally authenticated/contact-management source whose records the user has independently * chosen to trust. A contact-store signature or encryption authenticates local persistence; it * does not replace that independent validation step. * Pass `forceRefresh: true` on the discover args to bypass both contacts and the overlay * cache. */ contactSource?: ContactSource; /** * Optional. Provide a function conforming to the `MakeWalletLogger` type to enable wallet request logging. * * For simple requests using `Console` may be adequate, initialize with * `() => Console` * * Aggregate tracing and control over capturing all logged output in one place: * `(log?: string | WalletLoggerInterface) => new WalletLogger(log)` */ makeLogger?: MakeWalletLogger; /** * Internal Wallet Toolbox optimization policy. `auto` (the default) * negotiates the optional action-batch storage capability; `legacy` always * uses per-action storage. This does not change the BRC-100 wallet interface. */ actionBatchMode?: ActionBatchMode; /** * Optional high-performance script verifier used by Wallet Toolbox's * internal transaction checks. This is an implementation extension and does * not change the BRC-100 wallet interface. */ scriptVerifier?: SpendVerifierInterface; /** * Optional provider-neutral tracing shared by wallet, lookup, storage, and * permission layers. Disabled unless an enabled sink is supplied. */ telemetry?: TelemetryConfig; } export declare class Wallet implements WalletInterface, ProtoWallet { chain: Chain; keyDeriver: KeyDeriverApi; storage: WalletStorageManager; settingsManager: WalletSettingsManager; lookupResolver: LookupResolver; services?: WalletServices; monitor?: Monitor; contactSource?: ContactSource; identityKey: string; /** * The wallet creates a `BeefParty` when it is created. * All the Beefs that pass through the wallet are merged into this beef. * Thus what it contains at any time is the union of all transactions and proof data processed. * The class `BeefParty` derives from `Beef`, adding the ability to track the source of merged data. * * This allows it to generate beefs to send to a particular “party” (storage or the user) * that includes “txid only proofs” for transactions they already know about. * Over time, this allows an active wallet to drastically reduce the amount of data transmitted. */ beef: BeefParty; /** * If true, signableTransactions will include sourceTransaction for each input, * including those that do not require signature and those that were also contained * in the inputBEEF. */ includeAllSourceTransactions: boolean; /** * If true, txids that are known to the wallet's party beef do not need to be returned from storage. */ autoKnownTxids: boolean; /** * If true, beefs returned to the user may contain txidOnly transactions. */ returnTxidOnly: boolean; trustSelf?: TrustSelf; userParty: string; proto: ProtoWallet; privilegedKeyManager?: PrivilegedKeyManager; makeLogger?: MakeWalletLogger; pendingSignActions: Record; readonly actionBatch: ActionBatchController; readonly scriptVerifier?: SpendVerifierInterface; readonly telemetry: Telemetry; /** * For repeatability testing, set to an array of random numbers from [0..1). */ randomVals?: number[]; constructor(argsOrSigner: WalletArgs | WalletSigner, services?: WalletServices, monitor?: Monitor, privilegedKeyManager?: PrivilegedKeyManager, makeLogger?: MakeWalletLogger); destroy(): Promise; getClientChangeKeyPair(): KeyPair; getIdentityKey(): Promise; getPublicKey(args: GetPublicKeyArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; revealCounterpartyKeyLinkage(args: RevealCounterpartyKeyLinkageArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; revealSpecificKeyLinkage(args: RevealSpecificKeyLinkageArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; encrypt(args: WalletEncryptArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; decrypt(args: WalletDecryptArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; createHmac(args: CreateHmacArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; verifyHmac(args: VerifyHmacArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; createSignature(args: CreateSignatureArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; verifySignature(args: VerifySignatureArgs, _originator?: OriginatorDomainNameStringUnder250Bytes): Promise; getServices(): WalletServices; /** * @returns the full list of txids whose validity this wallet claims to know. * * @param newKnownTxids Optional. Additional new txids known to be valid by the caller to be merged. */ getKnownTxids(newKnownTxids?: string[]): string[]; getStorageIdentity(): StorageIdentity; private validateAuthAndArgs; listActions(args: ListActionsArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; get storageParty(): string; listOutputs(args: ListOutputsArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; listCertificates(args: ListCertificatesArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; private acquireDirectCertificateProtocol; private validateIssuedCertificateFields; private validateIssuedCertificate; private acquireIssuedCertificateProtocol; acquireCertificate(args: AcquireCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; relinquishCertificate(args: RelinquishCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; proveCertificate(args: ProveCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; /** 2-minute cache of trust settings for identity resolution paths */ private _trustSettingsCache?; /** Bounded two-minute untrusted receipts. Every use rechecks canonical evidence. */ private readonly _overlayEvidenceCache; private _overlayEvidenceExpiryTimer?; private _identityEvidenceVerifier?; private _identityEvidenceClosed; private pruneOverlayEvidence; private scheduleOverlayEvidenceExpiry; private requireOverlayChainTracker; private discoverOverlayCertificates; /** * Resolves an identity from a caller-installed local contact source first, then the certificate * overlay. A local hit expresses the user's own authoritative trust decision and carries empty * third-party certificate proof fields; use `forceRefresh` to bypass it and query the overlay. */ discoverByIdentityKey(args: DiscoverByIdentityKeyArgs & { forceRefresh?: boolean; }, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; /** * Resolves matching identities from a caller-installed local contact source first, then the * certificate overlay. Local hits are authoritative personal assertions with empty third-party * certificate proof fields; use `forceRefresh` to bypass them and query the overlay. */ discoverByAttributes(args: DiscoverByAttributesArgs & { forceRefresh?: boolean; }, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; verifyReturnedTxidOnly(beef: Beef, knownTxids?: string[]): Beef; verifyReturnedTxidOnlyAtomicBEEF(beef: AtomicBEEF, knownTxids?: string[], parsedBeef?: Beef): AtomicBEEF; verifyReturnedTxidOnlyBEEF(beef: BEEF): BEEF; logMakeLogger(method: string, args: any): WalletLoggerInterface | undefined; logMethodStart(method: string, logger?: WalletLoggerInterface): void; logResult(r: any, logger?: WalletLoggerInterface): void; logWalletError(eu: unknown, logger?: WalletLoggerInterface): void; createAction(args: CreateActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; signAction(args: SignActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; internalizeAction(args: InternalizeActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; abortAction(args: AbortActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; relinquishOutput(args: RelinquishOutputArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; isAuthenticated(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; waitForAuthentication(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; getHeight(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; getHeaderForHeight(args: GetHeaderArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; getNetwork(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; getVersion(args: {}, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; /** * Transfer all possible satoshis held by this wallet to `toWallet`. * * @param toWallet wallet which will receive this wallet's satoshis. */ sweepTo(toWallet: Wallet): Promise; /** * Uses `listOutputs` to iterate over chunks of up to 1000 outputs to * compute the sum of output satoshis. * * For `default`, only wallet-managed BRC-29 change is included. Raw * administrative `listOutputs({ basket: 'default' })` remains available to * discover legacy incompatible rows for recovery. * * @param {string} basket - Optional. Defaults to 'default', the wallet change basket. * @returns {WalletBalance} total sum of output satoshis and utxo details (satoshis and outpoints) */ balanceAndUtxos(basket?: string): Promise; /** * Uses `listOutputs` special operation to compute the total value (of satoshis) for * all spendable outputs in the 'default' basket. * * @returns {number} sum of output satoshis */ balance(args?: ListOutputsArgs): Promise; /** * Uses `listOutputs` special operation to review the spendability via `Services` of * outputs currently considered spendable. Returns only outputs conclusively * confirmed spent. Rejects the review if any provider result is inconclusive. * * Ignores the `limit` and `offset` properties. * * @param all Defaults to false. If false, only change outputs ('default' basket) are reviewed. If true, all spendable outputs are reviewed. * @param release Defaults to false. If true, atomically sets conclusively spent outputs to un-spendable (spendable: false). No outputs change if any candidate is inconclusive. * @param optionalArgs Optional. Additional tags will constrain the outputs processed. * @returns outputs previously considered spendable but conclusively confirmed spent. */ reviewSpendableOutputs(all?: boolean, release?: boolean, optionalArgs?: Partial): Promise; /** * Uses `listOutputs` special operation to update the 'default' basket's automatic * change generation parameters. * * @param count target number of change UTXOs to maintain. * @param satoshis target value for new change outputs. */ setWalletChangeParams(count: number, satoshis: number): Promise; /** * Uses `listActions` special operation to return only actions with status 'nosend'. * * @param abort Defaults to false. If true, runs `abortAction` on each 'nosend' action. * @returns {ListActionsResult} start `listActions` result restricted to 'nosend' (or 'failed' if aborted) actions. */ listNoSendActions(args: ListActionsArgs, abort?: boolean): Promise; /** * Uses `listActions` special operation to return only actions with status 'failed'. * * @param unfail Defaults to false. If true, queues the action for attempted recovery. * @returns {ListActionsResult} start `listActions` result restricted to 'failed' status actions. */ listFailedActions(args: ListActionsArgs, unfail?: boolean): Promise; } export interface PendingStorageInput { vin: number; derivationPrefix: string; derivationSuffix: string; unlockerPubKey?: string; sourceSatoshis: number; lockingScript: string; } export interface PendingSignAction { reference: string; dcr: StorageCreateActionResult; args: ValidCreateActionArgs; tx: BsvTransaction; amount: number; pdi: PendingStorageInput[]; } /** * Throws a WERR_REVIEW_ACTIONS with a full set of properties to test data formats and propagation. */ export declare function throwDummyReviewActions(): void; //# sourceMappingURL=Wallet.d.ts.map