add remainder of routes to use
parent
3556b27497
commit
5358696d79
@ -0,0 +1,4 @@
|
||||
#[get("/")]
|
||||
pub fn show() -> &'static str {
|
||||
"address details and qr"
|
||||
}
|
@ -1,12 +1,23 @@
|
||||
use rocket::serde::json;
|
||||
use rocket::serde::json::{Value, json};
|
||||
|
||||
#[get("/height/<block_height>")]
|
||||
pub fn get_height(block_height: i32) -> json::Value {
|
||||
return json::json!({
|
||||
#[get("/height/<height>")]
|
||||
pub fn height(height: i32) -> Value {
|
||||
let payload: Value = json!({
|
||||
"method": "get_block",
|
||||
"params": {
|
||||
"height": block_height
|
||||
"height": height
|
||||
}
|
||||
});
|
||||
return payload;
|
||||
}
|
||||
|
||||
#[get("/hash/<hash>")]
|
||||
pub fn hash(hash: String) -> Value {
|
||||
let payload: Value = json!({
|
||||
"method": "get_block",
|
||||
"params": {
|
||||
"hash": hash
|
||||
}
|
||||
});
|
||||
return payload;
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
pub mod block;
|
||||
// pub mod block::get_height;
|
||||
pub mod transaction;
|
||||
pub mod address;
|
||||
pub mod search;
|
@ -0,0 +1,5 @@
|
||||
#[get("/<value>")]
|
||||
pub fn show(value: String) -> &'static str {
|
||||
println!("found args: {}", value);
|
||||
"search options/args"
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
use rocket::serde::json::{Value, json};
|
||||
|
||||
#[get("/<hash>")]
|
||||
pub fn hash(hash: String) -> Value {
|
||||
let params: Value = json!({
|
||||
"txs_hashes": [&hash],
|
||||
"decode_as_json": true
|
||||
});
|
||||
// let mut res: GetTransactions = build_rpc(
|
||||
// &"get_transactions", Some(params), true
|
||||
// ).send().unwrap().json().unwrap();
|
||||
// if res.txs.len() > 0 {
|
||||
// for f in &mut res.txs {
|
||||
// f.process();
|
||||
// };
|
||||
// };
|
||||
// let context = json!({
|
||||
// "tx_info": res.txs,
|
||||
// "hash": hash,
|
||||
// "debug": res.clone()
|
||||
// });
|
||||
return params;
|
||||
}
|
||||
|
||||
#[get("/receipt?<address>&<hash>&<key>")]
|
||||
pub fn receipt(address: String, hash: String, key: String) -> Value {
|
||||
let payload: Value = json!({
|
||||
"method": "check_tx_key",
|
||||
"params": {
|
||||
"address": address,
|
||||
"txid": hash,
|
||||
"tx_key": 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,
|
||||
// "hash": hash,
|
||||
// "address": address
|
||||
// });
|
||||
// Template::render("receipt", context)
|
||||
return payload;
|
||||
}
|
Loading…
Reference in New Issue