You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

489 lines
14 KiB

  1. // Copyright 2017-2018 DERO Project. All rights reserved.
  2. // Use of this source code in any form is governed by RESEARCH license.
  3. // license can be found in the LICENSE file.
  4. // GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8
  5. //
  6. //
  7. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  8. // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  9. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  10. // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  11. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  13. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  14. // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15. // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. package main
  17. // this files defines all the templates
  18. var header_template string = `
  19. {{define "header"}}
  20. <!DOCTYPE html>
  21. <html lang="en">
  22. <head>
  23. <meta charset="UTF-8">
  24. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  25. <title>{{ .title }}</title>
  26. <!--<link rel="stylesheet" type="text/css" href="/css/style.css">-->
  27. <style type="text/css">
  28. body {
  29. margin: 0;
  30. padding: 0;
  31. color: green;
  32. background-color: white;
  33. }
  34. h1, h2, h3, h4, h5, h6 {
  35. text-align: center;
  36. }
  37. .center {
  38. margin: auto;
  39. width: 96%;
  40. /*border: 1px solid #73AD21;
  41. padding: 10px;*/
  42. }
  43. tr, li, #pages, .info {
  44. font-family: "Lucida Console", Monaco, monospace;
  45. font-size : 12px;
  46. height: 22px;
  47. }
  48. #pages
  49. {
  50. margin-top: 15px;
  51. }
  52. td {
  53. text-align: center;
  54. }
  55. a:link {
  56. text-decoration: none;
  57. color: blue;
  58. }
  59. a:visited {
  60. text-decoration: none;
  61. color: blue;
  62. }
  63. a:hover {
  64. text-decoration: underline;
  65. color: blue;
  66. }
  67. a:active {
  68. text-decoration: none;
  69. color: blue;
  70. }
  71. form {
  72. display: inline-block;
  73. text-align: center;
  74. }
  75. .style-1 input[type="text"] {
  76. padding: 2px;
  77. border: solid 1px #dcdcdc;
  78. transition: box-shadow 0.3s, border 0.3s;
  79. }
  80. .style-1 input[type="text"]:focus,
  81. .style-1 input[type="text"].focus {
  82. border: solid 1px #707070;
  83. box-shadow: 0 0 5px 1px #969696;
  84. }
  85. .tabs {
  86. position: relative;
  87. min-height: 220px; /* This part sucks */
  88. clear: both;
  89. margin: 25px 0;
  90. }
  91. .tab {
  92. float: left;
  93. }
  94. .tab label {
  95. background: white;
  96. padding: 10px;
  97. border: 1px solid #ccc;
  98. margin-left: -1px;
  99. position: relative;
  100. left: 1px;
  101. }
  102. .tab [type=radio] {
  103. display: none;
  104. }
  105. .content {
  106. position: absolute;
  107. top: 28px;
  108. left: 0;
  109. background: white;
  110. right: 0;
  111. bottom: 0;
  112. padding: 20px;
  113. border: 1px solid #ccc;
  114. }
  115. [type=radio]:checked ~ label {
  116. background: #505050 ;
  117. border-bottom: 1px solid green;
  118. z-index: 2;
  119. }
  120. [type=radio]:checked ~ label ~ .content {
  121. z-index: 1;
  122. }
  123. input#toggle-1[type=checkbox] {
  124. position: absolute;
  125. /*top: -9999px;*/
  126. left: -9999px;
  127. }
  128. label#show-decoded-inputs {
  129. /*-webkit-appearance: push-button;*/
  130. /*-moz-appearance: button;*/
  131. display: inline-block;
  132. /*margin: 60px 0 10px 0;*/
  133. cursor: pointer;
  134. background-color: white;;
  135. color: green;
  136. width: 100%;
  137. text-align: center;
  138. }
  139. div#decoded-inputs{
  140. display: none;
  141. }
  142. /* Toggled State */
  143. input#toggle-1[type=checkbox]:checked ~ div#decoded-inputs {
  144. display: block;
  145. }
  146. </style>
  147. </head>
  148. <body>
  149. <div>
  150. <div class="center">
  151. <h1 class="center"><a href="/">{{ .title }} {{if .testnet}} TestNet {{end}}</a></h1>
  152. <!-- <h4 style="font-size: 15px; margin: 0px">(no javascript - no cookies - no web analytics trackers - no images - open sourced)</h4> -->
  153. </div>
  154. <div class="center">
  155. <form action="/search" method="get" style="width:100%; margin-top:15px" class="style-1">
  156. <input type="text" name="value" size="120"
  157. placeholder="block height, block hash, transaction hash">
  158. <input type="submit" value="Search">
  159. </form>
  160. </div>
  161. </div>
  162. {{if .Network_Difficulty}}
  163. <div class="center">
  164. <h3 style="font-size: 12px; margin-top: 20px">
  165. Server time: {{ .servertime }} | <a href="/txpool">Transaction pool</a>
  166. </h3>
  167. <h3 style="font-size: 12px; margin-top: 5px; margin-bottom: 3">
  168. Network difficulty: {{ .Network_Difficulty }}
  169. | Hash rate: {{ .hash_rate }} MH&#x2F;s
  170. | Mempool size : {{ .txpool_size }}
  171. <!-- | Fee per kb: 0.001198930000
  172. | Median block size limit: 292.97 kB
  173. -->
  174. </h3>
  175. </div>
  176. {{end}}
  177. {{end}}
  178. `
  179. var block_template string = `{{define "block"}}
  180. {{ template "header" . }}
  181. <div>
  182. <H4>Block hash (height): {{.block.Hash}} ({{.block.Height}})</H4>
  183. <H5>Previous block: <a href="/block/{{.block.Prev_Hash}}">{{.block.Prev_Hash}}</a></H5>
  184. <!--
  185. <H5>Next block: <a href="/block/a8ade20d5cad5e23105cfc25687beb2498844a984b1450330c67705b6c720596">a8ade20d5cad5e23105cfc25687beb2498844a984b1450330c67705b6c720596</a></H5>
  186. -->
  187. <table class="center">
  188. <tr>
  189. <td>Timestamp [UCT] (epoch):</td><td>{{.block.Block_time}} ({{.block.Epoch}})</td>
  190. <td>Age [h:m:s]:</td><td>{{.block.Age}}</td>
  191. <td>Δ [h:m:s]:</td><td></td>
  192. </tr>
  193. <tr>
  194. <td>Major.minor version:</td><td>{{.block.Major_Version}}.{{.block.Minor_Version}}</td>
  195. <td>Block reward:</td><td>{{.block.Reward}}</td>
  196. <td>Block size [kB]:</td><td>{{.block.Size}}</td>
  197. </tr>
  198. <tr>
  199. <td>nonce:</td><td>{{.block.Nonce}}</td>
  200. <td>Total fees:</td><td>{{.block.Fees}}</td>
  201. <td>No of txs:</td><td>{{.block.Tx_Count}}</td>
  202. </tr>
  203. </table>
  204. <h3>Miner reward transaction</h3>
  205. <table class="center">
  206. <tr>
  207. <td>hash</td>
  208. <td>outputs</td>
  209. <td>size [kB]</td>
  210. <td>version</td>
  211. </tr>
  212. <tr>
  213. <td><a href="/tx/{{.block.Mtx.Hash}}">{{.block.Mtx.Hash}}</a>
  214. <td>{{.block.Mtx.Amount}}</td>
  215. <td>{{.block.Mtx.Size}}</td>
  216. <td>{{.block.Mtx.Version}}</td>
  217. </tr>
  218. </table>
  219. <h3>Transactions ({{.block.Tx_Count}})</h3>
  220. <table class="center" style="width:80%">
  221. <tr>
  222. <td>hash</td>
  223. <td>outputs</td>
  224. <td>fee</td>
  225. <td>ring size</td>
  226. <td>in/out</td>
  227. <td>version</td>
  228. <td>size [kB]</td>
  229. </tr>
  230. {{range .block.Txs}}
  231. <tr>
  232. <td><a href="/tx/{{.Hash}}">{{.Hash}}</a></td>
  233. <td>?</td>
  234. <td>{{.Fee}}</td>
  235. <td>{{.Ring_size}}</td>
  236. <td>{{.In}}/{{.Out}}</td>
  237. <td>{{.Version}}</td>
  238. <td>{{.Size}}</td>
  239. </tr>
  240. {{end}}
  241. </table>
  242. </div>
  243. {{ template "footer" . }}
  244. {{end}}
  245. `
  246. var tx_template string = `{{define "tx"}}
  247. {{ template "header" . }}
  248. <div>
  249. <H4 style="margin:5px">Tx hash: {{.info.Hash}}</H4>
  250. <H5 style="margin:5px">Tx prefix hash: {{.info.PrefixHash}}</H5>
  251. <H5 style="margin:5px">Tx public key: TODO</H5>
  252. <table class="center" style="width: 80%; margin-top:10px">
  253. <tr>
  254. <td>Timestamp: {{.info.Timestamp}} </td>
  255. <td>Timestamp [UCT]: {{.info.Block_time}}</td>
  256. <td>Age [y:d:h:m:s]: {{.info.Age}} </td>
  257. </tr>
  258. <tr>
  259. <td>Block: <a href="/block/{{.info.Height}}">{{.info.Height}}</a></td>
  260. <td>Fee: {{.info.Fee}}</td>
  261. <td>Tx size: {{.info.Size}} kB</td>
  262. </tr>
  263. <tr>
  264. <td>Tx version: {{.info.Version}}</td>
  265. <td>No of confirmations: {{.info.Depth}}</td>
  266. <td>Signature type: {{.info.Type}}</td>
  267. </tr>
  268. <tr>
  269. <td colspan="3">Extra: {{.info.Extra}}</td>
  270. </tr>
  271. </table>
  272. <h3>{{.info.Out}} output(s) for total of {{.info.Amount}} dero</h3>
  273. <div class="center">
  274. <table class="center">
  275. <tr>
  276. <td>stealth address</td>
  277. <td>amount</td>
  278. <td>amount idx</td>
  279. </tr>
  280. {{range $i, $e := .info.OutAddress}}
  281. <tr>
  282. <td>{{ $e }}</td>
  283. <td>{{$.info.Amount}}</td>
  284. <td>{{index $.info.OutOffset $i}}</td>
  285. </tr>
  286. {{end}}
  287. </table>
  288. </div>
  289. <!-- TODO currently we donot enable user to prove or decode something -->
  290. {{if eq .info.CoinBase false}}
  291. <h3>{{.info.In}} input(s) for total of ? dero</h3>
  292. <div class="center">
  293. <table class="center">
  294. {{range .info.Keyimages}}
  295. <tr>
  296. <td style="text-align: center;">
  297. key image {{ . }}
  298. </td>
  299. <td>amount: ?</td>
  300. </tr>
  301. {{end}}
  302. </table>
  303. </div>
  304. {{end}}
  305. </div>
  306. {{ template "footer" . }}
  307. {{end}}`
  308. var txpool_template string = `{{define "txpool"}}
  309. <h2 style="margin-bottom: 0px">
  310. Transaction pool
  311. </h2>
  312. <h4 style="font-size: 12px; margin-top: 0px">(no of txs: {{ .txpool_size }}, size: 0.00 kB, updated every 5 seconds)</h4>
  313. <div class="center">
  314. <table class="center" style="width:80%">
  315. <tr>
  316. <td>age [h:m:s]</td>
  317. <td>transaction hash</td>
  318. <td>fee</td>
  319. <td>outputs</td>
  320. <td>in(nonrct)/out</td>
  321. <td>ring size</td>
  322. <td>tx size [kB]</td>
  323. </tr>
  324. {{range .mempool}}
  325. <tr>
  326. <td></td>
  327. <td><a href="/tx/{{.Hash}}">{{.Hash}}</a></td>
  328. <td>{{.Fee}}</td>
  329. <td>N/A</td>
  330. <td>{{.In}}/{{.Out}}</td>
  331. <td>{{.Ring_size}}</td>
  332. <td>{{.Size}}</td>
  333. </tr>
  334. {{end}}
  335. </table>
  336. </div>
  337. {{end}}`
  338. // full page txpool_template
  339. var txpool_page_template string = `{{define "txpool_page"}}
  340. {{ template "header" . }}
  341. {{ template "txpool" . }}
  342. {{ template "footer" . }}
  343. {{end}}`
  344. var main_template string = `
  345. {{define "main"}}
  346. {{ template "header" . }}
  347. {{ template "txpool" . }}
  348. <h2 style="margin-bottom: 0px">Transactions in the last 11 blocks</h2>
  349. <h4 style="font-size: 14px; margin-top: 0px">(Median size of these blocks: 0.09 kB)</h4>
  350. <div class="center">
  351. <table class="center">
  352. <tr>
  353. <td>height</td>
  354. <td>age [h:m:s]<!--(Δm)--></td>
  355. <td>size [kB]<!--(Δm)--></td>
  356. <td>tx hash</td>
  357. <td>fees</td>
  358. <td>outputs</td>
  359. <td>in(nonrct)/out</td>
  360. <td>ring size</td>
  361. <td>tx size [kB]</td>
  362. </tr>
  363. {{range .block_array}}
  364. <tr>
  365. <td><a href="/block/{{.Height}}">{{.Height}}</a></td>
  366. <td>{{.Age}}</td>
  367. <td>{{.Size}}</td>
  368. <td><a href="/tx/{{.Mtx.Hash}}">{{.Mtx.Hash}}</a></td>
  369. <td>N/A</td>
  370. <td>{{.Mtx.Amount}}</td>
  371. <td>{{.Mtx.In}}/{{.Mtx.Out}}</td>
  372. <td>0</td>
  373. <td>{{.Mtx.Size}}</td>
  374. </tr>
  375. {{range .Txs}}
  376. <tr>
  377. <td></td>
  378. <td></td>
  379. <td></td>
  380. <td><a href="/tx/{{.Hash}}">{{.Hash}}</a></td>
  381. <td>{{.Fee}}</td>
  382. <td>N/A</td>
  383. <td>{{.In}}/{{.Out}}</td>
  384. <td>{{.Ring_size}}</td>
  385. <td>{{.Size}}</td>
  386. </tr>
  387. {{end}}
  388. {{end}}
  389. </table>
  390. {{ template "paging" . }}
  391. </div>
  392. {{ template "footer" . }}
  393. {{end}}`
  394. var paging_template string = `{{ define "paging"}}
  395. <div id="pages" class="center" style="text-align: center;">
  396. <a href="/page/{{.previous_page}}">previous page</a> |
  397. <a href="/">first page</a> |
  398. current page: {{.current_page}}/<a href="/page/{{.total_page}}">{{.total_page}}</a>
  399. | <a href="/page/{{.next_page}}">next page</a>
  400. </div>
  401. {{end}}`
  402. var footer_template string = ` {{define "footer"}}
  403. <div class="center">
  404. <h6 style="margin-top:10px">
  405. <a href="https://github.com/deroproject/">DERO explorer source code</a>
  406. | explorer version (api): under development (1.0)
  407. | dero version: golang pre-alpha
  408. | Copyright 2017-2018 Dero Project
  409. </h6>
  410. </div>
  411. </body>
  412. </html>
  413. {{end}}
  414. `