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 🙏

© 2024 – Pkg Stats / Ryan Hefner

one-dollar-fee-estimator-failover

v0.1.1

Published

A script estimating the minimum feerate required for the inclusion of a bitcoin transaction into the next block.

Downloads

109

Readme

The $1 Fee Estimator

@samouraiwallet/one-dollar-fee-estimator

This library is a Typescript port of the original Python library - The $1 Fee Estimator.

The $1 Fee Estimator is an algorithm designed to return a feerate:

  • allowing the confirmation of a Bitcoin transaction by the next block,
  • lower than the median feerate paid by the transactions included in the next block.

Despite its simplicity, the $1 Fee Estimator requires very few data to perform well and is less than 200 lines of code, making it easy to deploy or to implement in all programming languages.

See original README to understand how this algorithm works.

Requirements

  • Node.js v16 or newer
  • NPM (or yarn or pnpm)
  • Synchnonized Bitcoin Core with accessible RPC

Installation

npm i @samouraiwallet/one-dollar-fee-estimator

# or globally

npm i -g @samouraiwallet/one-dollar-fee-estimator

Usage

This library can be used both as a CLI tool (like original version) or it can be plugged to your existing Node.js project. Since it is very lighweight in bundled code as well as required dependencies, it doesn't consume any unnecessary resources.

In order to avoid blocking the main event loop, estimator spawns its own worker thread which makes desired computations.

Node.js

import {FeeEstimator} from '@samouraiwallet/one-dollar-fee-estimator';

let receivedFees; // variable you want to store received fee rates in

const estimator = new FeeEstimator({
    mode: 'txs', // 'txs' | 'bundles' - optional, default 'txs'
    refresh: 30, // optional, default 30 - interval in seconds, setting too low can cause unexpected errors
    rpcOptions: {
        host: 'localhost',
        port: 8332,
        username: 'rpcUsername',
        password: 'rpcPassword'
    }
})

// handle errors emitted by FeeEstimator
estimator.on('error', (err) => {
    console.error(err)
})

// receive live fee rate updates from the FeeEstimator
estimator.on('fees', (fees) => {
    // fee rates received from FeeEstimator
    // array of four numbers: [number, number, number, number]
    // these fee rates correspond to the targets of [0.5, 0.9, 0.99, 0.999] (probabilities for fee rates for next block)
    receivedFees = fees;
})

// or just read last fee rates directly from the estimator
receivedFees = estimator.feeRates;

// FeeEstimator will continue working until you stop it, or the process is terminated
estimator.stop()

CLI

node dist/bin.js --connection <host>:<port> --username <username> --password <password> [--mode <mode>] [--refresh <delay>]

# OR when installed via NPM globally

one-dollar-fee-estimator --connection <host>:<port> --username <username> --password <password> [--mode <mode>] [--refresh <delay>]

[-c OR --connection] = Connection string to bitcoind RPC API. Must be of the form <host>:<port>

[-u OR --username] = Username used to access bitcoind RPC API.

[-p OR --password] = Password used to access bitcoind RPC API.

[-m OR --mode] = Mode used for the estimate (value = txs | bundles).

[-r OR --refresh] = Delay in seconds between 2 iterations of the computation.