Skip to content

Instantly share code, notes, and snippets.

@sagivo
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagivo/88f0196245282f9eb8f0 to your computer and use it in GitHub Desktop.
Save sagivo/88f0196245282f9eb8f0 to your computer and use it in GitHub Desktop.
var settings = {network: 'live'};
var acceptBitcoin = require('accept-bitcoin');
ac = new acceptBitcoin('YOUR_BITCOIN_ADDRESS', settings);
//generate new key for transaction
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
//transfer the amount recived to your account
key.transferBalanceToMyAccount(function(err, d){
if (d.status === 'success') console.log("Cool, the bitcoins are in my private account!");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment