Compare commits

...

2 Commits

1
.gitignore vendored

@ -3,3 +3,4 @@
docker-compose.prod.yml
docker-compose.stage.yml
docker-compose.dev.yml
data

37
Cargo.lock generated

@ -1,5 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "addr2line"
version = "0.12.2"
@ -126,6 +128,12 @@ version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bitflags"
version = "1.2.1"
@ -642,6 +650,12 @@ dependencies = [
"walkdir",
]
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]]
name = "hermit-abi"
version = "0.1.14"
@ -808,11 +822,12 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.4.0"
version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
@ -1552,12 +1567,12 @@ dependencies = [
[[package]]
name = "rocket"
version = "0.4.5"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6130967b369cfb8411b0b73e96fcba1229c32a9cc6f295d144f879bfced13c6e"
checksum = "4a7ab1dfdc75bb8bd2be381f37796b1b300c45a3c9145b34d86715e8dd90bf28"
dependencies = [
"atty",
"base64 0.12.3",
"base64 0.13.0",
"log 0.4.8",
"memchr",
"num_cpus",
@ -1573,9 +1588,9 @@ dependencies = [
[[package]]
name = "rocket_codegen"
version = "0.4.5"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb852e6da168fb948a8f2b798ba2e2f0e4fc860eae0efa9cf2bf0f5466bb0425"
checksum = "1729e687d6d2cf434d174da84fb948f7fef4fac22d20ce94ca61c28b72dbcf9f"
dependencies = [
"devise",
"glob 0.3.0",
@ -1588,9 +1603,9 @@ dependencies = [
[[package]]
name = "rocket_contrib"
version = "0.4.5"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3946ca815127041d8f64455561031d058c22ae1b135251502c5ea523cf9e14b"
checksum = "6b6303dccab46dce6c7ac26c9b9d8d8cde1b19614b027c3f913be6611bff6d9b"
dependencies = [
"glob 0.3.0",
"handlebars",
@ -1604,9 +1619,9 @@ dependencies = [
[[package]]
name = "rocket_http"
version = "0.4.5"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aff5a5480175f2f553a876b251e9350c74196128806d176da3a51c82aab5428"
checksum = "6131e6e6d38a9817f4a494ff5da95971451c2eb56a53915579fc9c80f6ef0117"
dependencies = [
"cookie",
"hyper 0.10.16",

@ -8,8 +8,8 @@ name = "wownero-explorer"
path = "src/main.rs"
[dependencies]
rocket = "0.4.4"
rocket_contrib = {version = "0.4.4", features = ["handlebars_templates", "tera_templates"]}
rocket = "0.4.10"
rocket_contrib = {version = "0.4.10", features = ["handlebars_templates", "tera_templates"]}
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"

@ -243,3 +243,17 @@ pub struct QRData {
pub recipient_name: String,
pub tx_payment_id: String
}
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
pub struct CheckTxKeyResponse {
pub jsonrpc: String,
pub id: u32,
pub result: Option<CheckTxKeyResult>
}
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
pub struct CheckTxKeyResult {
pub confirmations: u32,
pub in_pool: bool,
pub received: u64,
}

@ -42,8 +42,6 @@ fn build_rpc(method: &str, raw_data: Option<JsonValue>, raw: bool) -> RequestBui
#[get("/block/hash/<block_hash>")]
fn get_block_by_hash(block_hash: String) -> Template {
// https://www.getmonero.org/resources/developer-guides/daemon-rpc.html#get_block
// http POST crypto.int.lzahq.tech:34568/json_rpc method=get_block params:='{"hash": "83faf32a04708bead3e712947b8ad8e1e6ab50f3093948bfb3e71fb0089a7b68"}'
let payload: JsonValue = json!({
"method": "get_block",
"params": {
@ -59,8 +57,6 @@ fn get_block_by_hash(block_hash: String) -> Template {
#[get("/block/height/<block_height>")]
fn get_block_by_height(block_height: String) -> Template {
// https://www.getmonero.org/resources/developer-guides/daemon-rpc.html#get_block
// http POST crypto.int.lzahq.tech:34568/json_rpc method=get_block params:='{"height": 225460}'
let payload: JsonValue = json!({
"method": "get_block",
"params": {
@ -74,11 +70,31 @@ fn get_block_by_height(block_height: String) -> Template {
Template::render("block", &res.result)
}
#[get("/receipt?<address>&<tx_hash>&<tx_key>")]
fn get_tx_receipt(address: String, tx_hash: String, tx_key: String) -> Template {
let payload: JsonValue = json!({
"method": "check_tx_key",
"params": {
"address": address,
"txid": tx_hash,
"tx_key": tx_key
}
});
let http_client = Client::new();
let wallet_uri = env::var("WALLET_URI").unwrap();
let uri = format!("{}/json_rpc", &wallet_uri);
let res: CheckTxKeyResponse = http_client.post(&uri).json(&payload)
.send().unwrap().json().unwrap();
let context = json!({
"res": &res.result,
"tx_hash": tx_hash,
"address": address
});
Template::render("receipt", context)
}
#[get("/transaction/<tx_hash>")]
fn get_transaction_by_hash(tx_hash: String) -> Template {
// https://www.getmonero.org/resources/developer-guides/daemon-rpc.html#get_transactions
// echo '{"txs_hashes": ["98f68768d258544856e0b6c3a3aac8773a094fe184f9b9daba1554a9d8fc2e02"], "decode_as_json": true}' \
// | http POST crypto.int.lzahq.tech:34568/get_transactions
let params: JsonValue = json!({
"txs_hashes": [&tx_hash],
"decode_as_json": true
@ -198,19 +214,6 @@ fn search(value: &RawStr) -> Redirect {
};
}
// #[get("/tx_pool")]
// fn show_tx_pool() -> Json<GetTransactionPool> {
// let mut tx_pool: GetTransactionPool = build_rpc(
// &"get_transaction_pool", None, None, true
// ).send().unwrap().json().unwrap();
//
// for f in &mut tx_pool.transactions {
// f.process();
// };
//
// Json(tx_pool)
// }
#[get("/")]
fn index() -> Template {
let daemon_uri = env::var("DAEMON_URI").unwrap();
@ -265,6 +268,7 @@ fn main() {
get_block_by_height,
get_block_by_hash,
get_transaction_by_hash,
get_tx_receipt,
show_wallet_address,
error
])

@ -2078,7 +2078,7 @@ input, select, textarea {
/* Nav */
#nav {
margin: 2.5em 0 0 0;
margin: .5em 0 0 0;
}
#nav > ul {

@ -6,8 +6,8 @@
<div class="container">
<section id="header">
<nav id="nav">
<a href="/"><h1>Go Back</h1><br>
<img src="//files.lzahq.tech/wow/WOW-Bux-720x435.png" width=300 />
<a href="/"><h1>Go Back</h1>
<img src="//files.lzahq.tech/wow/WOW-Bux-720x435.png" width=250 />
</a>
</nav>
</section>

@ -6,8 +6,8 @@
<div class="container">
<section id="header">
<nav id="nav">
<a href="/"><h1>Go Back</h1><br>
<img src="//files.lzahq.tech/wow/Wownero-Mine-Stock-720x500.png" width=300 />
<a href="/"><h1>Go Back</h1>
<img src="//files.lzahq.tech/wow/Wownero-Mine-Stock-720x500.png" width=250 />
</a>
</nav>
</section>

@ -7,7 +7,7 @@
<section id="header">
<h1>Wownero Block Explorer</h1>
<nav id="nav">
<img src="//files.lzahq.tech/wow/Wownero-Development-Stock-720x440.png"/ width=300>
<img src="//files.lzahq.tech/wow/Wownero-Development-Stock-720x440.png"/ width=250>
<div class="search">
<form action="/search" method="get">
<input type="text" name="value" placeholder="Enter a transaction hash, block hash, block height, or wallet address.">

@ -0,0 +1,61 @@
{% extends "base" %}
{% block content %}
<section id="main">
<div class="container">
<section id="header">
<nav id="nav">
<a href="/"><h1>Go Home</h1><br />
<img src="//files.lzahq.tech/wow/WOW-Stack-720x455.png" width=150 />
</a>
</nav>
</section>
<div class="col-12">
<section>
<header class="major">
<h2>Confirm TX Receipt</h2>
{% if res %}
<p class="subheader"><strong>To Address</strong>: {{ address }}</p>
<p class="subheader"><strong>Transaction ID</strong>: {{ tx_hash }}</p>
</header>
<div class="row">
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Confirmations</h3>
</header>
<p>{{ res.confirmations }}</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Amount</h3>
</header>
<p>{{ res.received / 100000000000 }} WOW</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>In Pool</h3>
</header>
<p>{{ res.in_pool }}</p>
</section>
</div>
</div>
{% else %}
<p class="subheader"><strong>Invalid Confirmation</strong></p>
{% endif %}
</section>
</div>
<br><br>
<header class="major">
<h2><a href="/transaction/{{ tx_hash }}">View Transaction</a></h2>
</header>
</div>
</section>
{% endblock content %}

@ -6,8 +6,8 @@
<div class="container">
<section id="header">
<nav id="nav">
<a href="/"><h1>Go Back</h1><br>
<img src="//files.lzahq.tech/wow/WOW-Teleporter-720x1180.png" height=220 />
<a href="/"><h1>Go Back</h1>
<img src="//files.lzahq.tech/wow/WOW-Teleporter-720x1180.png" height=200 />
</a>
</nav>
</section>
@ -69,8 +69,15 @@
</div>
</div>
</section>
</div>
<br><br>
<section>
<h1 class="center">Prove Sending</h1>
<form method="get" action="/receipt" class="center">
<input type="text" name="tx_hash" placeholder="Transaction Hash / ID" value="{{ tx_hash }}" type="hidden" class="hidden">
<input type="text" name="address" placeholder="Address">
<input type="text" name="tx_key" placeholder="Transaction Key">
<input type="submit" value="Prove" class="btn">
</form>
</section>
<div class="tx-table">
<table>
<caption><h2>Inputs ({{ tx_info.0.as_json_full.vin | length | default(value="?") }})</h2></caption>
@ -110,4 +117,26 @@
</div>
</section>
<style>
.center {
margin: 0 auto;
display: block;
text-align: center;
}
.hidden {
display: none;
}
h1 {
font-size: 2em;
padding-bottom: 1em;
}
input[type=text] {
width: 50%;
margin: 1em;
}
input[type=submit] {
margin: 1em;
}
</style>
{% endblock content %}