diff --git a/README.md b/README.md index 403cc06..89e4013 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ testnet ======= -Miniature http server to play with litecoin testnet. \ No newline at end of file +Miniature HTTP server to play with litecoin testnet (also acts as a faucet). + +To run a local instance, copy config/testnet.cfg to config/testnet..cfg +and modify it with your local RPC settings. + diff --git a/http/link.gif b/http/link.gif new file mode 100644 index 0000000..24c993f Binary files /dev/null and b/http/link.gif differ diff --git a/testnet.js b/testnet.js index 88715bd..51d5c3e 100644 --- a/testnet.js +++ b/testnet.js @@ -117,6 +117,8 @@ function Application() { app.get('/block/:blockhash', function(req, res) { no_cache(res, true); + console.log("LOOKING FOR:",req.params.blockhash); + if(!req.params.blockhash) return res.end(JSON.stringify({ error : "blockhash is required" })); @@ -169,8 +171,34 @@ function Application() { console.error("getBalance error:", err); self.status.balance_1 = balance_1; - dpc(config.daemon_poll_freq, update_status); - + self.status.last_blocks = [ ] + + var blocks = [ ] + var n = info.blocks; + for(var i = 0; i < 10; i++) + blocks.push(n-i); + + get_block(); + + function get_block() { + + var height = blocks.shift(); + + if(!height) + return dpc(config.daemon_poll_freq, update_status); + + self.client.getBlockHash(height, function(err, blockhash) { + if(err) + console.error("getBlockHash error:", err); + + self.status.last_blocks.push({ + height : height, + hash : blockhash + }); + + get_block(); + }) + } }) }) }) diff --git a/views/index.ejs b/views/index.ejs index 2175911..590d279 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -13,13 +13,20 @@ color: #000; font-family: "Consolas"; font-size: 14px; - white-space: pre; + xwhite-space: pre; } + .response { white-space: pre; } + + a:link { text-decoration: none; color: #0051AD; } + a:visited { text-decoration: none; color: #0051AD; } + a:hover { text-decoration: none; color: #F04800; } + button, input { font-family: "Consolas"; } table { border-collapse: collapse; } td, th { padding: 8px; text-align: center; border: 1px solid #ccc; } + xfieldset { width : 700px; } @@ -50,9 +57,19 @@ function Application() { var str = ""; // --- + _.each(response.last_blocks, function(o) { + str += ""+o.height+" - "+o.hash+"
"; + }); + + $("#last_blocks").html(str); + + // --- + str = "" _.each(response.info, function(v,n) { - str += ""; + str += ""; }) str += "
"+n+""+v+"
"+n+""; + str += v; + str += "
"; $("#info").html(str); @@ -89,26 +106,8 @@ function Application() { $("#fee_response").html(jt(data)); }); }) - - $("#tx_lookup").click(function(){ - var txhash = $("#tx_input").val(); - - $.getJSON("/tx/"+txhash, function(data) { - $("#tx_info").html(jt(data)); - }); - }) - - $("#block_lookup").click(function(){ - var blockhash = $("#tx_input").val(); - - $.getJSON("/block/"+blockhash, function(data) { - $("#block_info").html(jt(data)); - }); - }) - } - $(document).ready(function() { window.app = new Application(); }); @@ -116,42 +115,45 @@ $(document).ready(function() { -
LITECOIN TESTNET NODE INTERFACE +
LITECOIN TESTNET NODE INTERFACE

---- WALLET --- -WALLET ADDRESS: -BALANCE (0 confirms): +

WALLET +WALLET ADDRESS:
+BALANCE (0 confirms):
BALANCE (1 confirms): - ---- SEND --- +
+
+
SEND TO ADDRESS: AMOUNT: - -RESPONSE: - - ---- SET TX FEE --- +

+RESPONSE:
+ +

+
+
+
SET TX FEE FEE: - -RESPONSE: - - -------------------- -LOOKUP TX HASH: - - -------------------- -LOOKUP BLOCK HASH: - - -INFO: +

+RESPONSE:
+ +

+
+
+
LAST 10 BLOCKS + +
+
+
INFO - -CONNECTED PEERS: +
+
+
CONNECTED PEERS - +
+