# @carnesen/bitcoin-software

> Node.js utilities for installing bitcoin server software

Latest version **0.0.3** (published 2019-02-13) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @carnesen/bitcoin-software
pnpm add @carnesen/bitcoin-software
yarn add @carnesen/bitcoin-software
bun add @carnesen/bitcoin-software
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2019-02-13 |
| First published | 2019-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 7 |
| Unpacked size | 46.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chris Arnesen |
| Maintainers | carnesen |

## Links

- npm: https://www.npmjs.com/package/@carnesen/bitcoin-software
- Repository: https://github.com/carnesen/bitcoin-software
- Issues: https://github.com/carnesen/bitcoin-software/issues
- npm.io page: https://npm.io/package/@carnesen/bitcoin-software

## Dependencies (7)

- [mkdirp](https://npm.io/package/mkdirp.md) 0.5.1
- [rimraf](https://npm.io/package/rimraf.md) 2.6.3
- [download](https://npm.io/package/download.md) 7.1.0
- [@types/mkdirp](https://npm.io/package/@types/mkdirp.md) 0.5.2
- [@types/rimraf](https://npm.io/package/@types/rimraf.md) 2.0.2
- [@types/download](https://npm.io/package/@types/download.md) 6.2.4
- [@carnesen/bitcoin-config](https://npm.io/package/@carnesen/bitcoin-config.md) 0.0.3

## Recent versions

- 0.0.3 (latest) — 2019-02-13
- 0.0.2 — 2019-02-11
- 0.0.0 — 2019-02-09
- 0.0.0-0 — 2019-01-23

## README

# @carnesen/bitcoin-software [![Build Status](https://travis-ci.com/carnesen/bitcoin-software.svg?branch=master)](https://travis-ci.com/carnesen/bitcoin-software)

A Node.js library for installing bitcoin server software

## Install
```
$ npm install @carnesen/bitcoin-software
```
The package includes runtime JavaScript files suitable for Node.js >=8 as well as the corresponding TypeScript type declarations.

## Usage

Here is an example of a script that installs Bitcoin Core:

```ts
// example.ts
const { installSoftware } = require('@carnesen/bitcoin-software');
const { homedir } = require('os');

(async () => {
  console.log('Installing Bitcoin Core ...');
  const { changed, bitcoinHome } = await installSoftware({
    implementation: 'core',
    version: '0.17.1',
    destination: homedir(),
  });
  const message = changed
    ? `Installed Bitcoin Core to ${bitcoinHome}`
    : `Bitcoin Core is already installed at ${bitcoinHome}`;
  console.log(message);
})();
```

Here what that script looks like when run:
```
$ ts-node example.ts
Installing Bitcoin Core ...
Installed Bitcoin Core to /Users/carnesen/bitcoin-core-0.17.1

$ ts-node example.ts
Installing Bitcoin Core ...
Bitcoin Core is already installed at /Users/carnesen/bitcoin-core-0.17.1
```

The script would be the same in JavaScript just with the `import ... from` statements replaced by `const ... require` ones.

## API

### installSoftware({implementation?, destination?, version?}): Promise<{changed, bitcoinHome}>
Downloads and unpacks a tarball of bitcoin server software

#### implementation
Optional `string`. Defaults to `'core'`. Supported values:
- `'core'`: Download from [https://bitcoincore.org/bin/](https://bitcoincore.org/bin/)
- `'abc'`: Download from [https://download.bitcoinabc.org/](https://download.bitcoinabc.org/)

#### version
Optional `string`. Default value is implementation-dependent, e.g. `'0.17.1'` for Bitcoin Core.

#### destination
Optional `string`. Defaults to `'software'`. An absolute or datadir-relative path of a directory below which the software will be installed. 

#### changed
`boolean`. `installSoftware` is [idempotent](https://en.wikipedia.org/wiki/Idempotence) in the sense that it does not modify an existing installation if there is one, nor does it throw. If `installSoftware` actually downloads and extracts the tarball to `destination`, it returns an object with `changed` set to `true`. If `install` finds the software already installed, it returns an object with `changed` set to `false`.

#### bitcoinHome
`string`. Absolute directory path at which the software is installed. Effectively:
```ts
bitcoinHome = `${destination}/bitcoin-${implementation}-${version}` 
```

### uninstallSoftware({implementation?, destination?, version?}): Promise<{changed, bitcoinHome}>
Uninstalls bitcoin server software from the specified destination. Parameters and return values are the same as described above for [`installSoftware`](#installsoftware) above.

## More information
This library has a number of unit tests with ~100% coverage. Check out [the tests directory](src/__tests__) 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](https://github.com/carnesen/bitcoin-software/issues/new) or [submit a pull request](https://github.com/carnesen/bitcoin-software/compare) on [this project's repository on GitHub](https://github.com/carnesen/bitcoin-software).

## Related
- [@carnesen/bitcoin-software-cli](https://github.com/carnesen/bitcoin-software-cli): A Node.js command-line interface for managing bitcoin server software
- [@carnesen/bitcoin-config](https://github.com/carnesen/bitcoin-config): A Node.js library for bitcoin server software configuration
- [@carnesen/bitcoin-service](https://github.com/carnesen/bitcoin-service): A Node.js library for managing the bitcoin server process `bitcoind`

## License

MIT © [Chris Arnesen](https://www.carnesen.com)

---
_Source: https://npm.io/package/@carnesen/bitcoin-software · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
