Skip to content

Instantly share code, notes, and snippets.

@sagivo
Created September 10, 2014 05:49
Show Gist options
  • Save sagivo/3e8ff7077585fe97478a to your computer and use it in GitHub Desktop.
Save sagivo/3e8ff7077585fe97478a to your computer and use it in GitHub Desktop.
accept-bitcoin sample
var settings = {payToAddress: 'YOUR_BITCOIN_ADDRESS'};
var ac = require('accept-bitcoin')(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