Created
September 10, 2014 05:49
-
-
Save sagivo/3e8ff7077585fe97478a to your computer and use it in GitHub Desktop.
accept-bitcoin sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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