Last active
November 3, 2017 13:08
-
-
Save Alex-Werner/9fc45eaf42db5bc93bac054610f82c4b to your computer and use it in GitHub Desktop.
Use bitcore-node-dash as dependencies
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
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