• Stars
    star
    159
  • Rank 235,916 (Top 5 %)
  • Language
    CoffeeScript
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Accept bitcoin payments using Node.js

Accept Bitcoin 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

More Repositories

1

algorithms

algorithms playground for common questions
Ruby
3,264
star
2

StockStalk

Robinhood on Desktop
JavaScript
52
star
3

Unity2d-Game

Unity2d Game Sample Template
C#
19
star
4

solidity-utils

solidity utils to make your life easier
JavaScript
16
star
5

nodejs-addons

calling native c++ from nodejs
C++
15
star
6

go-benchmark

benchmarking things in go, for performance freaks.
Go
11
star
7

dead-simple-crypt

simply encrypt and decrypt things
JavaScript
9
star
8

robinhood-node

💹 Trade stocks for free using your Robinhood account
JavaScript
7
star
9

Ruby-Javascript

Make your life easy - add lots of ruby-like methides to your javascript language.
JavaScript
6
star
10

emoji-domain-checker

check if your favorite emoji-domain is avaialble
JavaScript
6
star
11

node-coffeescript-express-mongoose-rest-api

a quick MVC skeleton for creating a RESTful server using express.js and mongoose
CoffeeScript
6
star
12

timeago-words

node.js time ago functionality to display time ago in words
CoffeeScript
4
star
13

slack-overflow

launch hackathon 2015
HTML
4
star
14

fixed-table-header

allow you to make constat header for tables
4
star
15

powerset

ruby implementation for finding the powerset of set.
Ruby
3
star
16

shutup

chrome extention for content censorship
CoffeeScript
2
star
17

ggj2015

C#
2
star
18

jQuery-Watermark

small and easy watermark creator for inputs
2
star
19

rnn-cartpole

using RNN to play CartPole on Keras and openai Gym
Python
1
star
20

gitconfig

git shortcut to make your life better
1
star
21

react-chrome-extentaion-template

a basic template for using react apps on chrome extantion
JavaScript
1
star
22

pong-client

client side pong game in Unity3D
C#
1
star
23

unity-vr-hackathon

C#
1
star
24

simple-chat-room

experimatal webRTC chatroom using node, express and socket.io
JavaScript
1
star