mirror of
https://git.wownero.com/lza_menace/wownero-explorer.git
synced 2024-08-15 01:03:26 +00:00
clean up code, add prove sending page and form
This commit is contained in:
parent
8d0709240a
commit
d9b7629931
9 changed files with 139 additions and 30 deletions
|
@ -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,
|
||||
}
|
||||
|
|
44
src/main.rs
44
src/main.rs
|
@ -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
|
||||
])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue