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

nbxplorer-client

v2.1.0

Published

A NodeJS client library for controlling NBXplorer

Downloads

54

Readme

NBXplorer Client

A NodeJS client for NBXplorer.

npm install nbxplorer-client

NBXplorer Version

The following version combinations have been tested and work together.

  1. NBXplorer.NodeJS v2.0.0 === NBXplorer v2.0.0.67 (github commit 99ca6e4)

Usage

FIRST READ THE NBXplorer DOCs AND UNDERSTAND HOW THE API WORKS

derivationScheme vs. derivationSchemeInternal

When using LTC Ltub (old xpub version for LTC) NBXplorer converts to xpub in the backend. So if using derivationScheme to filter events from getEvents etc. please use the derivationSchemeInternal.

HealthCheck

const cli = new NBXClient({
  uri: 'https://nbx.example.com',
  cryptoCode: 'btc',
});
// healthCheck will work without cookieFilePath regardless of noauth state
// It does not require auth no matter what
const healthCheckResponse = await cli.healthCheck();

Bare minimum no-wallet methods

const cli = new NBXClient({
  uri: 'https://nbx.example.com',
  cryptoCode: 'btc',
  cookieFilePath: '/home/user/.nbxplorer/Main/.cookie', // Only if noauth is not active
});
const txData = await cli.getTransactionNoWallet(txid);
const nbxStatus = await cli.getStatus();
// Adding an optional true will return the broadcast response without actually broadcasting
// Good for checking the validity of a tx that you wish to broadcast at a later date.
const broadcastTxResponse = await cli.broadcastTx(txBuffer, true);
// This will actually broadcast
const broadcastTxResponse = await cli.broadcastTx(txBuffer);
await cli.rescanTx([txArg, txArg, txArg]); // See NBX docs
const feeRate = await cli.getFeeRate(blockCount);
const events = await cli.getEvents();
const updatedPsbt = await cli.updatePsbt({ psbt: 'base64 string' })
// updatedPsbt will be the merged PSBT
// creating PSBT will require an HD wallet though

Tracking address

const cli = new NBXClient({
  uri: 'https://nbx.example.com',
  cryptoCode: 'btc',
  address: '14bnuyjuP5US5JKXc1YuVK8XDe7E3Dnanc',
  cookieFilePath: '/home/user/.nbxplorer/Main/.cookie',
});
await cli.track(); // MUST DO ONCE PER LIFETIME OF THE WALLET

Tracking HD (multisig OK)

SEE API DOCS FOR derivationScheme FORMAT

const cli = new NBXClient({
  uri: 'https://nbx.example.com',
  cryptoCode: 'btc',
  derivationScheme: 'xpub6DJ5JT2drRS1kTaPGfRrCXdFnG1BCGkzjvStYQYMHFBAumFsMAmxb3ZQBXA1W43zix17okdUoTKSeLkK8vPVUz5cMzFmFBacPJ7EmtX8JUw-[legacy]',
  cookieFilePath: '/home/user/.nbxplorer/Main/.cookie',
});
await cli.track(); // MUST DO ONCE PER LIFETIME OF THE WALLET

Wallet methods (address OR derivationScheme)

const txes = await cli.getTransactions()
const tx = await cli.getTransaction(txid) // must be related to wallet
const utxos = await cli.getUtxos()

Wallet methods (derivationScheme ONLY)

const addressInfo = await cli.getAddress()
const keyInfo = await cli.getExtPubKeyFromScript(scriptPubKeyHex) // must be related to wallet
await cli.scanWallet() // starts a scan of the utxo set (/utxo/scan endpoint)
const status = await cli.getScanStatus() // get status of scan
// createPsbt will throw an error if fee info is not available, use fallbackFeeRate just in case
// if you don't pass disableFingerprintRandomization: true, then rbf, discourageFeeSniping, version, and lockTime
// will be randomized for privacy
const psbtData = await cli.createPsbt({destinations: [{ destination: address }]})
await cli.addMeta(key, value);
const meta = await cli.getMeta(key); // meta is an object with key `key` and value of type value passed to addMeta
await cli.removeMeta(key);
await cli.prune(); // prunes transactions of spent txos.