/// import type { Blockchain } from '../blockchain'; import { UnsignedTransaction } from '@ironfish/rust-nodejs'; import { Consensus } from '../consensus'; import { Event } from '../event'; import { Config } from '../fileStores'; import { Logger } from '../logger'; import { Witness } from '../merkletree/witness'; import { BlockHeader } from '../primitives'; import { BurnDescription } from '../primitives/burnDescription'; import { NoteEncrypted } from '../primitives/noteEncrypted'; import { MintData, RawTransaction } from '../primitives/rawTransaction'; import { Transaction } from '../primitives/transaction'; import { GetBlockRequest, GetBlockResponse, RpcClient } from '../rpc'; import { IDatabaseTransaction } from '../storage/database/transaction'; import { SetTimeoutToken } from '../utils'; import { WorkerPool } from '../workerPool'; import { DecryptedNote } from '../workerPool/tasks/decryptNotes'; import { Account } from './account/account'; import { EncryptedAccount } from './account/encryptedAccount'; import { AccountImport } from './exporter/accountImport'; import { MintAssetOptions } from './interfaces/mintAssetOptions'; import { ScanState } from './scanner/scanState'; import { WalletScanner } from './scanner/walletScanner'; import { AssetValue } from './walletdb/assetValue'; import { DecryptedNoteValue } from './walletdb/decryptedNoteValue'; import { HeadValue } from './walletdb/headValue'; import { TransactionValue } from './walletdb/transactionValue'; import { WalletDB } from './walletdb/walletdb'; export declare enum AssetStatus { CONFIRMED = "confirmed", PENDING = "pending", UNCONFIRMED = "unconfirmed", UNKNOWN = "unknown" } export declare enum TransactionStatus { CONFIRMED = "confirmed", EXPIRED = "expired", PENDING = "pending", UNCONFIRMED = "unconfirmed", UNKNOWN = "unknown" } export declare enum TransactionType { SEND = "send", RECEIVE = "receive", MINER = "miner" } export type TransactionOutput = { publicAddress: string; amount: bigint; memo: Buffer; assetId: Buffer; }; export declare const DEFAULT_UNLOCK_TIMEOUT_MS: number; export declare class Wallet { readonly onAccountImported: Event<[account: Account]>; readonly onAccountRemoved: Event<[account: Account]>; readonly accountById: Map; readonly encryptedAccountById: Map; readonly walletDb: WalletDB; private readonly logger; readonly workerPool: WorkerPool; readonly scanner: WalletScanner; readonly nodeClient: RpcClient | null; private readonly config; private readonly consensus; readonly networkId: number; private masterKey; protected rebroadcastAfter: number; protected defaultAccount: string | null; protected isStarted: boolean; protected isOpen: boolean; protected isSyncingTransactionGossip: boolean; locked: boolean; protected eventLoopTimeout: SetTimeoutToken | null; protected lockTimeout: SetTimeoutToken | null; private readonly createTransactionMutex; private readonly eventLoopAbortController; private eventLoopPromise; constructor({ config, database, logger, rebroadcastAfter, workerPool, consensus, networkId, nodeClient, chain, }: { config: Config; database: WalletDB; logger?: Logger; rebroadcastAfter?: number; workerPool: WorkerPool; consensus: Consensus; networkId: number; nodeClient: RpcClient | null; chain: Blockchain | null; }); /** * This starts a scan and returns when the scan has started and does not wait * for it to complete. */ scan({ force, wait, }?: { force?: boolean; wait?: boolean; }): Promise; open(): Promise; private load; private unload; close(): Promise; start(): void; stop(): Promise; eventLoop(): Promise; syncTransactionGossip(): Promise; reset(options?: { resetCreatedAt?: boolean; resetScanningEnabled?: boolean; passphrase?: string; }, tx?: IDatabaseTransaction): Promise; resetAccounts(options?: { resetCreatedAt?: boolean; resetScanningEnabled?: boolean; passphrase?: string; }, tx?: IDatabaseTransaction): Promise; decryptNotes(transaction: Transaction, initialNoteIndex: number | null, decryptForSpender: boolean, accounts: ReadonlyArray): Promise>>; private decryptNotesFromTransaction; connectBlockForAccount(account: Account, blockHeader: BlockHeader, transactions: { transaction: Transaction; decryptedNotes: DecryptedNote[]; }[], shouldDecrypt: boolean): Promise; private connectBlockTransactions; private upsertAssetsFromDecryptedNotes; /** * Ensures that the wallet db contains information about the assets involved * in the given notes and mints. * * This method checks that each asset is in the wallet db and, if it cannot * be found, then the information is copied from the chain db into the wallet * db. */ private backfillAssets; private getOrBackfillAsset; disconnectBlockForAccount(account: Account, header: BlockHeader, transactions: Transaction[]): Promise; addPendingTransaction(transaction: Transaction): Promise; getBalances(account: Account, confirmations?: number): AsyncGenerator<{ assetId: Buffer; unconfirmed: bigint; unconfirmedCount: number; pending: bigint; pendingCount: number; confirmed: bigint; available: bigint; availableNoteCount: number; blockHash: Buffer | null; sequence: number | null; }>; getBalance(account: Account, assetId: Buffer, options?: { confirmations?: number; }): Promise<{ unconfirmedCount: number; unconfirmed: bigint; confirmed: bigint; pendingCount: number; pending: bigint; available: bigint; availableNoteCount: number; blockHash: Buffer | null; sequence: number | null; }>; send(options: { account: Account; outputs: TransactionOutput[]; fee?: bigint; feeRate?: bigint; expirationDelta?: number; expiration?: number; confirmations?: number; notes?: Buffer[]; }): Promise; mint(account: Account, options: MintAssetOptions): Promise; burn(account: Account, assetId: Buffer, value: bigint, expirationDelta: number, fee?: bigint, feeRate?: bigint, expiration?: number, confirmations?: number): Promise; createTransaction(options: { account: Account; notes?: Buffer[]; outputs?: TransactionOutput[]; mints?: MintData[]; burns?: BurnDescription[]; fee?: bigint; feeRate?: bigint; expiration?: number; expirationDelta?: number; confirmations?: number; }): Promise; build(options: { transaction: RawTransaction; account: Account; }): Promise<{ transaction: UnsignedTransaction; }>; post(options: { transaction: RawTransaction; spendingKey?: string; account?: Account; broadcast?: boolean; }): Promise<{ transaction: Transaction; accepted?: boolean; broadcasted?: boolean; }>; fund(raw: RawTransaction, options: { account: Account; notes?: Buffer[]; confirmations: number; }): Promise; getNoteWitness(note: DecryptedNoteValue, confirmations?: number): Promise>; private buildAmountsNeeded; broadcastTransaction(transaction: Transaction): Promise<{ accepted: boolean; broadcasted: boolean; }>; rebroadcastTransactions(sequence: number): Promise; expireTransactions(sequence: number): Promise; /** * Delete a transaction from all accounts in the wallet if it has not yet been * added to a block */ deleteTransaction(hash: Buffer, tx?: IDatabaseTransaction): Promise; getTransactionStatus(account: Account, transaction: TransactionValue, options?: { headSequence?: number | null; confirmations?: number; }, tx?: IDatabaseTransaction): Promise; /** * Note: This logic will be deprecated when we move the field `status` from the Asset response object. The status field has * more to do with the transaction than the asset itself. * * The getTransactionStatus field above is more relevant. * * @param account Account * @param assetValue AssetValue * @param options: { headSequence?: number | null; confirmations?: number} * @returns Promise */ getAssetStatus(account: Account, assetValue: AssetValue, options?: { headSequence?: number | null; confirmations?: number; }): Promise; getTransactionType(account: Account, transaction: TransactionValue, tx?: IDatabaseTransaction): Promise; createAccount(name: string, options?: { setDefault?: boolean; createdAt?: number | null; head?: HeadValue | null; }): Promise; private createdAtWithDefault; accountHeadAtSequence(sequence: number): Promise; skipRescan(account: Account, tx?: IDatabaseTransaction): Promise; importAccount(accountValue: AccountImport, options?: { createdAt?: number; }): Promise; setName(account: Account, name: string, tx?: IDatabaseTransaction): Promise; setScanningEnabled(account: Account, enabled: boolean, tx?: IDatabaseTransaction): Promise; get accounts(): Account[]; get encryptedAccounts(): EncryptedAccount[]; accountExists(name: string): boolean; resetAccount(account: Account, options?: { resetCreatedAt?: boolean; resetScanningEnabled?: boolean; }, tx?: IDatabaseTransaction): Promise; removeAccountByName(name: string): Promise; removeAccount(account: Account, tx?: IDatabaseTransaction): Promise; forceCleanupDeletedAccounts(): Promise; cleanupDeletedAccounts(): Promise; get hasDefaultAccount(): boolean; /** Set or clear the default account */ setDefaultAccount(name: string | null, tx?: IDatabaseTransaction): Promise; findAccount(predicate: (account: Account) => boolean): Account | null; getAccountByName(name: string): Account | null; getAccount(id: string): Account | null; getDefaultAccount(): Account | null; getEarliestHead(tx?: IDatabaseTransaction): Promise; getLatestHead(tx?: IDatabaseTransaction): Promise; isAccountUpToDate(account: Account, confirmations?: number): Promise; protected assertHasAccount(account: Account): void; protected assertNotHasAccount(account: Account): void; chainHasBlock(hash: Buffer): Promise; chainGetBlock(request: GetBlockRequest): Promise; private getChainAsset; getChainGenesis(): Promise; getChainHead(): Promise; createMultisigSecret(name: string): Promise; accountsEncrypted(): Promise; encrypt(passphrase: string, tx?: IDatabaseTransaction): Promise; decrypt(passphrase: string, tx?: IDatabaseTransaction): Promise; lock(tx?: IDatabaseTransaction): Promise; unlock(passphrase: string, timeout?: number, tx?: IDatabaseTransaction): Promise; private startUnlockTimeout; private stopUnlockTimeout; } //# sourceMappingURL=wallet.d.ts.map