Created
June 9, 2015 19:26
-
-
Save orweinberger/7fca506fe34b8ed9c510 to your computer and use it in GitHub Desktop.
Bitcoin socket
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
<html> | |
<head> | |
<script> | |
var socket = new WebSocket("wss://ws.blockchain.info/inv"); | |
socket.onopen = function (event) { | |
console.log('connected'); | |
socket.send(JSON.stringify({"op":"unconfirmed_sub"})); | |
}; | |
socket.onmessage = function (event) { | |
var sum = 0; | |
var e = JSON.parse(event.data); | |
var ins = e.x.inputs.length; | |
var outs = e.x.out.length; | |
e.x.out.forEach(function(d) { | |
sum += d.value; | |
}) | |
var doc = { | |
ip: e.x.relayed_by, | |
sum: sum, | |
inputs: ins, | |
outputs: outs, | |
hash: e.x.hash | |
} | |
console.log(doc); | |
} | |
</script> | |
</head> | |
<body> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment