https://github.com/rsbondi/btc-node-pay
lib for receiving bitcoin payments, nodejs, bitcoind node
https://github.com/rsbondi/btc-node-pay
bitcoin bitcoin-payment bitcoind nodejs receive-bitcoin-payments xpub
Last synced: 4 months ago
JSON representation
lib for receiving bitcoin payments, nodejs, bitcoind node
- Host: GitHub
- URL: https://github.com/rsbondi/btc-node-pay
- Owner: rsbondi
- Created: 2018-10-17T19:27:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T15:12:14.000Z (over 2 years ago)
- Last Synced: 2025-01-15T18:38:37.380Z (4 months ago)
- Topics: bitcoin, bitcoin-payment, bitcoind, nodejs, receive-bitcoin-payments, xpub
- Language: JavaScript
- Size: 173 KB
- Stars: 0
- Watchers: 3
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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 host = '127.0.0.1:18333'
const paytrack = new Payment(xpub, host, network)paytrack.on('payment_received', p => {
// do something meaningful
})// expect a pament of 2000 satoshis, use zero for donation of any value
const payme = paytrack.getNewAddress(2000, 'p2sh')
// generate qr code or something
```see `example` directory in repository for more usage info
also, this is based on bcoin, and should work with other forks supported by bcoin but has not been tested
to use for example with litecoin, `const paytrack = new Payment(xpub, host, network, {bcoin: 'lcoin'})`
### 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.