UNPKG

@bsv/wallet-toolbox

Version:

BRC100 conforming wallet, wallet storage and wallet signer components

1,520 lines (1,072 loc) 707 kB
# CLIENT: BSV Wallet Toolbox API Documentation The documentation is split into various pages, this page is the API of the `@bsv/wallet-toolbox-client` package; which is the subset of the `@bsv/wallet-toolbox` that is compatible with browser deployment contexts. [Return To Top](./README.md) <!--#region ts2md-api-merged-here--> ### API Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) #### Interfaces | | | | | --- | --- | --- | | [AdminStatsResult](#interface-adminstatsresult) | [GetReqsAndBeefDetail](#interface-getreqsandbeefdetail) | [SyncChunk](#interface-syncchunk) | | [ArcConfig](#interface-arcconfig) | [GetReqsAndBeefResult](#interface-getreqsandbeefresult) | [SyncError](#interface-syncerror) | | [ArcMinerGetTxData](#interface-arcminergettxdata) | [GetScriptHashHistory](#interface-getscripthashhistory) | [SyncMap](#interface-syncmap) | | [AuthId](#interface-authid) | [GetScriptHashHistoryResult](#interface-getscripthashhistoryresult) | [TableCertificate](#interface-tablecertificate) | | [AuthPayload](#interface-authpayload) | [GetStatusForTxidsResult](#interface-getstatusfortxidsresult) | [TableCertificateField](#interface-tablecertificatefield) | | [BaseBlockHeader](#interface-baseblockheader) | [GetUtxoStatusDetails](#interface-getutxostatusdetails) | [TableCertificateX](#interface-tablecertificatex) | | [BitailsConfig](#interface-bitailsconfig) | [GetUtxoStatusResult](#interface-getutxostatusresult) | [TableCommission](#interface-tablecommission) | | [BitailsMerkleProof](#interface-bitailsmerkleproof) | [GroupedPermissionRequest](#interface-groupedpermissionrequest) | [TableMonitorEvent](#interface-tablemonitorevent) | | [BlockHeader](#interface-blockheader) | [GroupedPermissions](#interface-groupedpermissions) | [TableOutput](#interface-tableoutput) | | [BsvExchangeRate](#interface-bsvexchangerate) | [HeightRangeApi](#interface-heightrangeapi) | [TableOutputBasket](#interface-tableoutputbasket) | | [BulkFileDataManagerMergeResult](#interface-bulkfiledatamanagermergeresult) | [HeightRanges](#interface-heightranges) | [TableOutputTag](#interface-tableoutputtag) | | [BulkFileDataManagerOptions](#interface-bulkfiledatamanageroptions) | [KeyPair](#interface-keypair) | [TableOutputTagMap](#interface-tableoutputtagmap) | | [BulkHeaderFileInfo](#interface-bulkheaderfileinfo) | [KeyPairAddress](#interface-keypairaddress) | [TableOutputX](#interface-tableoutputx) | | [BulkHeaderFilesInfo](#interface-bulkheaderfilesinfo) | [ListActionsSpecOp](#interface-listactionsspecop) | [TableProvenTx](#interface-tableproventx) | | [BulkIngestorApi](#interface-bulkingestorapi) | [ListOutputsSpecOp](#interface-listoutputsspecop) | [TableProvenTxReq](#interface-tableproventxreq) | | [BulkIngestorBaseOptions](#interface-bulkingestorbaseoptions) | [LiveBlockHeader](#interface-liveblockheader) | [TableProvenTxReqDynamics](#interface-tableproventxreqdynamics) | | [BulkIngestorCDNOptions](#interface-bulkingestorcdnoptions) | [LiveIngestorApi](#interface-liveingestorapi) | [TableSettings](#interface-tablesettings) | | [BulkIngestorWhatsOnChainOptions](#interface-bulkingestorwhatsonchainoptions) | [LiveIngestorBaseOptions](#interface-liveingestorbaseoptions) | [TableSyncState](#interface-tablesyncstate) | | [BulkStorageApi](#interface-bulkstorageapi) | [LiveIngestorWhatsOnChainOptions](#interface-liveingestorwhatsonchainoptions) | [TableTransaction](#interface-tabletransaction) | | [BulkStorageBaseOptions](#interface-bulkstoragebaseoptions) | [MonitorOptions](#interface-monitoroptions) | [TableTxLabel](#interface-tabletxlabel) | | [BulkSyncResult](#interface-bulksyncresult) | [OutPoint](#interface-outpoint) | [TableTxLabelMap](#interface-tabletxlabelmap) | | [CertOpsWallet](#interface-certopswallet) | [Paged](#interface-paged) | [TableUser](#interface-tableuser) | | [Certifier](#interface-certifier) | [PendingSignAction](#interface-pendingsignaction) | [TaskPurgeParams](#interface-taskpurgeparams) | | [ChaintracksApi](#interface-chaintracksapi) | [PendingStorageInput](#interface-pendingstorageinput) | [TrustSettings](#interface-trustsettings) | | [ChaintracksAppendableFileApi](#interface-chaintracksappendablefileapi) | [PermissionRequest](#interface-permissionrequest) | [TrxToken](#interface-trxtoken) | | [ChaintracksChainTrackerOptions](#interface-chaintrackschaintrackeroptions) | [PermissionToken](#interface-permissiontoken) | [TscMerkleProofApi](#interface-tscmerkleproofapi) | | [ChaintracksClientApi](#interface-chaintracksclientapi) | [PermissionsManagerConfig](#interface-permissionsmanagerconfig) | [TxScriptOffsets](#interface-txscriptoffsets) | | [ChaintracksFetchApi](#interface-chaintracksfetchapi) | [PostBeefResult](#interface-postbeefresult) | [UMPToken](#interface-umptoken) | | [ChaintracksFsApi](#interface-chaintracksfsapi) | [PostBeefResultForTxidApi](#interface-postbeefresultfortxidapi) | [UMPTokenInteractor](#interface-umptokeninteractor) | | [ChaintracksInfoApi](#interface-chaintracksinfoapi) | [PostReqsToNetworkDetails](#interface-postreqstonetworkdetails) | [UpdateProvenTxReqWithNewProvenTxArgs](#interface-updateproventxreqwithnewproventxargs) | | [ChaintracksManagementApi](#interface-chaintracksmanagementapi) | [PostReqsToNetworkResult](#interface-postreqstonetworkresult) | [UpdateProvenTxReqWithNewProvenTxResult](#interface-updateproventxreqwithnewproventxresult) | | [ChaintracksOptions](#interface-chaintracksoptions) | [PostTxResultForTxid](#interface-posttxresultfortxid) | [ValidAbortActionArgs](#interface-validabortactionargs) | | [ChaintracksPackageInfoApi](#interface-chaintrackspackageinfoapi) | [PostTxResultForTxidError](#interface-posttxresultfortxiderror) | [ValidAcquireCertificateArgs](#interface-validacquirecertificateargs) | | [ChaintracksReadableFileApi](#interface-chaintracksreadablefileapi) | [PostTxsResult](#interface-posttxsresult) | [ValidAcquireDirectCertificateArgs](#interface-validacquiredirectcertificateargs) | | [ChaintracksServiceClientOptions](#interface-chaintracksserviceclientoptions) | [ProcessSyncChunkResult](#interface-processsyncchunkresult) | [ValidAcquireIssuanceCertificateArgs](#interface-validacquireissuancecertificateargs) | | [ChaintracksStorageApi](#interface-chaintracksstorageapi) | [Profile](#interface-profile) | [ValidBasketInsertion](#interface-validbasketinsertion) | | [ChaintracksStorageBaseOptions](#interface-chaintracksstoragebaseoptions) | [ProvenOrRawTx](#interface-provenorrawtx) | [ValidCreateActionArgs](#interface-validcreateactionargs) | | [ChaintracksStorageBulkFileApi](#interface-chaintracksstoragebulkfileapi) | [ProvenTransactionStatus](#interface-proventransactionstatus) | [ValidCreateActionInput](#interface-validcreateactioninput) | | [ChaintracksStorageIdbOptions](#interface-chaintracksstorageidboptions) | [ProvenTxFromTxidResult](#interface-proventxfromtxidresult) | [ValidCreateActionOptions](#interface-validcreateactionoptions) | | [ChaintracksStorageIdbSchema](#interface-chaintracksstorageidbschema) | [ProvenTxReqHistory](#interface-proventxreqhistory) | [ValidCreateActionOutput](#interface-validcreateactionoutput) | | [ChaintracksStorageIngestApi](#interface-chaintracksstorageingestapi) | [ProvenTxReqHistorySummaryApi](#interface-proventxreqhistorysummaryapi) | [ValidDiscoverByAttributesArgs](#interface-validdiscoverbyattributesargs) | | [ChaintracksStorageNoDbOptions](#interface-chaintracksstoragenodboptions) | [ProvenTxReqNotify](#interface-proventxreqnotify) | [ValidDiscoverByIdentityKeyArgs](#interface-validdiscoverbyidentitykeyargs) | | [ChaintracksStorageQueryApi](#interface-chaintracksstoragequeryapi) | [ProviderCallHistory](#interface-providercallhistory) | [ValidInternalizeActionArgs](#interface-validinternalizeactionargs) | | [ChaintracksWritableFileApi](#interface-chaintrackswritablefileapi) | [PurgeParams](#interface-purgeparams) | [ValidInternalizeOutput](#interface-validinternalizeoutput) | | [CommitNewTxResults](#interface-commitnewtxresults) | [PurgeResults](#interface-purgeresults) | [ValidListActionsArgs](#interface-validlistactionsargs) | | [CompleteAuthResponse](#interface-completeauthresponse) | [RequestSyncChunkArgs](#interface-requestsyncchunkargs) | [ValidListCertificatesArgs](#interface-validlistcertificatesargs) | | [CreateActionResultX](#interface-createactionresultx) | [ReviewActionResult](#interface-reviewactionresult) | [ValidListOutputsArgs](#interface-validlistoutputsargs) | | [EntitySyncMap](#interface-entitysyncmap) | [ScriptTemplateParamsBRC29](#interface-scripttemplateparamsbrc29) | [ValidProcessActionArgs](#interface-validprocessactionargs) | | [EntityTimeStamp](#interface-entitytimestamp) | [ScriptTemplateUnlock](#interface-scripttemplateunlock) | [ValidProcessActionOptions](#interface-validprocessactionoptions) | | [ExchangeRatesIoApi](#interface-exchangeratesioapi) | [ServiceCall](#interface-servicecall) | [ValidProveCertificateArgs](#interface-validprovecertificateargs) | | [ExtendedVerifiableCertificate](#interface-extendedverifiablecertificate) | [ServiceCall](#interface-servicecall) | [ValidRelinquishCertificateArgs](#interface-validrelinquishcertificateargs) | | [FiatExchangeRates](#interface-fiatexchangerates) | [ServiceCallHistory](#interface-servicecallhistory) | [ValidRelinquishOutputArgs](#interface-validrelinquishoutputargs) | | [FindCertificateFieldsArgs](#interface-findcertificatefieldsargs) | [ServiceCallHistoryCounts](#interface-servicecallhistorycounts) | [ValidSignActionArgs](#interface-validsignactionargs) | | [FindCertificatesArgs](#interface-findcertificatesargs) | [ServiceToCall](#interface-servicetocall) | [ValidSignActionOptions](#interface-validsignactionoptions) | | [FindCommissionsArgs](#interface-findcommissionsargs) | [SetupClientWalletArgs](#interface-setupclientwalletargs) | [ValidWalletPayment](#interface-validwalletpayment) | | [FindForUserSincePagedArgs](#interface-findforusersincepagedargs) | [SetupClientWalletClientArgs](#interface-setupclientwalletclientargs) | [ValidWalletSignerArgs](#interface-validwalletsignerargs) | | [FindMonitorEventsArgs](#interface-findmonitoreventsargs) | [SetupWallet](#interface-setupwallet) | [ValidateGenerateChangeSdkParamsResult](#interface-validategeneratechangesdkparamsresult) | | [FindOutputBasketsArgs](#interface-findoutputbasketsargs) | [SetupWalletClient](#interface-setupwalletclient) | [WalletArgs](#interface-walletargs) | | [FindOutputTagMapsArgs](#interface-findoutputtagmapsargs) | [SetupWalletIdb](#interface-setupwalletidb) | [WalletBalance](#interface-walletbalance) | | [FindOutputTagsArgs](#interface-findoutputtagsargs) | [SetupWalletIdbArgs](#interface-setupwalletidbargs) | [WalletPermissionsManagerCallbacks](#interface-walletpermissionsmanagercallbacks) | | [FindOutputsArgs](#interface-findoutputsargs) | [SignActionResultX](#interface-signactionresultx) | [WalletServices](#interface-walletservices) | | [FindPartialSincePagedArgs](#interface-findpartialsincepagedargs) | [StartAuthResponse](#interface-startauthresponse) | [WalletServicesOptions](#interface-walletservicesoptions) | | [FindProvenTxReqsArgs](#interface-findproventxreqsargs) | [StatusForTxidResult](#interface-statusfortxidresult) | [WalletSettings](#interface-walletsettings) | | [FindProvenTxsArgs](#interface-findproventxsargs) | [StorageAdminStats](#interface-storageadminstats) | [WalletSettingsManagerConfig](#interface-walletsettingsmanagerconfig) | | [FindSincePagedArgs](#interface-findsincepagedargs) | [StorageCreateActionResult](#interface-storagecreateactionresult) | [WalletSigner](#interface-walletsigner) | | [FindSyncStatesArgs](#interface-findsyncstatesargs) | [StorageCreateTransactionSdkInput](#interface-storagecreatetransactionsdkinput) | [WalletStorage](#interface-walletstorage) | | [FindTransactionsArgs](#interface-findtransactionsargs) | [StorageCreateTransactionSdkOutput](#interface-storagecreatetransactionsdkoutput) | [WalletStorageInfo](#interface-walletstorageinfo) | | [FindTxLabelMapsArgs](#interface-findtxlabelmapsargs) | [StorageFeeModel](#interface-storagefeemodel) | [WalletStorageProvider](#interface-walletstorageprovider) | | [FindTxLabelsArgs](#interface-findtxlabelsargs) | [StorageGetBeefOptions](#interface-storagegetbeefoptions) | [WalletStorageReader](#interface-walletstoragereader) | | [FindUsersArgs](#interface-findusersargs) | [StorageIdbOptions](#interface-storageidboptions) | [WalletStorageSync](#interface-walletstoragesync) | | [GenerateChangeSdkChangeInput](#interface-generatechangesdkchangeinput) | [StorageIdbSchema](#interface-storageidbschema) | [WalletStorageSyncReader](#interface-walletstoragesyncreader) | | [GenerateChangeSdkChangeOutput](#interface-generatechangesdkchangeoutput) | [StorageIdentity](#interface-storageidentity) | [WalletStorageWriter](#interface-walletstoragewriter) | | [GenerateChangeSdkInput](#interface-generatechangesdkinput) | [StorageInternalizeActionResult](#interface-storageinternalizeactionresult) | [WalletTheme](#interface-wallettheme) | | [GenerateChangeSdkOutput](#interface-generatechangesdkoutput) | [StorageProcessActionArgs](#interface-storageprocessactionargs) | [WhatsOnChainServicesOptions](#interface-whatsonchainservicesoptions) | | [GenerateChangeSdkParams](#interface-generatechangesdkparams) | [StorageProcessActionResults](#interface-storageprocessactionresults) | [WocChainInfo](#interface-wocchaininfo) | | [GenerateChangeSdkResult](#interface-generatechangesdkresult) | [StorageProvenOrReq](#interface-storageprovenorreq) | [WocGetHeaderByteFileLinks](#interface-wocgetheaderbytefilelinks) | | [GenerateChangeSdkStorageChange](#interface-generatechangesdkstoragechange) | [StorageProviderOptions](#interface-storageprovideroptions) | [WocGetHeadersHeader](#interface-wocgetheadersheader) | | [GetHeaderByteFileLinksResult](#interface-getheaderbytefilelinksresult) | [StorageReaderOptions](#interface-storagereaderoptions) | [WocHeader](#interface-wocheader) | | [GetMerklePathResult](#interface-getmerklepathresult) | [StorageReaderWriterOptions](#interface-storagereaderwriteroptions) | [XValidCreateActionOutput](#interface-xvalidcreateactionoutput) | | [GetRawTxResult](#interface-getrawtxresult) | [StorageSyncReaderOptions](#interface-storagesyncreaderoptions) | | Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: AdminStatsResult ```ts export interface AdminStatsResult extends StorageAdminStats { servicesStats?: ServicesCallHistory; monitorStats?: ServicesCallHistory; } ``` See also: [ServicesCallHistory](./client.md#type-servicescallhistory), [StorageAdminStats](./storage.md#interface-storageadminstats) Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ArcConfig Configuration options for the ARC broadcaster. ```ts export interface ArcConfig { apiKey?: string; httpClient?: HttpClient; deploymentId?: string; callbackUrl?: string; callbackToken?: string; headers?: Record<string, string>; } ``` ###### Property apiKey Authentication token for the ARC API ```ts apiKey?: string ``` ###### Property callbackToken default access token for notification callback endpoint. It will be used as a Authorization header for the http callback ```ts callbackToken?: string ``` ###### Property callbackUrl notification callback endpoint for proofs and double spend notification ```ts callbackUrl?: string ``` ###### Property deploymentId Deployment id used annotating api calls in XDeployment-ID header - this value will be randomly generated if not set ```ts deploymentId?: string ``` ###### Property headers additional headers to be attached to all tx submissions. ```ts headers?: Record<string, string> ``` ###### Property httpClient The HTTP client used to make requests to the ARC API. ```ts httpClient?: HttpClient ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ArcMinerGetTxData ```ts export interface ArcMinerGetTxData { status: number; title: string; blockHash: string; blockHeight: number; competingTxs: null | string[]; extraInfo: string; merklePath: string; timestamp: string; txid: string; txStatus: string; } ``` See also: [blockHash](./services.md#function-blockhash) Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: AuthId ```ts export interface AuthId { identityKey: string; userId?: number; isActive?: boolean; } ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: AuthPayload AuthMethodInteractor A base interface/class for client-side logic to interact with a server for a specific Auth Method's flow (start, complete). ```ts export interface AuthPayload { [key: string]: any; } ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BaseBlockHeader These are fields of 80 byte serialized header in order whose double sha256 hash is a block's hash value and the next block's previousHash value. All block hash values and merkleRoot values are 32 byte hex string values with the byte order reversed from the serialized byte order. ```ts export interface BaseBlockHeader { version: number; previousHash: string; merkleRoot: string; time: number; bits: number; nonce: number; } ``` ###### Property bits Block header bits value. Serialized length is 4 bytes. ```ts bits: number ``` ###### Property merkleRoot Root hash of the merkle tree of all transactions in this block. Serialized length is 32 bytes. ```ts merkleRoot: string ``` ###### Property nonce Block header nonce value. Serialized length is 4 bytes. ```ts nonce: number ``` ###### Property previousHash Hash of previous block's block header. Serialized length is 32 bytes. ```ts previousHash: string ``` ###### Property time Block header time value. Serialized length is 4 bytes. ```ts time: number ``` ###### Property version Block header version value. Serialized length is 4 bytes. ```ts version: number ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BitailsConfig ```ts export interface BitailsConfig { apiKey?: string; httpClient?: HttpClient; } ``` ###### Property apiKey Authentication token for BitTails API ```ts apiKey?: string ``` ###### Property httpClient The HTTP client used to make requests to the API. ```ts httpClient?: HttpClient ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BitailsMerkleProof ```ts export interface BitailsMerkleProof { index: number; txOrId: string; target: string; nodes: string[]; } ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BlockHeader A `BaseBlockHeader` extended with its computed hash and height in its chain. ```ts export interface BlockHeader extends BaseBlockHeader { height: number; hash: string; } ``` See also: [BaseBlockHeader](./client.md#interface-baseblockheader) ###### Property hash The double sha256 hash of the serialized `BaseBlockHeader` fields. ```ts hash: string ``` ###### Property height Height of the header, starting from zero. ```ts height: number ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BsvExchangeRate ```ts export interface BsvExchangeRate { timestamp: Date; base: "USD"; rate: number; } ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkFileDataManagerMergeResult ```ts export interface BulkFileDataManagerMergeResult { unchanged: BulkHeaderFileInfo[]; inserted: BulkHeaderFileInfo[]; updated: BulkHeaderFileInfo[]; dropped: BulkHeaderFileInfo[]; } ``` See also: [BulkHeaderFileInfo](./services.md#interface-bulkheaderfileinfo) Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkFileDataManagerOptions ```ts export interface BulkFileDataManagerOptions { chain: Chain; maxPerFile: number; maxRetained?: number; fetch?: ChaintracksFetchApi; fromKnownSourceUrl?: string; } ``` See also: [Chain](./client.md#type-chain), [ChaintracksFetchApi](./services.md#interface-chaintracksfetchapi) Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkHeaderFileInfo Descriptive information about a single bulk header file. ```ts export interface BulkHeaderFileInfo { fileName: string; firstHeight: number; count: number; prevChainWork: string; lastChainWork: string; prevHash: string; lastHash: string | null; fileHash: string | null; chain?: Chain; data?: Uint8Array; validated?: boolean; fileId?: number; sourceUrl?: string; } ``` See also: [Chain](./client.md#type-chain) ###### Property chain Which chain: 'main' or 'test' ```ts chain?: Chain ``` See also: [Chain](./client.md#type-chain) ###### Property count count of how many headers the file contains. File size must be 80 * count. ```ts count: number ``` ###### Property fileHash file contents single sha256 hash as base64 string ```ts fileHash: string | null ``` ###### Property fileId optional, used for database storage ```ts fileId?: number ``` ###### Property fileName filename and extension, no path ```ts fileName: string ``` ###### Property firstHeight chain height of first header in file ```ts firstHeight: number ``` ###### Property lastChainWork lastChainWork is the cummulative chain work including the last header in this file's data, as a hex string. ```ts lastChainWork: string ``` ###### Property lastHash block hash of last header in the file in standard hex string block hash encoding ```ts lastHash: string | null ``` ###### Property prevChainWork prevChainWork is the cummulative chain work up to the first header in this file's data, as a hex string. ```ts prevChainWork: string ``` ###### Property prevHash previousHash of first header in file in standard hex string block hash encoding ```ts prevHash: string ``` ###### Property sourceUrl optional, if valid `${sourceUrl}/${fileName}` is the source of this data. ```ts sourceUrl?: string ``` ###### Property validated true iff these properties should be considered pre-validated, including a valid required fileHash of data (when not undefined). ```ts validated?: boolean ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkHeaderFilesInfo Describes a collection of bulk block header files. ```ts export interface BulkHeaderFilesInfo { rootFolder: string; jsonFilename: string; files: BulkHeaderFileInfo[]; headersPerFile: number; } ``` See also: [BulkHeaderFileInfo](./services.md#interface-bulkheaderfileinfo) ###### Property files Array of information about each bulk block header file. ```ts files: BulkHeaderFileInfo[] ``` See also: [BulkHeaderFileInfo](./services.md#interface-bulkheaderfileinfo) ###### Property headersPerFile Maximum number of headers in a single file in this collection of files. ```ts headersPerFile: number ``` ###### Property jsonFilename Sub-path to this resource on rootFolder ```ts jsonFilename: string ``` ###### Property rootFolder Where this file was fetched or read from. ```ts rootFolder: string ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkIngestorApi ```ts export interface BulkIngestorApi { shutdown(): Promise<void>; getPresentHeight(): Promise<number | undefined>; fetchHeaders(before: HeightRanges, fetchRange: HeightRange, bulkRange: HeightRange, priorLiveHeaders: BlockHeader[]): Promise<BlockHeader[]>; synchronize(presentHeight: number, before: HeightRanges, priorLiveHeaders: BlockHeader[]): Promise<BulkSyncResult>; setStorage(storage: ChaintracksStorageApi, log: (...args: any[]) => void): Promise<void>; storage(): ChaintracksStorageApi; } ``` See also: [BlockHeader](./client.md#interface-blockheader), [BulkSyncResult](./services.md#interface-bulksyncresult), [ChaintracksStorageApi](./services.md#interface-chaintracksstorageapi), [HeightRange](./services.md#class-heightrange), [HeightRanges](./services.md#interface-heightranges) ###### Method fetchHeaders A BulkIngestor fetches and updates storage with bulk headers in bulkRange. If it can, it must also fetch live headers in fetch range that are not in bulkRange and return them as an array. The storage methods `insertBulkFile`, `updateBulkFile`, and `addBulkHeaders` should be used to add bulk headers to storage. ```ts fetchHeaders(before: HeightRanges, fetchRange: HeightRange, bulkRange: HeightRange, priorLiveHeaders: BlockHeader[]): Promise<BlockHeader[]> ``` See also: [BlockHeader](./client.md#interface-blockheader), [HeightRange](./services.md#class-heightrange), [HeightRanges](./services.md#interface-heightranges) Returns new live headers: headers in fetchRange but not in bulkRange Argument Details + **before** + bulk and live range of headers before ingesting any new headers. + **fetchRange** + range of headers still needed, includes both missing bulk and live headers. + **bulkRange** + range of bulk headers still needed + **priorLiveHeaders** + any headers accumulated by prior bulk ingestor(s) that are too recent for bulk storage. ###### Method getPresentHeight If the bulk ingestor is capable, return the approximate present height of the actual chain being tracked. Otherwise, return undefined. May not assume that setStorage has been called. ```ts getPresentHeight(): Promise<number | undefined> ``` ###### Method setStorage Called before first Synchronize with reference to storage. Components requiring asynchronous setup can override base class implementation. ```ts setStorage(storage: ChaintracksStorageApi, log: (...args: any[]) => void): Promise<void> ``` See also: [ChaintracksStorageApi](./services.md#interface-chaintracksstorageapi) ###### Method shutdown Close and release all resources. ```ts shutdown(): Promise<void> ``` ###### Method synchronize A BulkIngestor has two potential goals: 1. To source missing bulk headers and include them in bulk storage. 2. To source missing live headers to be forwarded to live storage. ```ts synchronize(presentHeight: number, before: HeightRanges, priorLiveHeaders: BlockHeader[]): Promise<BulkSyncResult> ``` See also: [BlockHeader](./client.md#interface-blockheader), [BulkSyncResult](./services.md#interface-bulksyncresult), [HeightRanges](./services.md#interface-heightranges) Returns updated priorLiveHeaders including any accumulated by this ingestor Argument Details + **presentHeight** + current height of the active chain tip, may lag the true value. + **before** + current bulk and live storage height ranges, either may be empty. + **priorLiveHeaders** + any headers accumulated by prior bulk ingestor(s) that are too recent for bulk storage. Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkIngestorBaseOptions ```ts export interface BulkIngestorBaseOptions { chain: Chain; jsonResource: string | undefined; } ``` See also: [Chain](./client.md#type-chain) ###### Property chain The target chain: "main" or "test" ```ts chain: Chain ``` See also: [Chain](./client.md#type-chain) ###### Property jsonResource Required. The name of the JSON resource to request from CDN which describes currently available bulk block header resources. ```ts jsonResource: string | undefined ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkIngestorCDNOptions ```ts export interface BulkIngestorCDNOptions extends BulkIngestorBaseOptions { jsonResource: string | undefined; cdnUrl: string | undefined; maxPerFile: number | undefined; fetch: ChaintracksFetchApi; } ``` See also: [BulkIngestorBaseOptions](./services.md#interface-bulkingestorbaseoptions), [ChaintracksFetchApi](./services.md#interface-chaintracksfetchapi) ###### Property cdnUrl Required. URL to CDN implementing the bulk ingestor CDN service protocol ```ts cdnUrl: string | undefined ``` ###### Property jsonResource Required. The name of the JSON resource to request from CDN which describes currently available bulk block header resources. ```ts jsonResource: string | undefined ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkIngestorWhatsOnChainOptions ```ts export interface BulkIngestorWhatsOnChainOptions extends BulkIngestorBaseOptions, WhatsOnChainServicesOptions { idleWait: number | undefined; chain: Chain; apiKey?: string; timeout: number; userAgent: string; enableCache: boolean; chainInfoMsecs: number; fetch?: ChaintracksFetchApi; } ``` See also: [BulkIngestorBaseOptions](./services.md#interface-bulkingestorbaseoptions), [Chain](./client.md#type-chain), [ChaintracksFetchApi](./services.md#interface-chaintracksfetchapi), [WhatsOnChainServicesOptions](./services.md#interface-whatsonchainservicesoptions) ###### Property apiKey WhatsOnChain.com API Key https://docs.taal.com/introduction/get-an-api-key If unknown or empty, maximum request rate is limited. https://developers.whatsonchain.com/#rate-limits ```ts apiKey?: string ``` ###### Property chain Which chain is being tracked: main, test, or stn. ```ts chain: Chain ``` See also: [Chain](./client.md#type-chain) ###### Property chainInfoMsecs How long chainInfo is considered still valid before updating (msecs). ```ts chainInfoMsecs: number ``` ###### Property enableCache Enable WhatsOnChain client cache option. ```ts enableCache: boolean ``` ###### Property idleWait Maximum msces of "normal" pause with no new data arriving. ```ts idleWait: number | undefined ``` ###### Property timeout Request timeout for GETs to https://api.whatsonchain.com/v1/bsv ```ts timeout: number ``` ###### Property userAgent User-Agent header value for requests to https://api.whatsonchain.com/v1/bsv ```ts userAgent: string ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkStorageApi Handles block header storage and retrieval older than the "live" portion of the chain. Height is the primary and only indexing field required. Only stores headers on the active chain; no orphans, no forks, no reorgs. ```ts export interface BulkStorageApi { shutdown(): Promise<void>; getMaxHeight(): Promise<number>; getHeightRange(): Promise<HeightRange>; appendHeaders(minHeight: number, count: number, headers: Uint8Array): Promise<void>; findHeaderForHeightOrUndefined(height: number): Promise<BlockHeader | undefined>; findHeaderForHeight(height: number): Promise<BlockHeader>; headersToBuffer(height: number, count: number): Promise<Uint8Array>; exportBulkHeaders(rootFolder: string, jsonFilename: string, maxPerFile: number): Promise<void>; setStorage(storage: ChaintracksStorageApi, log: (...args: any[]) => void): Promise<void>; } ``` See also: [BlockHeader](./client.md#interface-blockheader), [ChaintracksStorageApi](./services.md#interface-chaintracksstorageapi), [HeightRange](./services.md#class-heightrange) ###### Method appendHeaders Append new Block Headers to BulkStorage. Requires that these headers directly extend existing headers. maxHeight of existing plus one equals minHeight of `headers`. hash of last existing equals previousHash of first in `headers`. Checks that all `headers` are valid (hash, previousHash) Duplicate headers must be ignored. ```ts appendHeaders(minHeight: number, count: number, headers: Uint8Array): Promise<void> ``` Argument Details + **minHeight** + must match height of first header in buffer + **count** + times 80 must equal headers.length + **headers** + encoded as packed array of 80 byte serialized block headers ###### Method exportBulkHeaders Exports current bulk headers, including all ingests, excluding live headers to static header files. ```ts exportBulkHeaders(rootFolder: string, jsonFilename: string, maxPerFile: number): Promise<void> ``` Argument Details + **rootFolder** + Where the json and headers files will be written + **jsonFilename** + The name of the json file. + **maxPerFile** + The maximum headers per file. ###### Method findHeaderForHeight Returns block header for a given block height on active chain. Throws if not found. ```ts findHeaderForHeight(height: number): Promise<BlockHeader> ``` See also: [BlockHeader](./client.md#interface-blockheader) Argument Details + **hash** + block hash ###### Method findHeaderForHeightOrUndefined Returns block header for a given block height on active chain. ```ts findHeaderForHeightOrUndefined(height: number): Promise<BlockHeader | undefined> ``` See also: [BlockHeader](./client.md#interface-blockheader) Argument Details + **hash** + block hash ###### Method getHeightRange ```ts getHeightRange(): Promise<HeightRange> ``` See also: [HeightRange](./services.md#class-heightrange) Returns available bulk block header height range: `(0, getMaxHeight())` ###### Method getMaxHeight ```ts getMaxHeight(): Promise<number> ``` Returns the height of the most recent header in bulk storage or -1 if empty. ###### Method headersToBuffer Adds headers in 80 byte serialized format to a buffer. Only adds active headers. returned array length divided by 80 is the actual number returned. Returns the buffer. ```ts headersToBuffer(height: number, count: number): Promise<Uint8Array> ``` Argument Details + **height** + of first header + **count** + of headers ###### Method setStorage Called before first Synchronize with reference to storage. Components requiring asynchronous setup can override base class implementation. ```ts setStorage(storage: ChaintracksStorageApi, log: (...args: any[]) => void): Promise<void> ``` See also: [ChaintracksStorageApi](./services.md#interface-chaintracksstorageapi) ###### Method shutdown Close and release all resources. ```ts shutdown(): Promise<void> ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkStorageBaseOptions ```ts export interface BulkStorageBaseOptions { chain: Chain; fs: ChaintracksFsApi; } ``` See also: [Chain](./client.md#type-chain), [ChaintracksFsApi](./services.md#interface-chaintracksfsapi) ###### Property chain The target chain: "main" or "test" ```ts chain: Chain ``` See also: [Chain](./client.md#type-chain) Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: BulkSyncResult ```ts export interface BulkSyncResult { liveHeaders: BlockHeader[]; liveRange: HeightRange; done: boolean; log: string; } ``` See also: [BlockHeader](./client.md#interface-blockheader), [HeightRange](./services.md#class-heightrange) Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: CertOpsWallet ```ts export interface CertOpsWallet { getPublicKey(args: GetPublicKeyArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<GetPublicKeyResult>; encrypt(args: WalletEncryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<WalletEncryptResult>; decrypt(args: WalletDecryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<WalletDecryptResult>; } ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: Certifier ```ts export interface Certifier { name: string; description: string; identityKey: PubKeyHex; trust: number; iconUrl?: string; baseURL?: string; } ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksApi Full Chaintracks API including startListening with callbacks ```ts export interface ChaintracksApi extends ChaintracksClientApi { startListening(listening?: () => void): Promise<void>; } ``` See also: [ChaintracksClientApi](./services.md#interface-chaintracksclientapi) ###### Method startListening Start or resume listening for new headers. Calls `synchronize` to catch up on headers that were found while not listening. Begins listening to any number of configured new header notification services. Begins sending notifications to subscribed listeners only after processing any previously found headers. May be called if already listening or synchronizing to listen. `listening` callback will be called after listening for new live headers has begun. Alternatively, the `listening` API function which returns a Promise can be awaited. ```ts startListening(listening?: () => void): Promise<void> ``` Argument Details + **listening** + callback indicates when listening for new headers has started. Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksAppendableFileApi Supports access and appending data to new or existing named data storage. New data is always appended to the end of existing data. ```ts export interface ChaintracksAppendableFileApi extends ChaintracksReadableFileApi { append(data: Uint8Array): Promise<void>; } ``` See also: [ChaintracksReadableFileApi](./services.md#interface-chaintracksreadablefileapi) ###### Method append ```ts append(data: Uint8Array): Promise<void> ``` Argument Details + **data** + data to add to the end of existing data. Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksChainTrackerOptions ```ts export interface ChaintracksChainTrackerOptions { maxRetries?: number; } ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksClientApi Chaintracks client API excluding events and callbacks ```ts export interface ChaintracksClientApi extends ChainTracker { getChain(): Promise<Chain>; getInfo(): Promise<ChaintracksInfoApi>; getPresentHeight(): Promise<number>; getHeaders(height: number, count: number): Promise<string>; findChainTipHeader(): Promise<BlockHeader>; findChainTipHash(): Promise<string>; findHeaderForHeight(height: number): Promise<BlockHeader | undefined>; findHeaderForBlockHash(hash: string): Promise<BlockHeader | undefined>; addHeader(header: BaseBlockHeader): Promise<void>; startListening(): Promise<void>; listening(): Promise<void>; isListening(): Promise<boolean>; isSynchronized(): Promise<boolean>; subscribeHeaders(listener: HeaderListener): Promise<string>; subscribeReorgs(listener: ReorgListener): Promise<string>; unsubscribe(subscriptionId: string): Promise<boolean>; isValidRootForHeight(root: string, height: number): Promise<boolean>; currentHeight: () => Promise<number>; } ``` See also: [BaseBlockHeader](./client.md#interface-baseblockheader), [BlockHeader](./client.md#interface-blockheader), [Chain](./client.md#type-chain), [ChaintracksInfoApi](./services.md#interface-chaintracksinfoapi), [HeaderListener](./services.md#type-headerlistener), [ReorgListener](./services.md#type-reorglistener) ###### Method addHeader Submit a possibly new header for adding If the header is invalid or a duplicate it will not be added. This header will be ignored if the previous header has not already been inserted when this header is considered for insertion. ```ts addHeader(header: BaseBlockHeader): Promise<void> ``` See also: [BaseBlockHeader](./client.md#interface-baseblockheader) Returns immediately ###### Method findChainTipHash Returns the block hash of the active chain tip. ```ts findChainTipHash(): Promise<string> ``` ###### Method findChainTipHeader Returns the active chain tip header ```ts findChainTipHeader(): Promise<BlockHeader> ``` See also: [BlockHeader](./client.md#interface-blockheader) ###### Method findHeaderForBlockHash Returns block header for a given recent block hash or undefined. ```ts findHeaderForBlockHash(hash: string): Promise<BlockHeader | undefined> ``` See also: [BlockHeader](./client.md#interface-blockheader) ###### Method findHeaderForHeight Returns block header for a given block height on active chain. ```ts findHeaderForHeight(height: number): Promise<BlockHeader | undefined> ``` See also: [BlockHeader](./client.md#interface-blockheader) ###### Method getChain Confirms the chain ```ts getChain(): Promise<Chain> ``` See also: [Chain](./client.md#type-chain) ###### Method getHeaders Adds headers in 80 byte serialized format to an array. Only adds active headers. array length divided by 80 is the actual number returned. ```ts getHeaders(height: number, count: number): Promise<string> ``` Returns array of headers as serialized hex string Argument Details + **height** + of first header + **count** + of headers, maximum ###### Method getInfo ```ts getInfo(): Promise<ChaintracksInfoApi> ``` See also: [ChaintracksInfoApi](./services.md#interface-chaintracksinfoapi) Returns Summary of configuration and state. ###### Method getPresentHeight Return the latest chain height from configured bulk ingestors. ```ts getPresentHeight(): Promise<number> ``` ###### Method isListening Returns true if actively listening for new headers and client api is enabled. ```ts isListening(): Promise<boolean> ``` ###### Method isSynchronized Returns true if `synchronize` has completed at least once. ```ts isSynchronized(): Promise<boolean> ``` ###### Method listening Returns a Promise that will resolve when the previous call to startListening enters the listening-for-new-headers state. ```ts listening(): Promise<void> ``` ###### Method startListening Start or resume listening for new headers. Calls `synchronize` to catch up on headers that were found while not listening. Begins listening to any number of configured new header notification services. Begins sending notifications to subscribed listeners only after processing any previously found headers. May be called if already listening or synchronizing to listen. The `listening` API function which returns a Promise can be awaited. ```ts startListening(): Promise<void> ``` ###### Method subscribeHeaders Subscribe to "header" events. ```ts subscribeHeaders(listener: HeaderListener): Promise<string> ``` See also: [HeaderListener](./services.md#type-headerlistener) Returns identifier for this subscription Throws ERR_NOT_IMPLEMENTED if callback events are not supported ###### Method subscribeReorgs Subscribe to "reorganization" events. ```ts subscribeReorgs(listener: ReorgListener): Promise<string> ``` See also: [ReorgListener](./services.md#type-reorglistener) Returns identifier for this subscription Throws ERR_NOT_IMPLEMENTED if callback events are not supported ###### Method unsubscribe Cancels all subscriptions with the given `subscriptionId` which was previously returned by a `subscribe` method. ```ts unsubscribe(subscriptionId: string): Promise<boolean> ``` Returns true if a subscription was canceled Argument Details + **subscriptionId** + value previously returned by subscribeToHeaders or subscribeToReorgs Throws ERR_NOT_IMPLEMENTED if callback events are not supported Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksFetchApi Provides a simplified interface based on the ```ts export interface ChaintracksFetchApi { httpClient: HttpClient; download(url: string): Promise<Uint8Array>; fetchJson<R>(url: string): Promise<R>; pathJoin(baseUrl: string, subpath: string): string; } ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksFsApi Supports file-like access to named data storage. Only minimal functionality required by Chaintracks is supported. ```ts export interface ChaintracksFsApi { delete(path: string): Promise<void>; writeFile(path: string, data: Uint8Array): Promise<void>; readFile(path: string): Promise<Uint8Array>; openReadableFile(path: string): Promise<ChaintracksReadableFileApi>; openWritableFile(path: string): Promise<ChaintracksWritableFileApi>; openAppendableFile(path: string): Promise<ChaintracksAppendableFileApi>; pathJoin(...parts: string[]): string; } ``` See also: [ChaintracksAppendableFileApi](./services.md#interface-chaintracksappendablefileapi), [ChaintracksReadableFileApi](./services.md#interface-chaintracksreadablefileapi), [ChaintracksWritableFileApi](./services.md#interface-chaintrackswritablefileapi) Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksInfoApi ```ts export interface ChaintracksInfoApi { chain: Chain; heightBulk: number; heightLive: number; storage: string; bulkIngestors: string[]; liveIngestors: string[]; packages: ChaintracksPackageInfoApi[]; } ``` See also: [Chain](./client.md#type-chain), [ChaintracksPackageInfoApi](./services.md#interface-chaintrackspackageinfoapi) Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksManagementApi ```ts export interface ChaintracksManagementApi extends ChaintracksApi { destroy(): Promise<void>; validate(): Promise<boolean>; exportBulkHeaders(toFolder: string, toFs: ChaintracksFsApi, sourceUrl?: string, toHeadersPerFile?: number, maxHeight?: number): Promise<void>; } ``` See also: [ChaintracksApi](./services.md#interface-chaintracksapi), [ChaintracksFsApi](./services.md#interface-chaintracksfsapi) ###### Method destroy close and release all resources ```ts destroy(): Promise<void> ``` ###### Method exportBulkHeaders Exports current bulk headers, including all ingests, excluding live headers to static header files. Useful for bulk ingestors such as those derived from BulkIngestorCDN. ```ts exportBulkHeaders(toFolder: string, toFs: ChaintracksFsApi, sourceUrl?: string, toHeadersPerFile?: number, maxHeight?: number): Promise<void> ``` See also: [ChaintracksFsApi](./services.md#interface-chaintracksfsapi) Argument Details + **toFolder** + Where the json and headers files will be written + **toFs** + The ChaintracksFsApi to use for writing files. If not provided, the default file system will be used. + **sourceUrl** + Optional source URL to include in the exported files. Set if exported files will be transferred to a CDN. + **toHeadersPerFile** + The maximum headers per file. Default is 100,000 (8MB) + **maxHeight** + The maximum height to export. Default is the current bulk storage max height. ###### Method validate Verifies that all headers from the tip back to genesis can be retrieved, in order, by height, and that they obey previousHash constraint. Additional validations may be addeded. This is a slow operation. ```ts validate(): Promise<boolean> ``` Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables) --- ##### Interface: ChaintracksOptions ```ts export interface ChaintracksOptions { chain: Chain; storage?: ChaintracksStorageApi; bulkIngestors: BulkIngestorApi[]; liveIngestors: LiveIngestorApi[]; addLiveRecursionLimit: number; logging?: (...args: any[]) => void; readonly: boolean; } ``` See also: [BulkIngestorApi](./services.md#interface-bulkingestorapi), [Chain](./client.md#type-chain), [ChaintracksStorageApi](./services.md#interface-chaintracksstorageapi), [LiveIngestorApi](./services.md#interface-liveingestorapi) ###### Property addLiveRecursionLimit Maximum number of missing headers to pursue when listening for new headers. Normally, large numbers of missing headers are handled by bulk ingestors. ```ts addLiveRecursionLimit: number