Skip to content

Instantly share code, notes, and snippets.

@Alex-Werner
Last active November 3, 2017 13:08
Show Gist options
  • Save Alex-Werner/9fc45eaf42db5bc93bac054610f82c4b to your computer and use it in GitHub Desktop.
Save Alex-Werner/9fc45eaf42db5bc93bac054610f82c4b to your computer and use it in GitHub Desktop.
Use bitcore-node-dash as dependencies
const bitcore = require('bitcore-node-dash');
const start = bitcore.scaffold.start;
let config = {
"network": "testnet",
"port": 3001,
"services": [
"bitcoind"
],
"servicesConfig": {
"bitcoind": {
"connect": [{
"rpchost": "127.0.0.1",
"rpcport": 9998,
"rpcuser": "dash",
"rpcpassword": "local321",
"zmqpubrawtx": "tcp://127.0.0.1:28332"
}]
}
}
};
let node = start({path:"",config:config});
node.on('ready',function(){
console.log('Hey I\'m ready!')
let dashd = node.services.bitcoind;
dashd.getBestBlockHash(function(err, hash){
if(err){console.log(err);}
dashd.getBlockHeader(hash,function(err, info){
console.log(info);
});
});
dashd.on('block',function(block){console.log(block)});
dashd.on('tx',function(txData){
let tx = new bitcore.lib.Transaction(txData).toJSON();
let inputs = tx.inputs;
inputs.forEach(function(input){
let script = new bitcore.lib.Script(input.script);
let address = script.toAddress('testnet');
//Enjoy potato with address
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment