Registry / auth-security / bitcore-lib

bitcore-lib

JSON →
library10.10.7jsnpmunverified

A pure and powerful JavaScript Bitcoin library providing core Bitcoin primitives such as addresses, transactions, HD keys (BIP32), and message signing. Current stable version is 10.10.7. Maintained as part of the Bitcore ecosystem by BitPay/Bitcore, it is primarily used for building Bitcoin-related Node.js applications. It offers a comprehensive API for creating and parsing transactions, managing keys, and interacting with the Bitcoin network. Key differentiators include full support for BIP21, BIP32, BIP37, and BIP69, and its integration with the Bitcore full node and Insight block explorer.

npm install bitcore-lib
INSTALL
IMPORT
SIG · BITCORE-LIB
B
bitcore-lib
auth-securityjavascriptv10.10.7
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

bitcore
import bitcore from 'bitcore-lib'
const bitcore = require('bitcore-lib')
ESM default import; if using CommonJS, use require('bitcore-lib').default.
PrivateKey
import { PrivateKey } from 'bitcore-lib'
import PrivateKey from 'bitcore-lib/PrivateKey'
Named export for PrivateKey.
Transaction
import { Transaction } from 'bitcore-lib'
const Transaction = require('bitcore-lib').Transaction
Named export; CommonJS users should destructure from the module.
Address
import { Address } from 'bitcore-lib'
import Address from 'bitcore-lib/lib/address'
Do not import from direct path; use the package root.

Generate a key pair, create and sign a Bitcoin transaction from a UTXO.

import bitcore from 'bitcore-lib'; // Generate a new private key const privateKey = new bitcore.PrivateKey(); // Derive the public key and address const publicKey = privateKey.toPublicKey(); const address = publicKey.toAddress(); console.log('Private Key:', privateKey.toString()); console.log('Address:', address.toString()); // Create a simple transaction (unsigned) const utxo = { address: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', txId: 'a477af6b2667c29670467e4e0728b685ee07b240235771b3181b3c3c0f3f3a0b', outputIndex: 0, script: '76a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac', satoshis: 10000 }; const tx = new bitcore.Transaction() .from(utxo) .to('1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2', 9000) .change(address) .fee(1000) .sign(privateKey); console.log('Raw transaction:', tx.toString());
Debug
Known issues
breakingv8.0.0 removed the 'bitcore' namespace; methods are now top-level exports.
fix
Use named imports like import { PrivateKey } from 'bitcore-lib' instead of bitcore.PrivateKey.
affects: >=8.0.0 <10.0.0
breakingv10.0.0 changed default ESM module; require() no longer works without .default.
fix
Use import bitcore from 'bitcore-lib' or const bitcore = require('bitcore-lib').default.
affects: >=10.0.0
deprecatedbitcore.HDPublicKey and bitcore.HDPrivateKey are deprecated in favor of bitcore.HDKey.
fix
Use bitcore.HDKey.fromExtendedKey() instead.
affects: >=9.0.0
gotchaTransaction signing mutates the Transaction object; always sign last.
fix
Call sign() only after all inputs/outputs are set.
affects: *
Errors
Common errors & fixes
Cannot find module 'bitcore-lib'
Package not installed or not in node_modules.
fix
Run npm install bitcore-lib
TypeError: Right-hand side of 'instanceof' is not an object
Multiple instances of bitcore-lib loaded (e.g., via peer dependencies).
fix
Ensure only one version of bitcore-lib is installed; use npm dedupe or check package.json.
Error: Invalid hex string
Hex string passed to Transaction.from() is malformed or has wrong length.
fix
Provide a valid hex string (e.g., raw transaction) or use Buffer.from(hex, 'hex').
Error: Transaction input satoshis do not add up to the outputs
UTXO satoshis provided do not equal output satoshis plus fee.
fix
Ensure total(inputs) = total(outputs) + fee. Check utxo.satoshis and .to() amounts.
Upgrade
Version history
10.10.7latest on npm
Audit
Dependencies
bn.jsrequiredBig number arithmetic for Bitcoin values and EC operations.
ellipticrequiredElliptic curve cryptography (secp256k1).
bs58requiredBase58 encoding for Bitcoin addresses and keys.
bitcore-messageoptionalMessage signing and verification (peer dependency).
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
bitcore-lib — npm install bitcore-lib · libregistry