npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@omni-bridge/btc

v0.1.0

Published

Bitcoin/UTXO transaction builder for Omni Bridge

Readme

@omni-bridge/btc

Bitcoin/UTXO transaction builder for Omni Bridge SDK.

Installation

npm install @omni-bridge/btc
# or
bun add @omni-bridge/btc

Usage

Building Withdrawal Plans

import { createBtcBuilder, type UTXO } from "@omni-bridge/btc"

const btcBuilder = createBtcBuilder({
  network: "mainnet",
})

// Define UTXOs available for withdrawal
const utxos: UTXO[] = [
  {
    txid: "abc123...",
    vout: 0,
    balance: 100000n, // satoshis
    path: "m/84'/0'/0'/0/0",
  },
  {
    txid: "def456...",
    vout: 1,
    balance: 50000n,
    path: "m/84'/0'/0'/0/1",
  },
]

// Build withdrawal plan
const plan = btcBuilder.buildWithdrawalPlan(
  utxos,
  75000n, // amount in satoshis
  "bc1q...", // target address
  "bc1q...", // change address
  5, // fee rate in sat/vB
)

console.log(plan)
// {
//   inputs: ["abc123...:0", "def456...:1"],
//   outputs: [
//     { value: 75000, script_pubkey: "..." },
//     { value: 24500, script_pubkey: "..." }
//   ],
//   fee: 500n
// }

Deposit Proof Generation

import { createBtcBuilder } from "@omni-bridge/btc"

const btcBuilder = createBtcBuilder({ network: "mainnet" })

// Get Merkle proof for a confirmed transaction
const merkleProof = await btcBuilder.getMerkleProof("txid...")
console.log(merkleProof)
// {
//   block_height: 800000,
//   merkle: ["hash1...", "hash2..."],
//   pos: 3
// }

// Get full deposit proof for NEAR verification
const depositProof = await btcBuilder.getDepositProof("txid...", 0)
console.log(depositProof)
// {
//   merkle_proof: [...],
//   tx_block_blockhash: "...",
//   tx_bytes: [...],
//   tx_index: 3,
//   amount: 100000n
// }

UTXO Selection

import { createBtcBuilder, linearFeeCalculator } from "@omni-bridge/btc"

const btcBuilder = createBtcBuilder({ network: "mainnet" })

const normalized = [
  { txid: "abc...", vout: 0, amount: 100000n },
  { txid: "def...", vout: 1, amount: 50000n },
]

const result = btcBuilder.selectUtxos(normalized, 75000n, {
  dustThreshold: 546n,
  minChange: 1000n,
  sort: "largest-first",
  feeCalculator: linearFeeCalculator({
    base: 10,
    input: 68,
    output: 31,
    rate: 5, // sat/vB
  }),
})

Address to Script

const btcBuilder = createBtcBuilder({ network: "mainnet" })

const scriptPubkey = btcBuilder.addressToScriptPubkey(
  "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
)
// "0014..."

Transaction Broadcasting

const btcBuilder = createBtcBuilder({ network: "mainnet" })

// After signing your transaction externally
const txid = await btcBuilder.broadcastTransaction(signedTxHex)
console.log(`Broadcast successful: ${txid}`)

Configuration

interface BtcBuilderConfig {
  network: "mainnet" | "testnet"
  chain?: "btc" | "zcash" // defaults to "btc"
  apiUrl?: string // Blockstream API URL (optional)
  rpcUrl?: string // Bitcoin RPC URL for proofs (optional)
  rpcHeaders?: Record<string, string> // Custom RPC headers (optional)
}

API Reference

createBtcBuilder(config)

Creates a new BtcBuilder instance.

BtcBuilder.buildWithdrawalPlan(utxos, amount, targetAddress, changeAddress, feeRate?, overrides?)

Builds a withdrawal transaction plan with optimal UTXO selection.

BtcBuilder.getDepositProof(txHash, vout)

Generates a deposit proof for verifying BTC deposits on NEAR.

BtcBuilder.getMerkleProof(txHash)

Gets the Merkle inclusion proof for a confirmed transaction.

BtcBuilder.selectUtxos(utxos, amount, options?)

Selects optimal UTXOs for a target amount using largest-first algorithm.

BtcBuilder.addressToScriptPubkey(address)

Converts a Bitcoin address to its script_pubkey (hex encoded).

BtcBuilder.broadcastTransaction(txHex)

Broadcasts a signed transaction to the Bitcoin network.

BtcBuilder.getTransactionBytes(txHash)

Fetches raw transaction bytes for a given txid.

linearFeeCalculator(params)

Creates a fee calculator based on transaction virtual size.

linearFeeCalculator({
  base: 10, // base vbytes
  input: 68, // vbytes per input
  output: 31, // vbytes per output
  rate: 5, // sat/vB
})