|
|
@ -42,8 +42,6 @@ fn build_rpc(method: &str, raw_data: Option<JsonValue>, raw: bool) -> RequestBui
|
|
|
|
|
|
|
|
|
|
|
|
#[get("/block/hash/<block_hash>")]
|
|
|
|
#[get("/block/hash/<block_hash>")]
|
|
|
|
fn get_block_by_hash(block_hash: String) -> Template {
|
|
|
|
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!({
|
|
|
|
let payload: JsonValue = json!({
|
|
|
|
"method": "get_block",
|
|
|
|
"method": "get_block",
|
|
|
|
"params": {
|
|
|
|
"params": {
|
|
|
@ -59,8 +57,6 @@ fn get_block_by_hash(block_hash: String) -> Template {
|
|
|
|
|
|
|
|
|
|
|
|
#[get("/block/height/<block_height>")]
|
|
|
|
#[get("/block/height/<block_height>")]
|
|
|
|
fn get_block_by_height(block_height: String) -> Template {
|
|
|
|
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!({
|
|
|
|
let payload: JsonValue = json!({
|
|
|
|
"method": "get_block",
|
|
|
|
"method": "get_block",
|
|
|
|
"params": {
|
|
|
|
"params": {
|
|
|
@ -74,11 +70,31 @@ fn get_block_by_height(block_height: String) -> Template {
|
|
|
|
Template::render("block", &res.result)
|
|
|
|
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>")]
|
|
|
|
#[get("/transaction/<tx_hash>")]
|
|
|
|
fn get_transaction_by_hash(tx_hash: String) -> Template {
|
|
|
|
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!({
|
|
|
|
let params: JsonValue = json!({
|
|
|
|
"txs_hashes": [&tx_hash],
|
|
|
|
"txs_hashes": [&tx_hash],
|
|
|
|
"decode_as_json": true
|
|
|
|
"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("/")]
|
|
|
|
#[get("/")]
|
|
|
|
fn index() -> Template {
|
|
|
|
fn index() -> Template {
|
|
|
|
let daemon_uri = env::var("DAEMON_URI").unwrap();
|
|
|
|
let daemon_uri = env::var("DAEMON_URI").unwrap();
|
|
|
@ -265,6 +268,7 @@ fn main() {
|
|
|
|
get_block_by_height,
|
|
|
|
get_block_by_height,
|
|
|
|
get_block_by_hash,
|
|
|
|
get_block_by_hash,
|
|
|
|
get_transaction_by_hash,
|
|
|
|
get_transaction_by_hash,
|
|
|
|
|
|
|
|
get_tx_receipt,
|
|
|
|
show_wallet_address,
|
|
|
|
show_wallet_address,
|
|
|
|
error
|
|
|
|
error
|
|
|
|
])
|
|
|
|
])
|
|
|
|