diff options
| author | Adam Soltys <[email protected]> | 2016-11-22 12:01:38 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2016-12-26 14:22:39 -0800 |
| commit | 6101cbf5db17faa2c32d81fc28a3971fb3b98c12 (patch) | |
| tree | e09e43a8779e1d2b95f461834994d724a2f0c323 /public/js/calculator.coffee | |
| parent | fe21ed758564087bb73d19c26dbbae4a94268b0a (diff) | |
| download | coinos-server-6101cbf5db17faa2c32d81fc28a3971fb3b98c12.tar.gz coinos-server-6101cbf5db17faa2c32d81fc28a3971fb3b98c12.zip | |
Switch to blockcypher API from blockchain
Diffstat (limited to 'public/js/calculator.coffee')
| -rw-r--r-- | public/js/calculator.coffee | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee index fccc0c5e..7d185f24 100644 --- a/public/js/calculator.coffee +++ b/public/js/calculator.coffee @@ -169,13 +169,13 @@ listen = -> setTimeout(listen, 12000) else fail(SOCKET_FAIL) if g.attempts > 3 - g.blockchain = new WebSocket("wss://ws.blockchain.info/inv") + g.blockchain = new WebSocket("wss://socket.blockcypher.com/v1/btc/main") g.blockchain.onopen = -> if g.blockchain.readyState is 1 g.attempts = 0 clear(SOCKET_FAIL) - g.blockchain.send('{"op":"addr_sub", "addr":"' + g.user.address + '"}') + g.blockchain.send('{"event":"unconfirmed-tx", "address":"' + g.user.address + '"}') else setTimeout(g.blockchain.onopen, 12000 * g.attempts) @@ -190,17 +190,17 @@ listen = -> listen() g.blockchain.onmessage = (e) -> - results = eval('(' + e.data + ')') + tx = JSON.parse(e.data) + amount = 0 - txid = results.x.hash + txid = tx.hash return if txid == g.last g.last = txid - $.each(results.x.out, (i, v) -> - if (v.addr == g.user.address) - amount += v.value / 100000000 - ) + for output in tx.outputs + if (output.addresses[0] == g.user.address) + amount += output.value / 100000000 logTransaction(txid, amount) |
