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

accept-bitcoin

v0.0.9

Published

accept bitcoins on your projects

Downloads

3

Readme

#Accept Bitcoin

Finally a developer-friendly tool to simply accept bitcoins in your site.

  • Lite and fast, built on top of bitcore.
  • No need to install local bitcoin node RPC client. We use blockr API instead.
  • No need to install any wallet client.
  • Create ad-hoc address to accept bitcoins and transfer incomes to your offline account.
  • Easy configurations.

##Get Started

Simply install via npm:

npm install accept-bitcoin

Load AC and you're ready to go!

var acceptBitcoin = require('accept-bitcoin');
var ac = new acceptBitcoin('YOUR_BITCOIN_ADDRESS');

##Motivation Accepting bitcoins online can be complex to program and require you to install a bitcoin RPC client in order to read and write to the blockchain. This client require a lot of resources (in terms of CPU, networking and storage).
Most of the users are using a wallet to store their bitcoins. This wallet is a simple way to secure your public and private key. For security reasons you better save this wallet offline in a "cold storage".
More about the motivation behind this project at my blog post.

##Example You can override the default settings on creating

Examples are provided here

var settings = {network: 'live'}
var acceptBitcoin = require('accept-bitcoin');
var ac = new acceptBitcoin('YOUR_BITCOIN_ADDRESS', settings);
key = ac.generateAddress({alertWhenHasBalance: true});
console.log("Hello buyer! please pay to: " + key.address());
key.on('hasBalance', function(amount){
  console.log("thanks for paying me " + amount); //do stuff
  key.transferBalanceToMyAccount(function(err, d){
    if (d.status === 'success') console.log("Cool, the bitcoins are in my private account!");
  });
});

##Settings

You can override the default settings:

| name | type | default value | comment | |-------------------------|--------|------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | payToAddress | string | - | Your bitcoin adress you wish to transfer incomes to. | | network | string | test | choose your bitcoin RPC env. values are: test and livemore info here | | password | string | - | choose your random password to encrypt generated keys. | | storePath | string | ./keys.txt | path to store a file containing all the ad-hoc generated keys. | | encryptPrivateKey | bool | false | in case you want the stored keys to be encrypted (using password). | | payReminderToAddress | string | payToAddress | In case transfer amount is smaller than income and fees. | | includeUnconfirmed | bool | false | include unconfirmed transactions when checking for unspent incomes | | checkTransactionEvery | int | 1000 * 60 * 2 (2 minutes) | how often (in millisecond) to ping the network when checking for transactions. | | checkBalanceTimeout | int | 1000 * 60 * 60 * 2 (2 hours) | timeout (in millisecond) when checking balance of an address. | | checkUnspentTimeout | int | 1000 * 60 * 60 * 2 (2 hours) | timeout (in millisecond) when checking unspent transactions of an address. | | minimumConfirmations | int | 6 | minimum confirmations needed in order to trigger hasBalance event. | | txFee | float | 0.0001 | fee (in bitcoin) for transferring amount from ad hoc address to your address. |

###Key class This class is responsible for creating new bitcoin addresses, storing them and transferring funds between them. Some key functions are:
storeKey(wk) - store your key in a local file. Can be encrypted.
checkBalance()- check and notify you when an address has minimum balance. payTo(payToAddress, options, callback) - transfer all balance of this address to another address.

###Encrypt class Contains helpers to encrypt and decrypt strings. Used for storing your keys data locally.

##Contribute Please do. Fork it, star it, share it and add your code to the project. Help others.
All the src code is written in coffeescript and is under src. There's a tool that convert it automatically to js each time you change a file and put it under lib folder. Simply run cake build for that.

##License

MIT