NBXplorer Client
A NodeJS client for NBXplorer.
npm install nbxplorer-client
NBXplorer Version
The following version combinations have been tested and work together.
- 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 = uri: 'https://nbx.example.com' cryptoCode: 'btc';// healthCheck will work without cookieFilePath regardless of noauth state// It does not require auth no matter whatconst healthCheckResponse = await cli;
Bare minimum no-wallet methods
const cli = uri: 'https://nbx.example.com' cryptoCode: 'btc' cookieFilePath: '/home/user/.nbxplorer/Main/.cookie' // Only if noauth is not active;const txData = await cli;const nbxStatus = await cli;// 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;// This will actually broadcastconst broadcastTxResponse = await cli;await cli; // See NBX docsconst feeRate = await cli;const events = await cli;const updatedPsbt = await cli// updatedPsbt will be the merged PSBT// creating PSBT will require an HD wallet though
Tracking address
const cli = uri: 'https://nbx.example.com' cryptoCode: 'btc' address: '14bnuyjuP5US5JKXc1YuVK8XDe7E3Dnanc' cookieFilePath: '/home/user/.nbxplorer/Main/.cookie';await cli; // MUST DO ONCE PER LIFETIME OF THE WALLET
Tracking HD (multisig OK)
SEE API DOCS FOR derivationScheme FORMAT
const cli = uri: 'https://nbx.example.com' cryptoCode: 'btc' derivationScheme: 'xpub6DJ5JT2drRS1kTaPGfRrCXdFnG1BCGkzjvStYQYMHFBAumFsMAmxb3ZQBXA1W43zix17okdUoTKSeLkK8vPVUz5cMzFmFBacPJ7EmtX8JUw-[legacy]' cookieFilePath: '/home/user/.nbxplorer/Main/.cookie';await cli; // MUST DO ONCE PER LIFETIME OF THE WALLET
Wallet methods (address OR derivationScheme)
const txes = await cliconst tx = await cli // must be related to walletconst utxos = await cli
Wallet methods (derivationScheme ONLY)
const addressInfo = await cliconst keyInfo = await cli // must be related to walletawait cli // starts a scan of the utxo set (/utxo/scan endpoint)const status = await cli // 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 privacyconst psbtData = await cliawait cli;const meta = await cli; // meta is an object with key `key` and value of type value passed to addMetaawait cli;await cli; // prunes transactions of spent txos.