Code Monkey home page Code Monkey logo

bitcoin-service's Introduction

@carnesen/bitcoin-service npm version Build Status

A Node.js library for managing the bitcoin service bitcoind. The package includes runtime JavaScript files suitable for Node.js >=8 as well as the corresponding TypeScript type declarations.

Usage

Here is a little TypeScript Node.js script that starts bitcoind:

// example.ts
import { startService } from '@carnesen/bitcoin-service';
const bitcoinHome = '/usr/local/bitcoin-0.17.1';
(async () => {
  try {
    await startService({ bitcoinHome });
    process.exit(0);
  } catch (ex) {
    console.log(ex);
    process.exit(1);
  }
})()

Running the script looks like:

$ ts-node example.ts
Bitcoin server starting

API

startService(configFilePath, bitcoinHome?): Promise<{changed}>

Sets daemon to true in the configuration file and starts bitcoind if it's not running already

configFilePath

string. Absolute path of a bitcoin configuration file. Will be created if it does not already exist.

bitcoinHome

Optional string. Absolute path of a directory where the bitcoin server software is installed. If not provided, `${bitcoinHome}/bin` must be on your PATH.

changed

boolean. Is false if bitcoind was already running, true if the service was successfully started.

stopService(configFilePath): Promise<{changed}>

Stops bitcoind if it's running

changed

boolean. Is false if bitcoind wasn't running. Is true if the service was running and successfully stopped.

restartService(configFilePath, bitcoinHome?): Promise<{changed}>

Stops and starts bitcoind as documented above.

isServiceRunning(configFilePath): Promise<boolean>

The returned promise resolves to true if the service is running or false if it is not.

More information

Check out the tests directory for more examples of how it works. If you encounter any bugs or have any questions or feature requests, please don't hesitate to file an issue or submit a pull request on this project's repository on GitHub.

Related

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.