GithubHelp home page GithubHelp logo

22388o / btc-node-pay Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rsbondi/btc-node-pay

1.0 0.0 0.0 117 KB

lib for receiving bitcoin payments, nodejs, bitcoind node

JavaScript 88.01% HTML 11.99%

btc-node-pay's Introduction

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

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.

btc-node-pay's People

Contributors

rsbondi avatar

Stargazers

Gábor Mihálcz avatar

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.