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

    Class ElectrumOnchainProvider

    Electrum-based implementation of the OnchainProvider interface. Replaces esplora polling with electrum subscriptions where possible.

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

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

    const coins = await provider.getCoins("bc1q...");

    Implements

    Index

    Constructors

    Methods

    • Broadcast a single transaction or a TRUC (BIP 431) 1P1C package atomically.

      Server requirements for 1P1C packages: the backing Electrum server must implement blockchain.transaction.broadcast_package (Fulcrum ≥ 1.10) and be backed by bitcoind ≥ v28.0.0. ElectrumX does not implement this method. There is no fallback to sequential parent-then-child broadcast: TRUC packages typically have a zero-fee parent and would be rejected from the mempool on their own, so a fallback would silently fail in subtle ways. Callers receiving a "method not found" error here should route through a different provider for that submission.

      Parameters

      • ...txs: string[]

        One transaction (single broadcast) or two topologically-sorted transactions (parent first, child last) for 1P1C package relay.

      Returns Promise<string>

      The broadcast txid (or the child txid for 1P1C packages).

    • Fetch the current chain tip.

      Returns Promise<{ hash: string; height: number; time: number }>

      Current chain height, block time, and block hash

    • Fetch spendable onchain outputs for an address.

      Parameters

      • address: string

        Bitcoin address to query

      Returns Promise<Coin[]>

      Spendable onchain outputs for the address

      Coin

    • Fetch the current fastest fee rate estimate.

      Returns Promise<number | undefined>

      Fee rate in sats/vB, if available

      Implementations may return undefined when the backing service does not expose a usable fee estimate.

    • Fetch outspend information for every output in a transaction.

      Parameters

      • txid: string

        Transaction id to inspect

      Returns Promise<{ spent: boolean; txid: string }[]>

      Per-output spend status information

      getTxStatus

    • Fetch confirmation status for a transaction.

      Parameters

      • txid: string

        Transaction id to inspect

      Returns Promise<
          | { confirmed: false }
          | { blockHeight: number; blockTime: number; confirmed: true },
      >

      Confirmation status and block metadata when confirmed

      getTxOutspends

    • Watch a set of addresses and invoke the callback when transactions are observed.

      Parameters

      • addresses: string[]

        Addresses to monitor

      • eventCallback: (txs: ExplorerTransaction[]) => void

        Callback invoked when matching transactions are seen

      Returns Promise<() => void>

      Stop function that cancels the watch

      Implementations may use websockets, server-sent events, polling, or a hybrid strategy.

      getTransactions