Created
September 9, 2015 17:12
-
-
Save genecyber/3966acc70dec65b3ad3c to your computer and use it in GitHub Desktop.
Some bitcore SPV stuff
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
//Get output addresses from tx | |
tx.outputs.forEach(function(value, index){ | |
try { | |
console.log(value._satoshis) | |
console.log(toAddress(value._script.toHex())) | |
} catch(e){ | |
console.error(e) | |
} | |
}) | |
//toAddress | |
function toAddress(script) {return bitcore.Script(script).toAddress(bitcore.Networks.livenet).toString()} | |
var txo = {tx: tx.hash, outputs:[]} | |
tx.outputs.forEach(function(value, index){ | |
try { | |
//console.log(tx.hash) | |
//console.log(value._satoshis) | |
console.log(toAddress(value._script.toHex())) | |
txo.outputs.push({value: value._satoshis, address: toAddress(value._script.toHex()) }) | |
console.log(txo) | |
} catch(e){ | |
console.error(e) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment