UNPKG

@bsv/overlay

Version:
110 lines 3.24 kB
import { MerklePath } from '@bsv/sdk'; export declare const BASM_ZERO_HASH = "0000000000000000000000000000000000000000000000000000000000000000"; export interface TopicBlockAnchor { topic: string; blockHeight: number; blockHash: string; basmRoot: string; admittedCount: number; tac: string; } export interface TopicAnchorTip { topic: string; blockHeight: number; blockHash?: string; basmRoot?: string; admittedCount?: number; tac: string; } export interface AdmittedTxRef { txid: string; blockIndex: number; } export interface RawTransactionRecord { txid: string; rawTx: string; } export interface RawTransactionRequest { txids: string[]; } export interface RawTransactionResponse { transactions: RawTransactionRecord[]; missing: string[]; } export interface TopicAnchorHeader { blockHeight: number; blockHash: string; merkleRoot?: string; } export type TopicAnchorHeaderResolver = (blockHeight: number) => Promise<TopicAnchorHeader | undefined>; export interface TopicAnchorRangeRequest { fromHeight: number; toHeight: number; } export interface TopicAnchorRangeResponse { topic: string; anchors: TopicBlockAnchor[]; } export interface AdmittedListRequest { blockHeight: number; blockHash?: string; } export interface AdmittedListResponse { topic: string; blockHeight: number; blockHash?: string; admitted: AdmittedTxRef[]; } export interface CompoundMerklePathRequest { blockHeight: number; txids: string[]; } export interface CompoundMerklePathResponse { topic: string; blockHeight: number; txids: string[]; merklePath: string; } export interface MerkleProofMetadata { blockHeight: number; blockIndex: number; merkleRoot: string; } export interface ReorgReport { perTopic: Array<{ topic: string; demotedTxids: string[]; rebuiltFrom: number; rebuiltTo: number; }>; } export interface BASMPeerSyncReport { topic: string; endpoint: string; status: 'matched' | 'advanced' | 'diverged' | 'skipped' | 'error'; localTip?: TopicAnchorTip; remoteTip?: TopicAnchorTip; checkedHeights: number[]; missingTxids: string[]; fetchedTxCount: number; message?: string; } type AdmittedTxLike = string | AdmittedTxRef; /** * Computes a BRC-136 BASM root from admitted topic txids. * * The API accepts normal display-order txid hex because that is what the BSV * TypeScript stack exposes at its public boundaries. Hashing is performed on * internal byte order as required by the BRC, and the returned root is display * order for JSON/wire compatibility. */ export declare function computeBasmRoot(admitted: AdmittedTxLike[]): string; /** * Computes the BRC-136 cumulative Topic Anchor Chain hash: * SHA256d(prevTac || blockHash || basmRoot), with all inputs reversed to * internal byte order before hashing and the output returned as display hex. */ export declare function computeTac(prevTac: string, blockHash: string, basmRoot: string): string; export declare function extractMerkleProofMetadata(txid: string, proof?: MerklePath): MerkleProofMetadata | undefined; export {}; //# sourceMappingURL=BASM.d.ts.map