Skip to content

Instantly share code, notes, and snippets.

@genecyber
Created September 9, 2015 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save genecyber/3966acc70dec65b3ad3c to your computer and use it in GitHub Desktop.
Save genecyber/3966acc70dec65b3ad3c to your computer and use it in GitHub Desktop.
Some bitcore SPV stuff
//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