import { ICryptoProvider } from "../crypto/ICryptoProvider"; import { DataProvider } from "../dataProvider"; import { TxAux } from "../ledger/transaction"; import { Address, Lovelace, TokenBundle, UTxO } from "../types"; import { Address as HexAddress, DataSignature, HexString } from '../dappConnector'; import { AddressWithMeta } from './addressesInfo'; export type AccountInfo = { accountIndex: number; isUsed: boolean; usedAddresses: AddressWithMeta[]; unusedAddresses: AddressWithMeta[]; addresses: { baseExternal: AddressWithMeta[]; enterpriseExternal: AddressWithMeta[]; baseInternal: AddressWithMeta[]; enterpriseInternal: AddressWithMeta[]; }; stakingAddress: Address; }; /** * Account is derived by the derivation path `m/1852'/1815'/accountIndex'` * * Each account provides information about its addresses (base, enterprise and * staking) and whether they are used or not. Based on these addresses it can * query available account UTxOs and from them derive the total balance of the account. * * On demand it can also report staking information - available rewards, current delegation. * * Another responsibility is the ability to witness transactions, with the * private keys belonging to one of its addresses. * * The source of UTxOs, used addresses and staking info is cab-backend. * * By default Account is loaded once on initialization, and to get new data * it needs to be explicitly reloaded by calling the appropriate methods: * - `reloadAccountInfo()` - reloads the accountInfo, also rediscovering used addresses * - `reloadUTxOs()` - reloads available UTxOs on used addresses * - `reloadStakingInfo()` - reloads the stakingInfo * * ⚠️ Public getters ensure that the account is loaded before returning any * data, and throw an exception otherwise. */ export declare class Account { accountIndex: number; private cryptoProvider; private dataProvider; private addressManager; protected accountInfo: AccountInfo | null; protected utxos: UTxO[] | null; constructor({ cryptoProvider, dataProvider, accountIndex, gapLimit, stakeKeyHashesToDerive, }: { cryptoProvider: ICryptoProvider; dataProvider: DataProvider; accountIndex: number; /** * Gap limit signalizes that after how many unused addresses to stop * looking for used ones when doing address exploration */ gapLimit: number; stakeKeyHashesToDerive: number; }); private assertAccountInfoLoaded; private assertUTxOsLoaded; /** * Fetches account info for this account which includes, deriving addresses * associated with this account and checking whether they are in use or not */ private fetchAccountInfo; reloadAccountInfo(): Promise; /** * Fetches UTxOs on all base and enterprise addresses of the account, * calling this method requires the account info to be already loaded */ private fetchUTxOs; reloadUtxos(): Promise; reload(): Promise; /** * Ensure that we can derive the first address to ensure that public key * was exported. Important for compatibility with hardware wallets */ private ensureXpubIsExported; /** * Loads the account, this first loads the account info and after loads * available UTxOs on all the base and enterprise addresses of the account */ load(): Promise; /** * Gets the first base external address. E.g. the one derived by derivation * path `m/1852'/1815'/accountIndex'/0/0`. */ getFirstVisibleAddress(): Address; /** * Gets the change address for the account. CAB by default defines the change * address as the first base external address. * * @see getFirstVisibleAddress */ getChangeAddress(): Address; /** * Get the staking address for this account, derived by the derivation path * `m/1852'/1815'/accountIndex'/2/0` */ getStakingAddress(): Address; deriveStakingAddress(index: number): Promise
; deriveStakingAddresses(beginIndex: number, endIndex: number): Promise; getUtxos(): UTxO[]; getCollateralUtxos(minCollateralAmount?: number): UTxO[]; getAccountInfo(): AccountInfo; /** * Gets the current Lovelace and token balance of the account, by aggregating * all the available UTxOs. * With large Accounts this can be a heavy operation, so by default it's * cached until the UTxOs are not reloaded. */ getBalance(): { coins: Lovelace; tokenBundle: TokenBundle; }; signTxAux(txAux: TxAux): Promise; witnessTxAux(txAux: TxAux): Promise; signData(address: HexAddress, data: HexString): Promise; } //# sourceMappingURL=Account.d.ts.map