# btc-node-pay

> lib for receiving bitcoin payments, nodejs, bitcoind node

Latest version **0.0.2** (published 2018-10-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install btc-node-pay
pnpm add btc-node-pay
yarn add btc-node-pay
bun add btc-node-pay
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2018-10-30 |
| First published | 2018-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 73.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Richard Bondi |
| Maintainers | rsbondi |

## Links

- npm: https://www.npmjs.com/package/btc-node-pay
- Repository: https://github.com/rsbondi/btc-node-pay
- Homepage: https://github.com/rsbondi/btc-node-pay#readme
- Issues: https://github.com/rsbondi/btc-node-pay/issues
- npm.io page: https://npm.io/package/btc-node-pay

## Dependencies (4)

- [bcoin](https://npm.io/package/bcoin.md) ^1.0.2
- [bech32](https://npm.io/package/bech32.md) ^1.1.3
- [promise](https://npm.io/package/promise.md) ^8.0.1
- [sqlite3](https://npm.io/package/sqlite3.md) ^4.0.2

## Recent versions

- 0.0.2 (latest) — 2018-10-30
- 0.0.1 — 2018-10-30

## README

### Overview

WIP - this should be usable, but not tested, testers welcome

This is a simple class to receive bitcoin payments using xpub.  Addresses are tracked
and expired addresses are re-used.  Defaults to sqlite but can be used with any db by providing
proper db class.  You are the payment processor so you process directly in your apps without
appearing to go to a third party.  Example use case would be to embed a qr code for donations
on a web page but with no address re-use.  An event is raised when a payment is received.

This is receive only and is not meant to be a complete wallet back end, you use the wallet of 
your choice and generate an xpub, and use this library to automate generation of addresses for 
receiving funds in your app.

### Requirements

nodejs and a fully synced bitcoin core node

### Usage

```javascript
const Payment = require('btc-node-pay')
const network = 'testnet'
const xpub = "xpub..."
const paytrack = new Payment(xpub, host, network)

paytrack.on('payment_received', p => {
  // do something meaningful
})
```


see `example` directory in repository for more usage info

### Limitations

* At least one block needs to be mined before shutdown to track properly on startup
* Currently does not handle reorg so you may end up with addresses not used if logged beforehand

### Defining additional database types

The default database is sqlite.  You can create a simple database class for use with any database by creating the class and implementing the methods.  See the `sqlite.js` file for methods and types.  Methods beginning with underscore do not need to be implemented.

---
_Source: https://npm.io/package/btc-node-pay · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
