Get the address string for a script output, if decodable.
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.
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.
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.
Look up the block height of a confirmed transaction without relying
on the verbose-tx endpoint. blockchain.transaction.get_merkle is
part of the standard SPV protocol and is supported by both Fulcrum
and electrs (whereas blockchain.transaction.get with verbose=true
is Fulcrum-only). Returns null when the tx is in the mempool —
electrs in that case rejects with a "not yet in a block" error.
Send N requests in parallel and aggregate the results, replacement
for ws.batchRequest. The library's batchRequest is implemented as
Promise.all over individual request promises — when one element
rejects, the others remain pending. When their (often error)
responses arrive later, the library rejects them too, and nobody is
awaiting them: the rejections become unhandled and crash the test
runner / pollute production logs.
safeBatchRequest issues each request through ws.request (so each
has its own request-promise lifecycle), waits for all of them via
Promise.allSettled (every promise gets an explicit handler), and
then surfaces the first error if any failed. Same wall-clock cost
as the library's batch (parallel send), no orphan rejections.
Use this in place of ws.batchRequest for any call where one or
more elements may legitimately error (e.g. electrs index lag
surfacing as missingheight for a subset of heights/txids).
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.
WebSocket-based Electrum chain source using ws-electrumx-client. Provides low-level methods for the Electrum protocol.
Example