diff --git a/src/main.rs b/src/main.rs index 57dcf9a..d77759b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ extern crate qrcode_generator; mod data_types; use rocket::http::RawStr; +use rocket::request::Form; use rocket::response::Redirect; use rocket_contrib::json::{Json,JsonValue}; use rocket_contrib::templates::Template; @@ -104,9 +105,22 @@ fn get_transaction_by_hash(tx_hash: String) -> Template { Template::render("transaction", context) } -#[get("/address/")] -fn show_wallet_address(wallet_address: String) -> Template { - let address_uri = format!("monero:{}", wallet_address); +#[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!( + "monero:{}&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); @@ -164,11 +178,11 @@ fn search(value: &RawStr) -> Redirect { } else if sl == 95 { // Equal to 95 characters is probably a wallet address. // For this let's just redirect to the `show_wallet_address` route. - return Redirect::found(uri!(show_wallet_address: value.as_str())) + return Redirect::found(uri!(show_wallet_address: value.as_str(), "", "", "", "")) } else if sl == 105 { // Equal to 105 characters is probably an integrated address. // For this let's just redirect to the `show_wallet_address` route. - return Redirect::found(uri!(show_wallet_address: value.as_str())) + return Redirect::found(uri!(show_wallet_address: value.as_str(), "", "", "", "")) } else { // Anything else hasn't been implemented yet // so redirect to error response. diff --git a/static/css/main.css b/static/css/main.css index 4f9402d..a237b6e 100755 --- a/static/css/main.css +++ b/static/css/main.css @@ -297,3 +297,13 @@ p.subheader { margin: 0 auto; display: block; } + +.qr_form form { + text-align: center; +} + +.qr_form form input { + width: 75%; + margin: .5em auto; + padding-bottom: 1em; +} diff --git a/templates/address.html.tera b/templates/address.html.tera index 99818f6..89bf74f 100644 --- a/templates/address.html.tera +++ b/templates/address.html.tera @@ -13,23 +13,19 @@
- +
+

Want to generate a QR code for incoming payment?

+
+ + + + + +
+
- - {% endblock content %}