From d8d53b810c9dfe57c5955dff81dd3454090196c1 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 1 Jul 2020 01:17:12 -0700 Subject: [PATCH] adding wallet address view --- src/main.rs | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7b065c8..cc298ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -111,32 +111,32 @@ fn get_transaction_by_hash(tx_hash: String) -> Template { Template::render("transaction", context) } -// #[get("/address/?&&&")] -// fn show_wallet_address( -// wallet_address: String, -// tx_amount: Option, -// tx_description: Option, -// recipient_name: Option, -// tx_payment_id: Option -// ) -> Template { -// let address_uri = format!( -// "wownero:{}&tx_amount={}&tx_description={}&recipient_name={}&tx_payment_id={}", -// wallet_address, -// tx_amount.unwrap_or("".to_string()), -// tx_description.unwrap_or("".to_string()), -// recipient_name.unwrap_or("".to_string()), -// tx_payment_id.unwrap_or("".to_string()) -// ); -// let qr_code: String = qrcode_generator::to_svg_to_string(address_uri, QrCodeEcc::Low, 256, None) -// .unwrap(); -// let qr_code: String = base64::encode(qr_code); -// let context: JsonValue = json!({ -// "qr_code": qr_code, -// "wallet_address": wallet_address -// }); -// Template::render("address", context) -// } -// +#[get("/address/?&&&")] +fn show_wallet_address( + wallet_address: String, + tx_amount: Option, + tx_description: Option, + recipient_name: Option, + tx_payment_id: Option + ) -> Template { + let address_uri = format!( + "wownero:{}&tx_amount={}&tx_description={}&recipient_name={}&tx_payment_id={}", + wallet_address, + tx_amount.unwrap_or("".to_string()), + tx_description.unwrap_or("".to_string()), + recipient_name.unwrap_or("".to_string()), + tx_payment_id.unwrap_or("".to_string()) + ); + let qr_code: String = qrcode_generator::to_svg_to_string(address_uri, QrCodeEcc::Low, 256, None) + .unwrap(); + let qr_code: String = base64::encode(qr_code); + let context: JsonValue = json!({ + "qr_code": qr_code, + "wallet_address": wallet_address + }); + Template::render("address", context) +} + // #[get("/search?")] // fn search(value: &RawStr) -> Redirect { // // This search implementation is not ideal but it works. @@ -270,7 +270,7 @@ fn main() { // get_block_by_height, // get_block_by_hash, get_transaction_by_hash, - // show_wallet_address, + show_wallet_address, error ]) .mount("/static", StaticFiles::from("./static"))