diff options
| author | Adam Soltys <[email protected]> | 2016-11-22 17:04:29 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2016-12-26 14:22:39 -0800 |
| commit | 69fe9bc5e29415e66e5463adb37d9524d7ac185a (patch) | |
| tree | 562562000e31e2f4861c53681bca4bdc98b8f969 /public | |
| parent | 6101cbf5db17faa2c32d81fc28a3971fb3b98c12 (diff) | |
| download | coinos-server-69fe9bc5e29415e66e5463adb37d9524d7ac185a.tar.gz coinos-server-69fe9bc5e29415e66e5463adb37d9524d7ac185a.zip | |
Listen for testnet payments
Diffstat (limited to 'public')
| -rw-r--r-- | public/js/calculator.coffee | 6 | ||||
| -rw-r--r-- | public/js/calculator.js | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee index 7d185f24..7dfb6186 100644 --- a/public/js/calculator.coffee +++ b/public/js/calculator.coffee @@ -1,6 +1,8 @@ EXCHANGE_FAIL = "Problem fetching exchange rate" SOCKET_FAIL = "Problem connecting to payment server, notifications may not appear" ADDRESS_FAIL = "Invalid address" +API_URL = "wss://socket.blockcypher.com/v1/btc/main" +TEST_URL = "wss://socket.blockcypher.com/v1/btc/test3" g = exports ? this g.errors = [] @@ -90,6 +92,8 @@ setup = -> $('#logo').attr('src', src).show() getAddress() + if g.user.address[0] is 'm' + API_URL = TEST_URL $('.symbol').html(g.user.currency) $('.currency').html(g.user.currency) @@ -169,7 +173,7 @@ listen = -> setTimeout(listen, 12000) else fail(SOCKET_FAIL) if g.attempts > 3 - g.blockchain = new WebSocket("wss://socket.blockcypher.com/v1/btc/main") + g.blockchain = new WebSocket(API_URL) g.blockchain.onopen = -> if g.blockchain.readyState is 1 diff --git a/public/js/calculator.js b/public/js/calculator.js index 3a564034..c85c9bb3 100644 --- a/public/js/calculator.js +++ b/public/js/calculator.js @@ -1,5 +1,5 @@ (function() { - var ADDRESS_FAIL, EXCHANGE_FAIL, SOCKET_FAIL, clear, fail, fetchExchangeRate, g, getAddress, listen, logTransaction, multiplier, setup, updateTotal; + var ADDRESS_FAIL, API_URL, EXCHANGE_FAIL, SOCKET_FAIL, TEST_URL, clear, fail, fetchExchangeRate, g, getAddress, listen, logTransaction, multiplier, setup, updateTotal; EXCHANGE_FAIL = "Problem fetching exchange rate"; @@ -7,6 +7,10 @@ ADDRESS_FAIL = "Invalid address"; + API_URL = "wss://socket.blockcypher.com/v1/btc/main"; + + TEST_URL = "wss://socket.blockcypher.com/v1/btc/test3"; + g = typeof exports !== "undefined" && exports !== null ? exports : this; g.errors = []; @@ -96,6 +100,9 @@ $('#logo').attr('src', src).show(); } getAddress(); + if (g.user.address[0] === 'm') { + API_URL = TEST_URL; + } $('.symbol').html(g.user.currency); $('.currency').html(g.user.currency); $('.unit').html(g.user.unit); @@ -173,7 +180,7 @@ if (g.attempts > 3) { fail(SOCKET_FAIL); } - g.blockchain = new WebSocket("wss://socket.blockcypher.com/v1/btc/main"); + g.blockchain = new WebSocket(API_URL); g.blockchain.onopen = function() { if (g.blockchain.readyState === 1) { g.attempts = 0; |
