28.0.0 • Published 1 year ago
bitcoin-cli-ts v28.0.0
bitcoin-cli-ts
Auto-generated Bitcoin client library for Bitcoin Core JSON-RPC API
Installation
Install the package with:
npm i bitcoin-cli-ts
# or
yarn add bitcoin-cli-tsUsage
Choose the version that corresponds to your Bitcoin Core version.
We use the major and minor versions from Bitcoin Core Releases and reserve the patch version for library fixes related to static code or dependencies.
Config
import { authenticatedBitcoind } from 'bitcoin-cli-ts'
const { host, username, password, port } = getBitcoinCoreRPCConfig()
const bitcoind = authenticatedBitcoind({
protocol: 'http',
host: host,
username,
password,
timeout: 30000,
port: parseInt(port, 10),
walletName: wallet, // optional
})Use rpc command
import { getBalance } from 'bitcoin-cli-ts'
const balance = await getBalance({ bitcoind })Test
Test with Jest framework:
yarn testBuild
Build production (distribution) files in dist folder:
yarn buildIt generates CommonJS (in dist/cjs folder), ES Modules (in dist/esm folder), as well as TypeScript declaration files (in dist/types folder).
Local development
Run:
yarn link
# or
npm linkand in your test project run:
yarn link bitcoin-cli-ts
# or
npm link bitcoin-cli-tsIf you want to remove the symlink, run:
# in your test project
yarn unlink bitcoin-cli-ts
# or
npm unlink bitcoin-cli-ts
# in bitcoin-cli-ts folder
yarn unlink
# or
npm unlinkPlease check more details in npm link or yarn link
References
This library was developed based on: