npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cwi-external-services

v0.4.87

Published

Implementations of external service APIs and standardized APIs for use within CWI

Downloads

1,140

Readme

cwi-external-services

Implementations of external service APIs.

Standardized service APIs for use within CWI.

API

Links: API, Interfaces, Classes, Functions, Types, Variables

Interfaces

| | | | | --- | --- | --- | | ArcMinerApi | GetEnvelopeOptionsApi | MapiPostTxPayloadApi | | ArcMinerPostBeefDataApi | GetMerkleProofResultApi | MapiTxStatusPayloadApi | | BsvExchangeRateApi | GetRawTxResultApi | MapiTxidReturnResultApi | | ChaintracksChainTrackerOptions | GetScriptHistoryDetailsApi | PostBeefResultApi | | ChaintracksServiceClientOptions | GetScriptHistoryResultApi | PostBeefResultForTxidApi | | CwiExternalServicesApi | GetUtxoStatusDetailsApi | PostRawTxResultApi | | CwiExternalServicesOptions | GetUtxoStatusResultApi | PostTransactionMapiMinerApi | | ExchangeRatesIoApi | MapiCallbackApi | RawTxForPost | | FiatExchangeRatesApi | MapiCallbackPayloadApi | |

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: ArcMinerApi

export interface ArcMinerApi {
    name: string;
    url: string;
    apiKey?: string;
    deploymentId?: string;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: ArcMinerPostBeefDataApi

export interface ArcMinerPostBeefDataApi {
    status: number;
    title: string;
    extraInfo: string;
    blockHash?: string;
    blockHeight?: number;
    competingTxs?: null;
    merklePath?: string;
    timestamp?: string;
    txStatus?: string;
    txid?: string;
    type?: string;
    detail?: string;
    instance?: string;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: BsvExchangeRateApi

export interface BsvExchangeRateApi {
    timestamp: Date;
    base: "USD";
    rate: number;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: ChaintracksChainTrackerOptions

export interface ChaintracksChainTrackerOptions {
    maxRetries?: number;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: ChaintracksServiceClientOptions

export interface ChaintracksServiceClientOptions {
    useAuthrite: boolean;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: CwiExternalServicesApi

Defines standard interfaces to access functionality implemented by external transaction processing services.

export interface CwiExternalServicesApi {
    getBsvExchangeRate(): Promise<number>;
    getFiatExchangeRate(currency: "USD" | "GBP" | "EUR", base?: "USD" | "GBP" | "EUR"): Promise<number>;
    getRawTx(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<GetRawTxResultApi>;
    getTransaction(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<Transaction>;
    getTransactionOutput(vout: number, txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<TransactionOutput>;
    getMerkleProof(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<GetMerkleProofResultApi>;
    postRawTx(rawTx: string | Buffer, chain: Chain, callback?: MapiCallbackApi): Promise<PostRawTxResultApi[]>;
    postRawTxs(rawTxs: string[] | Buffer[] | number[][], chain: Chain): Promise<PostRawTxResultApi[][]>;
    postBeef(beef: number[], txids: string[], chain: Chain): Promise<PostBeefResultApi[]>;
    postBeefs(beefs: number[][], txids: string[], chain: Chain): Promise<PostBeefResultApi[][]>;
    getUtxoStatus(output: string | Buffer, chain: Chain, outputFormat?: GetUtxoStatusOutputFormatApi, useNext?: boolean): Promise<GetUtxoStatusResultApi>;
}

See also: GetMerkleProofResultApi, GetRawTxResultApi, GetUtxoStatusOutputFormatApi, GetUtxoStatusResultApi, MapiCallbackApi, PostBeefResultApi, PostRawTxResultApi

Method getBsvExchangeRate

Approximate exchange rate US Dollar / BSV, USD / BSV

This is the US Dollar price of one BSV

getBsvExchangeRate(): Promise<number>
Method getFiatExchangeRate

Approximate exchange rate currency per base.

getFiatExchangeRate(currency: "USD" | "GBP" | "EUR", base?: "USD" | "GBP" | "EUR"): Promise<number>
Method getMerkleProof

Attempts to obtain the merkle proof associated with a 32 byte transaction hash (txid).

Cycles through configured transaction processing services attempting to get a valid response.

On success: Result txid is the requested transaction hash Result proof will be the merkle proof. Result name will be the responding service's identifying name. Returns result without incrementing active service.

On failure: Result txid is the requested transaction hash Result mapi will be the first mapi response obtained (service name and response), or null Result error will be the first error thrown (service name and CwiError), or null Increments to next configured service and tries again until all services have been tried.

getMerkleProof(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<GetMerkleProofResultApi>

See also: GetMerkleProofResultApi

Argument Details

  • txid
    • transaction hash for which proof is requested
  • chain
    • which chain to look on
  • useNext
    • optional, forces skip to next service before starting service requests cycle.
Method getRawTx

Attempts to obtain the raw transaction bytes associated with a 32 byte transaction hash (txid).

Cycles through configured transaction processing services attempting to get a valid response.

On success: Result txid is the requested transaction hash Result rawTx will be Buffer containing raw transaction bytes. Result name will be the responding service's identifying name. Returns result without incrementing active service.

On failure: Result txid is the requested transaction hash Result mapi will be the first mapi response obtained (service name and response), or null Result error will be the first error thrown (service name and CwiError), or null Increments to next configured service and tries again until all services have been tried.

getRawTx(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<GetRawTxResultApi>

See also: GetRawTxResultApi

Argument Details

  • txid
    • transaction hash for which raw transaction bytes are requested
  • chain
    • which chain to look on
  • useNext
    • optional, forces skip to next service before starting service requests cycle.
Method getTransaction

Typically uses getRawTx to lookup a raw transaction to return a parsed Transaction.

getTransaction(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<Transaction>

Argument Details

  • txid
    • transaction hash for which raw transaction bytes are requested
  • chain
    • which chain to look on
  • useNext
    • optional, forces skip to next service before starting service requests cycle.

Throws

ERR_INVALID_PARAMETER if txid does not exist, or can't be found, on chain.

Method getTransactionOutput

Typically uses getTransaction to obtain a parsed Transaction and returns a specific TransactionOutput.

getTransactionOutput(vout: number, txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<TransactionOutput>

Argument Details

  • vout
    • the index (zero based) of the output to be returned
  • txid
    • transaction hash for which raw transaction bytes are requested
  • chain
    • which chain to look on
  • useNext
    • optional, forces skip to next service before starting service requests cycle.

Throws

ERR_INVALID_PARAMETER if txid does not exist, or can't be found, on chain, or if vout is invalid.

Method getUtxoStatus

Attempts to determine the UTXO status of a transaction output.

Cycles through configured transaction processing services attempting to get a valid response.

getUtxoStatus(output: string | Buffer, chain: Chain, outputFormat?: GetUtxoStatusOutputFormatApi, useNext?: boolean): Promise<GetUtxoStatusResultApi>

See also: GetUtxoStatusOutputFormatApi, GetUtxoStatusResultApi

Argument Details

  • output
    • transaction output identifier in format determined by outputFormat.
  • chain
    • which chain to post to, all of rawTx's inputs must be unspent on this chain.
  • outputFormat
    • optional, supported values: 'hashLE' little-endian sha256 hash of output script 'hashBE' big-endian sha256 hash of output script 'script' entire transaction output script undefined if asBuffer length of output is 32 then 'hashBE`, otherwise 'script'.
  • useNext
    • optional, forces skip to next service before starting service requests cycle.
Method postRawTx

Attempts to post a new transaction to each configured external transaction processing service.

Asynchronously posts the transaction simultaneously to all the configured services.

postRawTx(rawTx: string | Buffer, chain: Chain, callback?: MapiCallbackApi): Promise<PostRawTxResultApi[]>

See also: MapiCallbackApi, PostRawTxResultApi

Returns

an array of PostRawTxResultApi objects with results of posting to each service

Argument Details

  • rawTx
    • new raw transaction to post for processing
  • chain
    • which chain to post to, all of rawTx's inputs must be unspent on this chain.
  • callback
    • optional, controls whether and how each service is to make transaction status update callbacks.
Method postRawTxs

Attempts to post multiple new transaction to each configured external transaction processing service.

Posting multiple transactions is recommended when chaining new transactions and for performance gains.

Asynchronously posts the transactions simultaneously to all the configured services.

postRawTxs(rawTxs: string[] | Buffer[] | number[][], chain: Chain): Promise<PostRawTxResultApi[][]>

See also: PostRawTxResultApi

Returns

an array of PostRawTxResultApi objects with results of posting to each service

Argument Details

  • rawTxs
    • new raw transactions to post for processing
  • chain
    • which chain to post to, all of rawTx's inputs must be unspent on this chain.

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: CwiExternalServicesOptions

export interface CwiExternalServicesOptions {
    mainTaalApiKey?: string;
    testTaalApiKey?: string;
    bsvExchangeRate: BsvExchangeRateApi;
    bsvUpdateMsecs: number;
    fiatExchangeRates: FiatExchangeRatesApi;
    fiatUpdateMsecs: number;
    disableMapiCallback?: boolean;
    exchangeratesapiKey?: string;
    chaintracksFiatExchangeRatesUrl?: string;
}

See also: BsvExchangeRateApi, FiatExchangeRatesApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: ExchangeRatesIoApi

export interface ExchangeRatesIoApi {
    success: boolean;
    timestamp: number;
    base: "EUR" | "USD";
    date: string;
    rates: Record<string, number>;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: FiatExchangeRatesApi

export interface FiatExchangeRatesApi {
    timestamp: Date;
    base: "USD";
    rates: Record<string, number>;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: GetEnvelopeOptionsApi

export interface GetEnvelopeOptionsApi {
    chaintracks?: ChaintracksClientApi;
    maxRecursionDepth?: number;
    minProofLevel?: number;
}
Property minProofLevel

Use to generate test envelopes. If set to a number greater than zero, proofs will be ignored until that level. The first level is zero. userId must be undefined.

minProofLevel?: number

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: GetMerkleProofResultApi

Properties on result returned from CwiExternalServicesApi function getMerkleProof.

export interface GetMerkleProofResultApi {
    name?: string;
    proof?: TscMerkleProofApi | TscMerkleProofApi[];
    mapi?: {
        name?: string;
        resp: MapiResponseApi;
    };
    error?: {
        name?: string;
        err: CwiError;
    };
}
Property error

The first exception error that occurred during processing, if any.

error?: {
    name?: string;
    err: CwiError;
}
Property mapi

The first valid mapi response received from a service, if any. Relevant when no proof was received.

mapi?: {
    name?: string;
    resp: MapiResponseApi;
}
Property name

The name of the service returning the proof, or undefined if no proof

name?: string
Property proof

Multiple proofs may be returned when a transaction also appears in one or more orphaned blocks

proof?: TscMerkleProofApi | TscMerkleProofApi[]

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: GetRawTxResultApi

Properties on result returned from CwiExternalServicesApi function getRawTx.

export interface GetRawTxResultApi {
    txid: string;
    name?: string;
    rawTx?: Buffer;
    mapi?: {
        name?: string;
        resp: MapiResponseApi;
    };
    error?: {
        name?: string;
        err: CwiError;
    };
}
Property error

The first exception error that occurred during processing, if any.

error?: {
    name?: string;
    err: CwiError;
}
Property mapi

The first valid mapi response received from a service, if any. Relevant when no proof was received.

mapi?: {
    name?: string;
    resp: MapiResponseApi;
}
Property name

The name of the service returning the rawTx, or undefined if no rawTx

name?: string
Property rawTx

Multiple proofs may be returned when a transaction also appears in one or more orphaned blocks

rawTx?: Buffer
Property txid

Transaction hash or rawTx (and of initial request)

txid: string

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: GetScriptHistoryDetailsApi

export interface GetScriptHistoryDetailsApi {
    txid: string;
    height?: number;
    fee?: number;
}
Property fee

the fee paid by the transaction referencing this output script, may be an input or output

typically valid if the transaction has not been mined.

fee?: number
Property height

the block height of the transaction referencing this output script, may be an input or output

typically valid if the transaction has been mined.

height?: number
Property txid

the hash of the transaction referencing this output script, may be an input or output

txid: string

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: GetScriptHistoryResultApi

export interface GetScriptHistoryResultApi {
    name: string;
    status: "success" | "error";
    error?: CwiError;
    details: GetScriptHistoryDetailsApi[];
}

See also: GetScriptHistoryDetailsApi

Property details

Additional details about occurances of this output script.

Sorted by decreasing fee, then decreasing height. i.e. most likely spending transaction first.

details: GetScriptHistoryDetailsApi[]

See also: GetScriptHistoryDetailsApi

Property error

When status is 'error', provides code and description

error?: CwiError
Property name

The name of the service to which the transaction was submitted for processing

name: string
Property status

'success' - the operation was successful, non-error results are valid. 'error' - the operation failed, error may have relevant information.

status: "success" | "error"

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: GetUtxoStatusDetailsApi

export interface GetUtxoStatusDetailsApi {
    height?: number;
    txid?: string;
    index?: number;
    amount?: number;
}
Property amount

if isUtxo, the amount of the matching unspent transaction output

typically there will be only one, but future orphans can result in multiple values

amount?: number
Property height

if isUtxo, the block height containing the matching unspent transaction output

typically there will be only one, but future orphans can result in multiple values

height?: number
Property index

if isUtxo, the output index in the transaction containing of the matching unspent transaction output

typically there will be only one, but future orphans can result in multiple values

index?: number
Property txid

if isUtxo, the transaction hash (txid) of the transaction containing the matching unspent transaction output

typically there will be only one, but future orphans can result in multiple values

txid?: string

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: GetUtxoStatusResultApi

export interface GetUtxoStatusResultApi {
    name: string;
    status: "success" | "error";
    error?: CwiError;
    isUtxo?: boolean;
    details: GetUtxoStatusDetailsApi[];
}

See also: GetUtxoStatusDetailsApi

Property details

Additional details about occurances of this output script as a utxo.

Normally there will be one item in the array but due to the possibility of orphan races there could be more than one block in which it is a valid utxo.

details: GetUtxoStatusDetailsApi[]

See also: GetUtxoStatusDetailsApi

Property error

When status is 'error', provides code and description

error?: CwiError
Property isUtxo

true if the output is associated with at least one unspent transaction output

isUtxo?: boolean
Property name

The name of the service to which the transaction was submitted for processing

name: string
Property status

'success' - the operation was successful, non-error results are valid. 'error' - the operation failed, error may have relevant information.

status: "success" | "error"

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: MapiCallbackApi

An API that enables unique callback IDs to be generated for potentially multiple independent callback clients.

export interface MapiCallbackApi {
    getId: () => Promise<string>;
    url: string;
}
Property getId

Each call to this method generates a unique callbackID string and creates a record of the circumstances under which it was generated.

getId: () => Promise<string>
Property url

The public url to which callbacks will occur.

Callback requests must include a previously getId generated callbackID which must match an already existing callback record.

url: string

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: MapiCallbackPayloadApi

As defined in https://github.com/bitcoin-sv-specs/brfc-merchantapi/blob/master/README.md

export interface MapiCallbackPayloadApi {
    apiVersion: string;
    timestamp: string;
    blockHash: string;
    blockHeight: number;
    callbackTxId: string;
    callbackReason: string;
    callbackPayload: string;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: MapiPostTxPayloadApi

As defined in https://github.com/bitcoin-sv-specs/brfc-merchantapi/blob/master/README.md

export interface MapiPostTxPayloadApi {
    apiVersion: string;
    timestamp: string;
    txid: string;
    returnResult: string;
    resultDescription: string;
    minerId: string;
    currentHighestBlockHash?: string;
    currentHighestBlockHeight?: number;
    txSecondMempoolExpiry?: number;
    failureRetryable?: boolean;
    warnings?: unknown[];
    conflictedWith?: unknown[];
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: MapiTxStatusPayloadApi

As defined in https://github.com/bitcoin-sv-specs/brfc-merchantapi/blob/master/README.md

export interface MapiTxStatusPayloadApi {
    apiVersion: string;
    timestamp: string;
    txid: string;
    returnResult: string;
    blockHash: string;
    blockHeight: number;
    confirmations: number;
    minerId: string;
    txSecondMempoolExpiry: number;
    merkleProof?: TscMerkleProofApi;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: MapiTxidReturnResultApi

Used to parse payloads when only confirmation that a miner acknowledges a specific txid matters.

export interface MapiTxidReturnResultApi {
    apiVersion?: string;
    timestamp?: string;
    txid: string;
    returnResult: string;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: PostBeefResultApi

Properties on array items of result returned from CwiExternalServicesApi function postBeef.

export interface PostBeefResultApi {
    name: string;
    status: "success" | "error";
    error?: CwiError;
    txids: PostBeefResultForTxidApi[];
    data?: object;
}

See also: PostBeefResultForTxidApi

Property data

Service response object. Use service name and status to infer type of object.

data?: object
Property error

When status is 'error', provides code and description

Specific potential errors: ERR_BAD_REQUEST ERR_EXTSVS_DOUBLE_SPEND ERR_EXTSVS_ALREADY_MINED (description has error details) ERR_EXTSVS_INVALID_TRANSACTION (description has error details) ERR_EXTSVS_TXID_INVALID (service response txid doesn't match rawTx)

error?: CwiError
Property name

The name of the service to which the transaction was submitted for processing

name: string
Property status

'success' - The beef was accepted for processing

status: "success" | "error"

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: PostBeefResultForTxidApi

export interface PostBeefResultForTxidApi {
    txid: string;
    status: "success" | "error";
    alreadyKnown?: boolean;
    blockHash?: string;
    blockHeight?: number;
    merklePath?: string;
}
Property alreadyKnown

if true, the transaction was already known to this service. Usually treat as a success.

Potentially stop posting to additional transaction processors.

alreadyKnown?: boolean
Property status

'success' - The transaction was accepted for processing

status: "success" | "error"

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: PostRawTxResultApi

Properties on array items of result returned from CwiExternalServicesApi function postRawTx.

export interface PostRawTxResultApi {
    name: string;
    callbackID?: string;
    status: "success" | "error";
    mapi?: MapiResponseApi;
    payload?: MapiPostTxPayloadApi;
    error?: CwiError;
    alreadyKnown?: boolean;
}

See also: MapiPostTxPayloadApi

Property alreadyKnown

if true, the transaction was already known to this service. Usually treat as a success.

Potentially stop posting to additional transaction processors.

alreadyKnown?: boolean
Property callbackID

callbackID associated with this request

callbackID?: string
Property error

When status is 'error', provides code and description

Specific potential errors: ERR_BAD_REQUEST ERR_EXTSVS_DOUBLE_SPEND ERR_EXTSVS_ALREADY_MINED (description has error details) ERR_EXTSVS_INVALID_TRANSACTION (description has error details) ERR_EXTSVS_TXID_INVALID (service response txid doesn't match rawTx) ERR_EXTSVS_MAPI_SIGNATURE_INVALID ERR_EXTSVS_MAPI_UNSUPPORTED_ENCODING ERR_EXTSVS_MAPI_UNSUPPORTED_MIMETYPE ERR_EXTSVS_MAPI_MISSING (description has service request error details)

error?: CwiError
Property mapi

Raw mapi response including stringified payload

mapi?: MapiResponseApi
Property name

The name of the service to which the transaction was submitted for processing

name: string
Property payload

Parsed and signature verified mapi payload

payload?: MapiPostTxPayloadApi

See also: MapiPostTxPayloadApi

Property status

'success' - The transaction was accepted for processing

status: "success" | "error"

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: PostTransactionMapiMinerApi

export interface PostTransactionMapiMinerApi {
    name: string;
    url: string;
    authType: "none" | "bearer";
    authToken?: string;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Interface: RawTxForPost

export interface RawTxForPost {
    txid: string;
    rawTx: Buffer;
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Classes

| | | | | --- | --- | --- | | ChaintracksChainTracker | ERR_EXTSVS_FEE | ERR_EXTSVS_MERKLEPROOF_NODE_TYPE | | ChaintracksServiceClient | ERR_EXTSVS_GENERIC | ERR_EXTSVS_MERKLEPROOF_PARSING | | CwiExternalServices | ERR_EXTSVS_INVALID_TRANSACTION | ERR_EXTSVS_MERKLEPROOF_TAGET_TYPE | | ERR_EXTSVS_ALREADY_MINED | ERR_EXTSVS_INVALID_TXID | ERR_EXTSVS_MERKLEPROOF_UNSUPPORTED | | ERR_EXTSVS_BLOCK_HASH_MISSING | ERR_EXTSVS_MAPI_MISSING | ERR_EXTSVS_MERKLEROOT_INVALID | | ERR_EXTSVS_BLOCK_HEIGHT_MISSING | ERR_EXTSVS_MAPI_SIGNATURE_INVALID | ERR_EXTSVS_MERKLEROOT_MISSING | | ERR_EXTSVS_DOUBLE_SPEND | ERR_EXTSVS_MAPI_UNSUPPORTED_ENCODING | ERR_EXTSVS_SECURITY | | ERR_EXTSVS_ENVELOPE_DEPTH | ERR_EXTSVS_MAPI_UNSUPPORTED_MIMETYPE | ERR_EXTSVS_TXID_INVALID | | ERR_EXTSVS_FAILURE | ERR_EXTSVS_MAPI_UNSUPPORTED_RETURNRESULT | ServiceCollection |

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ChaintracksChainTracker

export class ChaintracksChainTracker implements ChainTracker {
    chaintracks: ChaintracksClientApi;
    cache: Record<number, string>;
    options: ChaintracksChainTrackerOptions;
    constructor(chain?: Chain, chaintracks?: ChaintracksClientApi, options?: ChaintracksChainTrackerOptions) 
    async currentHeight(): Promise<number> 
    async isValidRootForHeight(root: string, height: number): Promise<boolean> 
}

See also: ChaintracksChainTrackerOptions

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ChaintracksServiceClient

Connects to a ChaintracksService to implement ChaintracksClientApi

export class ChaintracksServiceClient implements ChaintracksClientApi {
    static createChaintracksServiceClientOptions(): ChaintracksServiceClientOptions 
    authrite?: AuthriteClient;
    options: ChaintracksServiceClientOptions;
    constructor(public chain: Chain, public serviceUrl: string, options?: ChaintracksServiceClientOptions) 
    async currentHeight(): Promise<number> 
    async isValidRootForHeight(root: string, height: number): Promise<boolean> 
    async subscribeHeaders(listener: HeaderListener): Promise<string> 
    async subscribeReorgs(listener: ReorgListener): Promise<string> 
    async unsubscribe(subscriptionId: string): Promise<boolean> 
    async getJsonOrUndefined<T>(path: string): Promise<T | undefined> 
    async getJson<T>(path: string): Promise<T> 
    async postJsonVoid<T>(path: string, params: T): Promise<void> 
    async addHeaderHex(header: BaseBlockHeaderHex): Promise<void> 
    async startListening(): Promise<void> 
    async listening(): Promise<void> 
    async getChain(): Promise<Chain> 
    async getInfo(wait?: number): Promise<ChaintracksInfoApi> 
    async isListening(): Promise<boolean> 
    async isSynchronized(): Promise<boolean> 
    async getPresentHeight(): Promise<number> 
    async findChainTipHeaderHex(): Promise<BlockHeaderHex> 
    async findChainTipHashHex(): Promise<string> 
    async getHeadersHex(height: number, count: number): Promise<string> 
    async findHeaderHexForHeight(height: number): Promise<BlockHeaderHex | undefined> 
    async findChainWorkHexForBlockHash(hash: string | Buffer): Promise<string | undefined> 
    async findHeaderHexForBlockHash(hash: Buffer | string): Promise<BlockHeaderHex | undefined> 
    async findHeaderHexForMerkleRoot(merkleRoot: Buffer | string, height?: number): Promise<BlockHeaderHex | undefined> 
    async findChainTipHeader(): Promise<BlockHeader> 
    async findChainTipHash(): Promise<Buffer> 
    async findChainWorkForBlockHash(hash: string | Buffer): Promise<Buffer | undefined> 
    async findHeaderForBlockHash(hash: string | Buffer): Promise<BlockHeader | undefined> 
    async getHeaders(height: number, count: number): Promise<Buffer> 
    async findHeaderForHeight(height: number): Promise<BlockHeader | undefined> 
    async findHeaderForMerkleRoot(root: string | Buffer, height?: number): Promise<BlockHeader | undefined> 
    async addHeader(header: BaseBlockHeader | BaseBlockHeaderHex): Promise<void> 
}

See also: ChaintracksServiceClientOptions

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: CwiExternalServices

export class CwiExternalServices implements CwiExternalServicesApi {
    static createDefaultOptions(): CwiExternalServicesOptions 
    options: CwiExternalServicesOptions;
    getMerkleProofServices: ServiceCollection<GetMerkleProofServiceApi>;
    getRawTxServices: ServiceCollection<GetRawTxServiceApi>;
    postRawTxServices: ServiceCollection<PostRawTxServiceApi>;
    postRawTxsServices: ServiceCollection<PostRawTxsServiceApi>;
    postBeefServices: ServiceCollection<PostBeefServiceApi>;
    postBeefsServices: ServiceCollection<PostBeefsServiceApi>;
    getUtxoStatusServices: ServiceCollection<GetUtxoStatusServiceApi>;
    getScriptHistoryServices: ServiceCollection<GetScriptHistoryServiceApi>;
    updateFiatExchangeRateServices: ServiceCollection<UpdateFiatExchangeRateServiceApi>;
    constructor(options?: CwiExternalServicesOptions) 
    async getBsvExchangeRate(): Promise<number> 
    async getFiatExchangeRate(currency: "USD" | "GBP" | "EUR", base?: "USD" | "GBP" | "EUR"): Promise<number> 
    targetCurrencies = ["USD", "GBP", "EUR"];
    async updateFiatExchangeRates(rates?: FiatExchangeRatesApi, updateMsecs?: number): Promise<FiatExchangeRatesApi> 
    get getProofsCount() 
    get getRawTxsCount() 
    get postRawTxsCount() 
    get postBeefServicesCount() 
    get postRawTxsServicesCount() 
    get getUtxoStatsCount() 
    async getUtxoStatus(output: string | Buffer, chain: Chain, outputFormat?: GetUtxoStatusOutputFormatApi, useNext?: boolean): Promise<GetUtxoStatusResultApi> 
    async getScriptHistory(output: string | Buffer, chain: Chain, outputFormat?: GetUtxoStatusOutputFormatApi, useNext?: boolean): Promise<GetScriptHistoryResultApi> 
    async verifyOutput(output: {
        outputScript: Buffer | null;
        amount: number | null;
    }, chain: Chain): Promise<boolean> 
    async postBeef(beef: number[] | Beef, txids: string[], chain: Chain): Promise<PostBeefResultApi[]> 
    async postBeefs(beefs: number[][], txids: string[], chain: Chain): Promise<PostBeefResultApi[][]> 
    async postRawTxs(rawTxs: string[] | Buffer[] | number[][], chain: Chain): Promise<PostRawTxResultApi[][]> 
    async postRawTx(rawTx: string | Buffer, chain: Chain, callback?: MapiCallbackApi): Promise<PostRawTxResultApi[]> 
    async getRawTx(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<GetRawTxResultApi> 
    async getTransaction(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<Transaction> 
    async getTransactionOutput(vout: number, txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<TransactionOutput> 
    async getMerkleProof(txid: string | Buffer, chain: Chain, useNext?: boolean): Promise<GetMerkleProofResultApi> 
}

See also: CwiExternalServicesApi, CwiExternalServicesOptions, FiatExchangeRatesApi, GetMerkleProofResultApi, GetMerkleProofServiceApi, GetRawTxResultApi, GetRawTxServiceApi, GetScriptHistoryResultApi, GetScriptHistoryServiceApi, GetUtxoStatusOutputFormatApi, GetUtxoStatusResultApi, GetUtxoStatusServiceApi, MapiCallbackApi, PostBeefResultApi, PostBeefServiceApi, PostBeefsServiceApi, PostRawTxResultApi, PostRawTxServiceApi, PostRawTxsServiceApi, ServiceCollection, UpdateFiatExchangeRateServiceApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_ALREADY_MINED

Transaction was already mined.

export class ERR_EXTSVS_ALREADY_MINED extends CwiError {
    constructor(description?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_BLOCK_HASH_MISSING

Header for block hash ${hash} was not found.

export class ERR_EXTSVS_BLOCK_HASH_MISSING extends CwiError {
    constructor(hash?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_BLOCK_HEIGHT_MISSING

Header for block height ${height} was not found.

export class ERR_EXTSVS_BLOCK_HEIGHT_MISSING extends CwiError {
    constructor(height?: number) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_DOUBLE_SPEND

Transaction with txid of ${txid} is a double spend.

This class does not include spendingTransactions, see ERR_DOUBLE_SPEND if required.

export class ERR_EXTSVS_DOUBLE_SPEND extends CwiError {
    constructor(public txid: string, description?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_ENVELOPE_DEPTH

Exceeded max envelope depth ${maxDepth}

export class ERR_EXTSVS_ENVELOPE_DEPTH extends CwiError {
    constructor(maxDepth: number) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_FAILURE

Expected txid ${expected} doesn't match proof txid ${actual}

export class ERR_EXTSVS_FAILURE extends CwiError {
    constructor(public url: string, public cwiError?: CwiError, description?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_FEE

Fee error.

export class ERR_EXTSVS_FEE extends CwiError {
    constructor(description?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_GENERIC

See description.

export class ERR_EXTSVS_GENERIC extends CwiError {
    constructor(description: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_INVALID_TRANSACTION

Transaction is invalid.

export class ERR_EXTSVS_INVALID_TRANSACTION extends CwiError {
    constructor(description?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_INVALID_TXID

Txid of broadcast transaction doesn't match returned txid.

export class ERR_EXTSVS_INVALID_TXID extends CwiError {
    constructor(description?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MAPI_MISSING

Required Mapi response is missing.

export class ERR_EXTSVS_MAPI_MISSING extends CwiError {
    constructor(description?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MAPI_SIGNATURE_INVALID

Mapi response signature is invalid.

export class ERR_EXTSVS_MAPI_SIGNATURE_INVALID extends CwiError {
    constructor() 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MAPI_UNSUPPORTED_ENCODING

mAPI response unsupported encoding ${encoding}

export class ERR_EXTSVS_MAPI_UNSUPPORTED_ENCODING extends CwiError {
    constructor(encoding?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MAPI_UNSUPPORTED_MIMETYPE

mAPI response unsupported mimetype ${mimeType}

export class ERR_EXTSVS_MAPI_UNSUPPORTED_MIMETYPE extends CwiError {
    constructor(mimeType?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MAPI_UNSUPPORTED_RETURNRESULT

mAPI response unsupported returnResult ${result}

export class ERR_EXTSVS_MAPI_UNSUPPORTED_RETURNRESULT extends CwiError {
    constructor(result?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MERKLEPROOF_NODE_TYPE

Unsupported merkle proof node type ${nodeType}.

export class ERR_EXTSVS_MERKLEPROOF_NODE_TYPE extends CwiError {
    constructor(nodeType?: string | number) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MERKLEPROOF_PARSING

Merkle proof parsing error.

export class ERR_EXTSVS_MERKLEPROOF_PARSING extends CwiError {
    constructor() 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MERKLEPROOF_TAGET_TYPE

Unsupported merkle proof target type ${targetType}.

export class ERR_EXTSVS_MERKLEPROOF_TAGET_TYPE extends CwiError {
    constructor(targetType?: string | number) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MERKLEPROOF_UNSUPPORTED

Merkle proof unsuported feature ${feature}.

export class ERR_EXTSVS_MERKLEPROOF_UNSUPPORTED extends CwiError {
    constructor(feature?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MERKLEROOT_INVALID

Expected merkleRoot ${expected} doesn't match computed ${actual}

export class ERR_EXTSVS_MERKLEROOT_INVALID extends CwiError {
    constructor(expected?: string, actual?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_MERKLEROOT_MISSING

MerkleRoot ${merkleRoot} was not found in active chain.

export class ERR_EXTSVS_MERKLEROOT_MISSING extends CwiError {
    constructor(merkleRoot?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_SECURITY

Security error.

export class ERR_EXTSVS_SECURITY extends CwiError {
    constructor(description?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ERR_EXTSVS_TXID_INVALID

Expected txid ${expected} doesn't match proof txid ${actual}

export class ERR_EXTSVS_TXID_INVALID extends CwiError {
    constructor(expected?: string, actual?: string) 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Class: ServiceCollection

export class ServiceCollection<T> {
    services: {
        name: string;
        service: T;
    }[];
    _index: number;
    constructor(services?: {
        name: string;
        service: T;
    }[]) 
    add(s: {
        name: string;
        service: T;
    }): ServiceCollection<T> 
    remove(name: string): void 
    get name() 
    get service() 
    get allServices() 
    get count() 
    get index() 
    reset() 
    next(): number 
    clone(): ServiceCollection<T> 
}

Links: API, Interfaces, Classes, Functions, Types, Variables


Functions

| | | | | --- | --- | --- | | checkMapiResponse | getMerkleProofFromWhatsOnChain | postBeefsToArcMiner | | checkMapiResponseForTxid | getMerkleProofFromWhatsOnChainTsc | postBeefsToTaalArcMiner | | checkMerkleProof | getProofFromGorillaPool | postRawTxToGorillaPool | | createMapiPostTxResponse | getProofFromMetastreme | postRawTxToMapiMiner | | deserializeTscMerkleProof | getProofFromTaal | postRawTxToTaal | | deserializeTscMerkleProofNodes | getProofFromWhatsOnChain | postRawTxToWhatsOnChain | | getEnvelopeForTransaction | getProofFromWhatsOnChainTsc | serializeTscMerkleProof | | getExchangeRatesIo | getRawTxFromWhatsOnChain | serializeTscMerkleProofNodes | | getMapiCallbackPayload | getScriptHistoryFromWhatsOnChain | signMapiPayload | | getMapiJsonResponsePayload | getSpentStatusForOutpoint | updateBsvExchangeRate | | getMapiPostTxPayload | getUtxoStatusFromWhatsOnChain | updateChaintracksFiatExchangeRates | | getMapiTxStatusPayload | makeErrorResult | updateExchangeratesapi | | getMerkleProofFromGorillaPool | makePostBeefResult | validateScriptHash | | getMerkleProofFromMetastreme | postBeefToArcMiner | verifyMapiResponseForTxid | | getMerkleProofFromTaal | postBeefToTaalArcMiner | |

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: checkMapiResponse

Verifies the payload signature on a mAPI response object

export function checkMapiResponse(response: MapiResponseApi) 

Throws

ERR_EXTSVS_MAPI_SIGNATURE_INVALID if signature fails to validate.

https://github.com/bitcoin-sv-specs/brfc-misc/tree/master/jsonenvelope

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: checkMapiResponseForTxid

export function checkMapiResponseForTxid(response: MapiResponseApi, txid?: string | Buffer): boolean 

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: checkMerkleProof

Implement merkle proof per https://tsc.bitcoinassociation.net/standards/merkle-proof-standardised-format/

We extend the current standard by implementing targetType 'height' (binary value 3). This extension avoids the need to maintain a merkleroot or block hash index for all headers, reducing the space required by 50%.

Other extensions are not currently supported.

Supports partial and full binary format as well as hex strings.

External Assumptions:

  1. The raw transaction is in-hand and is either duplicated in the proof or matches the starting hash used to evaluate the merkle tree branch.

Checking the proof verifies these claims:

  1. The merkleRoot determined by the targetType is confirmed to match a block header on the active chain.
  2. Computing a merkleRoot value starting with the transaction hash, using the proof nodes yields a match for the target value.

Implications:

  1. The transaction in-hand is valid and was included in a block on the active chain.
export async function checkMerkleProof(txid: string | Buffer, proof: TscMerkleProofApi | Buffer, chaintracks: ChaintracksClientApi): Promise<BlockHeader> 

Returns

The block header containing the verified merkleRoot

Argument Details

  • txid
    • the transaction hash of the in-hand transaction to which this proof applies.

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: createMapiPostTxResponse

export function createMapiPostTxResponse(txid: string, key: string, resultDescription: string, returnResult = "success"): {
    mapi: MapiResponseApi;
    payloadData: MapiPostTxPayloadApi;
} 

See also: MapiPostTxPayloadApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: deserializeTscMerkleProof

export function deserializeTscMerkleProof(txid: string, buffer: TscMerkleProofApi | Buffer): TscMerkleProofApi 

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: deserializeTscMerkleProofNodes

export function deserializeTscMerkleProofNodes(nodes: Buffer | string[]): string[] 

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getEnvelopeForTransaction

A transaction envelope is a tree of inputs where all the leaves are proven transactions. The trivial case is a single leaf: the envelope for a proven transaction is the rawTx and its proof.

Each branching level of the tree corresponds to an unmined transaction without a proof, in which case the envelope is:

  • rawTx
  • mapiResponses from transaction processors (optional)
  • inputs object where keys are this transaction's input txids and values are recursive envelope for those txids.

If storage is defined, any previously unseen txids that are required to build the envelope will be added to the proven_txs table, if they can be proven.

The options.maxRecursionDepth can be set to prevent overly deep and large envelopes. Will throw ERR_EXTSVS_ENVELOPE_DEPTH if exceeded.

export async function getEnvelopeForTransaction(services: CwiExternalServices, chain: Chain, txid: string | Buffer, options?: GetEnvelopeOptionsApi): Promise<EnvelopeApi> 

See also: CwiExternalServices, GetEnvelopeOptionsApi

Argument Details

  • services
    • used to obtain rawTx and merkleProof data.
  • chain
    • the chain on which txid exists.
  • txid
    • the transaction hash for which an envelope is requested.
  • options
    • default options use babbage cloud chaintracks service, chaintracks is required for envelope creation.

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getExchangeRatesIo

export async function getExchangeRatesIo(key: string): Promise<ExchangeRatesIoApi> 

See also: ExchangeRatesIoApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMapiCallbackPayload

export function getMapiCallbackPayload(txid: string | Buffer | undefined, response: MapiResponseApi): MapiCallbackPayloadApi 

See also: MapiCallbackPayloadApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMapiJsonResponsePayload

Parses a mAPI mimetype 'application/json' response payload after verifying the envelope signature.

Throws on verification errors.

export function getMapiJsonResponsePayload<T>(response: MapiResponseApi): T 

Returns

parse JSON payload object

Argument Details

  • mAPI
    • response

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMapiPostTxPayload

export function getMapiPostTxPayload(response: MapiResponseApi, txid?: string | Buffer, checkFailure?: boolean): MapiPostTxPayloadApi 

See also: MapiPostTxPayloadApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMapiTxStatusPayload

Validates the mapi response signature and parses payload as transaction status.

Throws an error if payload txid doesn't match requested txid.

Throws an error if payload returnResult is not 'success' or 'failure'.

'failure' indicates the txid is unknown to the service.

'success' indicates the txid is known to the service and status was returned.

export function getMapiTxStatusPayload(txid: string | Buffer | undefined, response: MapiResponseApi): MapiTxStatusPayloadApi 

See also: MapiTxStatusPayloadApi

Argument Details

  • txid
    • hash of transaction whose status was requested

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMerkleProofFromGorillaPool

GorillaPool.io has a mapi transaction status endpoint for mainNet, not for testNet, and does NOT return merkle proofs...

mapiResponse is signed and has txStatus payload. { apiVersion: "", timestamp: "2023-03-23T02:14:39.362Z", txid: "9c31ed1dea4ec1aae0475addc0a74eaed68b718d9983d42b111c387d6696a949", returnResult: "success", resultDescription: "", blockHash: "00000000000000000e155235fd83a8757c44c6299e63104fb12632368f3f0cc9", blockHeight: 700000, confirmations: 84353, minerId: "03ad780153c47df915b3d2e23af727c68facaca4facd5f155bf5018b979b9aeb83", txSecondMempoolExpiry: 0, }

export async function getMerkleProofFromGorillaPool(txid: string | Buffer): Promise<TscMerkleProofApi | undefined> 

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMerkleProofFromMetastreme

metastreme.com has a partially conforming merkleProof implementation.

Both mainNet and testNet are supported.

Proofs incorrectly included a copy of the computed value instead of "*" along right side of merkle tree.

targetType of hash is used which prevents automatic proof checking as the target root value isn't known without a lookup request.

export async function getMerkleProofFromMetastreme(txid: string | Buffer, chain: Chain): Promise<TscMerkleProofApi | undefined> 

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMerkleProofFromTaal

Taal.com has the most functional txStatus and merkleProof endpoint for both mainNet and testNet

Proofs use targetType "header" which is converted to "merkleRoot".

Proofs correctly use duplicate computed node value symbol "*".

An apiKey must be used and must correspond to the target chain: mainNet or testNet.

export async function getMerkleProofFromTaal(txid: string | Buffer, apiKey: string): Promise<TscMerkleProofApi | undefined> 

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMerkleProofFromWhatsOnChain

WhatOnChain.com has their own "hash/pos/R/L" proof format and a more TSC compliant proof format.

The "/proof" endpoint returns an object for each node with "hash" and "pos" properties. "pos" can have values "R" or "L". Normally "pos" indicates which side of a concatenation the provided "hash" goes with one exception! EXCEPTION: When the provided should be "*" indicating edge-of-the-tree-duplicate-computed-value, they include the expected computed value and the pos value is always "L", even when it should really be "R". This only matters if you are trying to compute index from the "R" and "L" values.

export async function getMerkleProofFromWhatsOnChain(txid: string | Buffer, chain: Chain): Promise<TscMerkleProofApi | undefined> 

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getMerkleProofFromWhatsOnChainTsc

WhatOnChain.com has their own "hash/pos/R/L" proof format and a more TSC compliant proof format.

The "/proof/tsc" endpoint is much closer to the TSC specification. It provides "index" directly and each node is just the provided hash value. The "targetType" is unspecified and thus defaults to block header hash, requiring a Chaintracks lookup to get the merkleRoot... Duplicate hash values are provided in full instead of being replaced by "*".

export async function getMerkleProofFromWhatsOnChainTsc(txid: string | Buffer, chain: Chain): Promise<TscMerkleProofApi | undefined> 

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getProofFromGorillaPool

GorillaPool.io MAINNET ONLY

has a mapi transaction status endpoint for mainNet, not for testNet, and does NOT return merkle proofs...

mapiResponse is signed and has txStatus payload. { apiVersion: "", timestamp: "2023-03-23T02:14:39.362Z", txid: "9c31ed1dea4ec1aae0475addc0a74eaed68b718d9983d42b111c387d6696a949", returnResult: "success", resultDescription: "", blockHash: "00000000000000000e155235fd83a8757c44c6299e63104fb12632368f3f0cc9", blockHeight: 700000, confirmations: 84353, minerId: "03ad780153c47df915b3d2e23af727c68facaca4facd5f155bf5018b979b9aeb83", txSecondMempoolExpiry: 0, }

export async function getProofFromGorillaPool(txid: string | Buffer, chain: Chain): Promise<GetMerkleProofResultApi> 

See also: GetMerkleProofResultApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getProofFromMetastreme

metastreme.com has a partially conforming merkleProof implementation.

Both mainNet and testNet are supported.

Proofs incorrectly included a copy of the computed value instead of "*" along right side of merkle tree.

targetType of hash

export async function getProofFromMetastreme(txid: string | Buffer, chain: Chain): Promise<GetMerkleProofResultApi> 

See also: GetMerkleProofResultApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getProofFromTaal

Taal.com has the most functional txStatus and merkleProof endpoint for both mainNet and testNet

Proofs use targetType "header" which is converted to "merkleRoot".

Proofs correctly use duplicate computed node value symbol "*".

An apiKey must be used and must correspond to the target chain: mainNet or testNet.

export async function getProofFromTaal(txid: string | Buffer, apiKey: string): Promise<GetMerkleProofResultApi> 

See also: GetMerkleProofResultApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getProofFromWhatsOnChain

WhatOnChain.com has their own "hash/pos/R/L" proof format and a more TSC compliant proof format.

The "/proof" endpoint returns an object for each node with "hash" and "pos" properties. "pos" can have values "R" or "L". Normally "pos" indicates which side of a concatenation the provided "hash" goes with one exception! EXCEPTION: When the provided should be "*" indicating edge-of-the-tree-duplicate-computed-value, they include the expected computed value and the pos value is always "L", even when it should really be "R". This only matters if you are trying to compute index from the "R" and "L" values.

export async function getProofFromWhatsOnChain(txid: string | Buffer, chain: Chain): Promise<GetMerkleProofResultApi> 

See also: GetMerkleProofResultApi

Links: API, Interfaces, Classes, Functions, Types, Variables


Function: getProofFromWhatsOnChainTsc

WhatOnCha