UNPKG

@bsv/wallet-toolbox-client

Version:
130 lines 5.21 kB
import { Beef, HexString, WhatsOnChainConfig } from '@bsv/sdk'; import SdkWhatsOnChain from './SdkWhatsOnChain'; import { Chain } from '../../sdk/types'; import { BlockHeader, BsvExchangeRate, GetMerklePathResult, GetRawTxResult, GetScriptHashHistoryResult, GetStatusForTxidsResult, GetUtxoStatusOutputFormat, GetUtxoStatusResult, PostBeefResult, PostTxResultForTxid, WalletServices } from '../../sdk/WalletServices.interfaces'; import { Services } from '../Services'; export declare class WhatsOnChainNoServices extends SdkWhatsOnChain { constructor(chain?: Chain, config?: WhatsOnChainConfig); /** * POST * https://api.whatsonchain.com/v1/bsv/main/txs/status * Content-Type: application/json * data: "{\"txids\":[\"6815f8014db74eab8b7f75925c68929597f1d97efa970109d990824c25e5e62b\"]}" * * result for a mined txid: * [{ * "txid":"294cd1ebd5689fdee03509f92c32184c0f52f037d4046af250229b97e0c8f1aa", * "blockhash":"000000000000000004b5ce6670f2ff27354a1e87d0a01bf61f3307f4ccd358b5", * "blockheight":612251, * "blocktime":1575841517, * "confirmations":278272 * }] * * result for a valid recent txid: * [{"txid":"6815f8014db74eab8b7f75925c68929597f1d97efa970109d990824c25e5e62b"}] * * result for an unknown txid: * [{"txid":"6815f8014db74eab8b7f75925c68929597f1d97efa970109d990824c25e5e62c","error":"unknown"}] */ getStatusForTxids(txids: string[]): Promise<GetStatusForTxidsResult>; /** * 2025-02-16 throwing internal server error 500. * @param txid * @returns */ getTxPropagation(txid: string): Promise<number>; /** * May return undefined for unmined transactions that are in the mempool. * @param txid * @returns raw transaction as hex string or undefined if txid not found in mined block. */ getRawTx(txid: string): Promise<string | undefined>; getRawTxResult(txid: string): Promise<GetRawTxResult>; /** * WhatsOnChain does not natively support a postBeef end-point aware of multiple txids of interest in the Beef. * * Send rawTx in `txids` order from beef. * * @param beef * @param txids * @returns */ postBeef(beef: Beef, txids: string[]): Promise<PostBeefResult>; /** * @param rawTx raw transaction to broadcast as hex string * @returns txid returned by transaction processor of transaction broadcast */ postRawTx(rawTx: HexString): Promise<PostTxResultForTxid>; updateBsvExchangeRate(rate?: BsvExchangeRate, updateMsecs?: number): Promise<BsvExchangeRate>; getUtxoStatus(output: string, outputFormat?: GetUtxoStatusOutputFormat, outpoint?: string): Promise<GetUtxoStatusResult>; getScriptHashConfirmedHistory(hash: string): Promise<GetScriptHashHistoryResult>; getScriptHashUnconfirmedHistory(hash: string): Promise<GetScriptHashHistoryResult>; getScriptHashHistory(hash: string): Promise<GetScriptHashHistoryResult>; /** { "hash": "000000000000000004a288072ebb35e37233f419918f9783d499979cb6ac33eb", "confirmations": 328433, "size": 14421, "height": 575045, "version": 536928256, "versionHex": "2000e000", "merkleroot": "4ebcba09addd720991d03473f39dce4b9a72cc164e505cd446687a54df9b1585", "time": 1553416668, "mediantime": 1553414858, "nonce": 87914848, "bits": "180997ee", "difficulty": 114608607557.4425, "chainwork": "000000000000000000000000000000000000000000ddf5d385546872bab7dc01", "previousblockhash": "00000000000000000988156c7075dc9147a5b62922f1310862e8b9000d46dd9b", "nextblockhash": "00000000000000000112b36a37c10235fa0c991f680bc5482ba9692e0ae697db", "nTx": 0, "num_tx": 5 } */ getBlockHeaderByHash(hash: string): Promise<BlockHeader | undefined>; getChainInfo(): Promise<WocChainInfo>; } /** * */ export declare class WhatsOnChain extends WhatsOnChainNoServices { services: Services; constructor(chain?: Chain, config?: WhatsOnChainConfig, services?: Services); /** * @param txid * @returns */ getMerklePath(txid: string, services: WalletServices): Promise<GetMerklePathResult>; } export interface WocChainInfo { chain: string; blocks: number; headers: number; bestblockhash: string; difficulty: number; mediantime: number; verificationprogress: number; pruned: boolean; chainwork: string; } export interface WocHeader { hash: string; size: number; height: number; version: number; versionHex: string; merkleroot: string; time: number; mediantime: number; nonce: number; bits: number | string; difficulty: number; chainwork: string; previousblockhash: string; confirmations: number; txcount: number; nextblockhash: string; } export declare function convertWocToBlockHeaderHex(woc: WocHeader): BlockHeader; export declare function getWhatsOnChainBlockHeaderByHash(hash: string, chain?: Chain, apiKey?: string): Promise<BlockHeader | undefined>; //# sourceMappingURL=WhatsOnChain.d.ts.map