@arkade-os/sdk Documentation - v0.4.21
    Preparing search index...

    Class WsElectrumChainSource

    WebSocket-based Electrum chain source using ws-electrumx-client. Provides low-level methods for the Electrum protocol.

    import { ElectrumWS } from "ws-electrumx-client";
    import { WsElectrumChainSource } from "./providers/electrum";
    import { networks } from "./networks";

    const ws = new ElectrumWS("wss://electrum.blockstream.info:50004");
    const chain = new WsElectrumChainSource(ws, networks.bitcoin);

    const history = await chain.fetchHistories([script]);
    await chain.close();
    Index

    Constructors

    Methods

    • Get the address string for a script output, if decodable.

      Parameters

      • scriptHex: string

      Returns string | undefined

    • Submit a package of raw transactions atomically via Fulcrum's blockchain.transaction.broadcast_package method, the on-the-wire equivalent of bitcoind's submitpackage RPC.

      Required for TRUC (BIP 431) 1P1C relay where the parent has zero (or below-minfee) fee and depends on the child to pay for both via CPFP — sequential broadcast cannot work in that case because the parent would be rejected from the mempool on its own.

      Parameters

      • txHexes: string[]

        Topologically sorted raw transactions; child must be the last element. Currently must be a 1P1C pair (length 2). Parents may not depend on each other.

      Returns Promise<string>

      The child transaction id (the last entry in the array), computed locally — broadcast_package itself returns {success, errors} rather than a txid.

      If the server does not implement broadcast_package (e.g. ElectrumX, or older Fulcrum, or Fulcrum backed by bitcoind < v28.0.0). Callers must surface this clearly to users — this method does NOT silently fall back to sequential broadcasts because doing so would let TRUC packages fail in subtle ways.

      If the server returns success=false, surfacing the underlying mempool rejection in the error message.

    • Parameters

      • txHex: string

      Returns Promise<string>

    • Parameters

      • targetNumberBlocks: number

      Returns Promise<number>

    • Parameters

      • txids: string[]

      Returns Promise<{ hex: string; txID: string }[]>

    • Parameters

      • txid: string

      Returns Promise<VerboseTransaction>

    • Parameters

      • txids: string[]

      Returns Promise<VerboseTransaction[]>

    • Returns the current chain tip and keeps it fresh via a single server-side subscription. Subsequent calls return the cached tip (updated by background notifications) without round-tripping to the server. Previously each call issued blockchain.headers.subscribe as a regular request, leaving a stale subscription on the server every time — under polling that adds up. ws-electrumx-client deduplicates subscribe() by method+params, so registering once is enough.

      Returns Promise<HeaderSubscribeResult>

    • Parameters

      • script: Uint8Array
      • callback: (scripthash: string, status: string | null) => void

      Returns Promise<void>

    • Parameters

      • script: Uint8Array

      Returns Promise<void>

    • Parameters

      • addr: string

      Returns Promise<void>