diff --git a/src/main.rs b/src/main.rs index 34a4700..1d71cff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,11 +85,15 @@ fn get_block_by_height(block_height: String) -> Template { } #[get("/transaction/")] -fn get_transaction_by_hash(tx_hash: String) -> Json { +fn get_transaction_by_hash(tx_hash: String) -> Template { let params: JsonValue = json!({"txs_hashes": [&tx_hash]}); let res: GetTransactions = issue_raw_rpc(&"get_transactions", params) .send().unwrap().json().unwrap(); - Json(res) + let context = json!({ + "tx_info": res.txs, + "tx_hash": tx_hash + }); + Template::render("transaction", context) } #[get("/search?")] diff --git a/templates/transaction.html.tera b/templates/transaction.html.tera index 5396af6..7b7b9de 100644 --- a/templates/transaction.html.tera +++ b/templates/transaction.html.tera @@ -2,100 +2,54 @@ {% block content %} +{% for i in tx_info %} +{{i.block_height}} +{{i.block_timestamp}} +{{i.double_spend_seen}} +{{i.in_pool}} +{{i.output_indices}} +{% endfor %} +
-

Transaction {{ block_header.height }}

-

Hash: {{ block_header.hash }}

-

Timestamp: {{ block_header.timestamp }} +

Transaction {{ tx_hash | truncate(length=4) }}

+

Full Hash: {{ tx_hash }}

+

Block Timestamp: {{ tx_info.0.block_timestamp }}

-

Size

-
-

{{ block_header.block_size }} bytes

-
-
-
-
-
-

Depth

-
-

{{ block_header.depth }}

-
-
-
-
-
-

Difficulty

-
-

{{ block_header.difficulty }}

-
-
-
-
-
-

Transactions

+

Block Height

-

{% if tx_hashes %}{{ tx_hashes | length }}{% else %}0{% endif %}

+

{{ tx_info.0.block_height }}

-

Orphaned

+

In Pool

-

{{ block_header.orphan_status }}

+

{{ tx_info.0.in_pool }}

-

Nonce

+

Double Spend

-

{{ block_header.nonce }}

+

{{ tx_info.0.double_spend_seen }}



-
- - - - - - - - - - - - - - - - - {% if tx_hashes %} - {% for hash in tx_hashes %} - - - - - - - - {% endfor %} - {% endif %} -

Block Transactions

CoinbaseHashAmountFeeBytes
{{ block_header.miner_tx_hash | truncate(length=8) }}{{ block_header.reward / 1000000000000 }} XMR0?
{{ hash | truncate(length=8) }}???
-
-

Previous Block

+

View Block