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, Validation, WalletLoggerInterface, MakeWalletLogger } 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'; /** * 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. The result shape matches what `discoverByIdentityKey` / * `discoverByAttributes` return so callers don't have to special-case contact-sourced records. * * 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 minimal trusted * `DiscoverCertificatesResult` without touching the overlay. */ 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 certifier metadata; missing trust defaults to `Infinity` (contacts override overlay trust). */ 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 contact source consulted before the overlay in `discoverByIdentityKey` / * `discoverByAttributes`. When a contact matches, the overlay call is skipped entirely. * 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; } 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; /** * 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; 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?; /** 2-minute cache of queryOverlay() results keyed by normalized query */ private readonly _overlayCache; discoverByIdentityKey(args: DiscoverByIdentityKeyArgs & { forceRefresh?: boolean; }, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; discoverByAttributes(args: DiscoverByAttributesArgs & { forceRefresh?: boolean; }, originator?: OriginatorDomainNameStringUnder250Bytes): Promise; verifyReturnedTxidOnly(beef: Beef, knownTxids?: string[]): Beef; verifyReturnedTxidOnlyAtomicBEEF(beef: AtomicBEEF, knownTxids?: string[]): 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. * * @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 the outputs that fail to verify. * * 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, sets outputs that fail to verify to un-spendable (spendable: false) * @param optionalArgs Optional. Additional tags will constrain the outputs processed. * @returns outputs which are/where considered spendable but currently fail to verify as spendable. */ 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: Validation.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