npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

btc-payments

v1.1.6

Published

Bitcoin payments processor built over using bitcore and blocker.io api.

Downloads

13

Readme

Btc-Payments

An NPM module to easily configure and integrate a BTC payments processor into nodejs, using a hierarchical deterministic addresses you will receive all your payments on a single address. You will also don't need the bitcoin blockchain to push text, so its very lightweight and you can use the testnet network for testing.

Install

  1. Run:
    npm install btc-payments
  2. Create a config.js to run the processor with this format:
	{
		logLevel : 'debug', // none, normal, debug
		dbURI : 'mongodb://USER:PASS@IP:PORT/DBNAME', //URI to use to connect to db
		network : 'testnet', // testnet or livenet
		seedBytes : "your secret string to recover all your balances", // String of the seed master key
		btcMainAddress : "YOUR_BTC_MAIN_ADDRESS", // Address to receive the payments
		paymentTimeout : 120, // The amount of time in minutes that the user have to make the payment
		limitBalance : 0.005, //The max balance that your waiting addresses can have
		txFee : 0.0001, // The fee amount to use in your transactions to teh BTC main address
		functionTimeout : 10 // The amount of time of second that you want to wait beetwen processor updates
		warningTimeout : 10 // When a paymentWaiting have this amount of minutes left a function gets executed
	}
  1. Create the processor object:
	BTCPayments = new require('btc-payments')(btcPaymentsConfig,[],[].[],[]);
  1. Add the onComplete, on Warning and onCancel payments functions:
	BTCPayments.addOnCreate('Test',function(payment,callback){
		console.log('Test payment type created');
		console.log(payment.toString());
		callback(null,'Success');
	});
	BTCPayments.addOnComplete('Test',function(payment,callback){
		console.log('Test payment type completed');
		console.log(payment.toString());
		callback(null,'Success');
	});
	BTCPayments.addOnWarning('Test',function(payment,callback){
		console.log('Test payment type warned');
		console.log(payment.toString());
		callback(null,'Success');
	});
	BTCPayments.addOnCancel('Test',function(payment,callback){
		console.log('Test payment type canceled');
		console.log(payment.toString());
		callback(null,'Success');
	});
  1. Start the processor:
	BTCPayments.start();

Update Steps

  1. Get all the addresses in the addressesPool that are waiting to receive a payment.
  2. Get the paymentWaiting that the address is waiting.
  3. Get all the utxos (unspent inputs) of the address.
  4. Check all the utxos, get a total balance of the address.
  5. Three possible cases:
  • The address balance its the same and it didn't receive any btc or not the enough btc to complete the payment, finish.
  • The address reach the timeout warning and the payment exec the warning function.
  • The address reach the timeout waiting and the payment got canceled, finish.
  • The address balance its enough to complete the payment, to step 6.
  1. If the address balance its higher than the minimum balance that every address can have send the btcs to the main address using all the utxos, if not the address finish waiting and its free to be used for another payment.

TO DO

  • [x] Add onPaymentCanceled functions.
  • [x] Add onPaymentCreated functions.
  • [x] Add editOnComplete and editOnCancel functions.
  • [x] Write basic tests.
  • [x] Stop gracefully.
  • [x] Added from address.
  • [x] Add wariningTimeout functions.
  • [ ] Tests with real data.
  • [ ] Pause and start processor.
  • [ ] Better error handling.
  • [ ] Better documentation.
  • [ ] improve performance.