diff --git a/templates/address_overview.html b/templates/address_overview.html index 6dbb8b40..45e68c8f 100644 --- a/templates/address_overview.html +++ b/templates/address_overview.html @@ -317,72 +317,6 @@

Wallet Addresses

$("time.timeago").timeago(); - var total_ws_received = 0; - var MAX_WS_TO_RECEIVE = 1000; - - {% if not is_wallet_page and not before_bh and num_unconfirmed_txns < 10 %} - - function create_ws() { - console.log('Creating new websocket...'); - ws = new WebSocket('{{ coin_symbol|coin_symbol_to_wss }}'); - } - - create_ws(); - - function send_ping() { - // Send pings at regular interval: - if (total_ws_received < MAX_WS_TO_RECEIVE) { - console.log('Sending websocket ping...'); - ws.send(JSON.stringify({event: "ping"})); - // Trigger self recursively - setTimeout(send_ping, 20000); - } else { - console.log('Not sending ping because MAX_WS_TO_RECEIVE reached'); - } - } - - ws.onmessage = function(evt) { - - var data = JSON.parse(evt.data); - console.log('Websocket Received: ' + evt.data); - - // Weak protection against too much activity - total_ws_received += 1; - if (total_ws_received > MAX_WS_TO_RECEIVE) { - ws.close(); - } - - if ( data.hasOwnProperty('hash') ) { - if (data['confirmations'] <= 6 ) { - // Update data in the view - location.reload(); - } - } - } - - ws.onopen = function() { - console.log('Connection established.'); - ws.send(JSON.stringify( - { - 'address': "{% if is_wallet_page %}{{ bc_wallet_name }}{% else %}{{address }}{% endif %}", - 'event': 'tx-confirmation', - 'token': '{{ BLOCKCYPHER_PUBLIC_KEY }}', - } - )); - send_ping(); - }; - - ws.onclose = function() { - console.log('Connection closed'); - if (total_ws_received < MAX_WS_TO_RECEIVE) { - console.log('Creating new websocket to replace old one...'); - create_ws(); - } - - }; - - {% endif %} - if (window.location.hash == '#advanced-details') { $('#advanced-details').collapse('show'); } diff --git a/templates/transaction_overview.html b/templates/transaction_overview.html index 35c0bdfd..98f4daf5 100644 --- a/templates/transaction_overview.html +++ b/templates/transaction_overview.html @@ -365,72 +365,6 @@

Details

$("time.timeago").timeago(); - var total_ws_received = 0; - var MAX_WS_TO_RECEIVE = 1000; - - function create_ws() { - console.log('Creating new websocket...'); - ws = new WebSocket('{{ coin_symbol|coin_symbol_to_wss }}'); - } - - create_ws(); - - function send_ping() { - // Send pings at regular interval: - if (total_ws_received < MAX_WS_TO_RECEIVE) { - console.log('Sending websocket ping...'); - ws.send(JSON.stringify({event: "ping"})); - // Trigger self recursively - setTimeout(send_ping, 20000); - } else { - console.log('Not sending ping because MAX_WS_TO_RECEIVE reached'); - } - } - - ws.onmessage = function(evt) { - - var data = JSON.parse(evt.data); - console.log('Websocket Received: ' + evt.data); - - // Weak protection against too much activity - total_ws_received += 1; - if (total_ws_received > MAX_WS_TO_RECEIVE) { - ws.close(); - } - - if ( data.hasOwnProperty('hash') ) { - - {# TODO: duplicate all logic in JS #} - location.reload(); - - - } - - } - - ws.onopen = function() { - console.log('Connection established.'); - ws.send(JSON.stringify( - { - 'hash': "{{ tx_hash }}", - 'event': 'tx-confirmation', - {# UGLY HACK #} - 'address': "{{ outputs.0.addresses.0 }}", - 'token': '{{ BLOCKCYPHER_PUBLIC_KEY }}', - } - )); - send_ping(); - }; - - ws.onclose = function() { - console.log('Connection closed'); - if (total_ws_received < MAX_WS_TO_RECEIVE) { - console.log('Creating new websocket to replace old one...'); - create_ws(); - } - - }; - {% if transaction.confirmations == 0 and transaction.double_spend == False %} poll_confidence() {% endif %}