diff --git a/.gitignore b/.gitignore index 2662f04..22dee40 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ docker-compose.prod.yml docker-compose.stage.yml docker-compose.dev.yml +data diff --git a/src/data_types.rs b/src/data_types.rs index ca8e6a1..833238e 100644 --- a/src/data_types.rs +++ b/src/data_types.rs @@ -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 +} + +#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)] +pub struct CheckTxKeyResult { + pub confirmations: u32, + pub in_pool: bool, + pub received: u64, +} diff --git a/src/main.rs b/src/main.rs index fcff56a..d0215a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,8 +42,6 @@ fn build_rpc(method: &str, raw_data: Option, raw: bool) -> RequestBui #[get("/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/")] 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?
&&")] +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/")] 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 { -// 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 ]) diff --git a/static/css/dopetrope.css b/static/css/dopetrope.css index 83899fd..d685dfa 100644 --- a/static/css/dopetrope.css +++ b/static/css/dopetrope.css @@ -2078,7 +2078,7 @@ input, select, textarea { /* Nav */ #nav { - margin: 2.5em 0 0 0; + margin: .5em 0 0 0; } #nav > ul { diff --git a/templates/address.html.tera b/templates/address.html.tera index 639f199..368968f 100644 --- a/templates/address.html.tera +++ b/templates/address.html.tera @@ -6,8 +6,8 @@
diff --git a/templates/block.html.tera b/templates/block.html.tera index 33a659a..c60bb2d 100644 --- a/templates/block.html.tera +++ b/templates/block.html.tera @@ -6,8 +6,8 @@
diff --git a/templates/index.html.tera b/templates/index.html.tera index adb7d9e..3d6a4ff 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -7,7 +7,7 @@ -
-

+
+

Prove Sending

+ + + + + + +
@@ -110,4 +117,26 @@ + + {% endblock content %}

Inputs ({{ tx_info.0.as_json_full.vin | length | default(value="?") }})