improve qr code page and adding more meta to others

master
lza_menace 4 years ago
parent 136756c690
commit a2c4739344

@ -234,3 +234,11 @@ pub struct RingSignatures {
pub txnFee: Option<u64>,
pub outPk: Option<Vec<String>>
}
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
pub struct QRData {
pub tx_amount: String,
pub tx_description: String,
pub recipient_name: String,
pub tx_payment_id: String
}

@ -109,19 +109,26 @@ fn show_wallet_address(
recipient_name: Option<String>,
tx_payment_id: Option<String>
) -> Template {
let qr_data: QRData = QRData {
tx_amount: tx_amount.unwrap_or("".to_string()),
tx_description: tx_description.unwrap_or("".to_string()),
recipient_name: recipient_name.unwrap_or("".to_string()),
tx_payment_id: tx_payment_id.unwrap_or("".to_string())
};
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())
qr_data.tx_amount,
qr_data.tx_description,
qr_data.recipient_name,
qr_data.tx_payment_id
);
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,
"qr_data": qr_data,
"wallet_address": wallet_address
});
Template::render("address", context)

@ -308,6 +308,10 @@ p.subheader {
padding-bottom: 1em;
}
.qr_code {
text-align: center;
}
#slim-header {
text-align: center;
}

@ -11,18 +11,25 @@
<section>
<header class="major">
<h2>Wallet Address</h2>
<p class="subheader"><strong>Address</strong>: {{ wallet_address }}</p>
</header>
<div class="center">
<div class="center qr_code">
<img src="data:image/svg+xml;base64,{{ qr_code }}" width=200 class="center">
<ul>
<li><strong>Address</strong>: {{ wallet_address }}</li>
<li><strong>Tx Amount</strong>: {{ qr_data.tx_amount }}</li>
<li><strong>Tx Payment Id</strong>: {{ qr_data.tx_payment_id }}</li>
<li><strong>Tx Description</strong>: {{ qr_data.tx_description }}</li>
<li><strong>Recipient Name</strong>: {{ qr_data.recipient_name }}</li>
</ul>
</div>
<div class="qr_form">
<p>Want to generate a QR code for incoming payment?</p>
<form action="" method="get">
<input type="text" name="tx_amount" placeholder="Enter amount for transaction.">
<input type="text" name="tx_payment_id" placeholder="Enter a payment ID for transaction.">
<input type="text" name="recipient_name" placeholder="Enter the name of the recipient.">
<input type="text" name="tx_description" placeholder="Enter a description for the transaction.">
<input type="text" name="tx_amount" placeholder="Enter amount for transaction." value="{{ qr_data.tx_amount }}">
<input type="text" name="tx_payment_id" placeholder="Enter a payment ID for transaction." value="{{ qr_data.tx_payment_id }}">
<input type="text" name="tx_description" placeholder="Enter a description for the transaction." value="{{ qr_data.tx_description }}">
<input type="text" name="recipient_name" placeholder="Enter the name of the recipient." value="{{ qr_data.recipient_name }}">
<button type="submit" value="">Regenerate QR Code</button>
</form>
</div>

@ -78,11 +78,11 @@
<br><br>
<div class="tx-table">
<table>
<caption><h2>Transactions ({% if tx_hashes %}{{ tx_hashes | length - 1 }}{% else %}?{% endif %})</h2></caption>
<caption><h2>Transactions ({% if tx_hashes %}{{ tx_hashes | length }}{% else %}0{% endif %})</h2></caption>
{% if tx_hashes %}
<tr>
<th>Hash</th>
</tr>
{% if tx_hashes %}
{% for hash in tx_hashes %}
<tr>
<td><a href="/transaction/{{ hash }}">{{ hash | truncate(length=12) }}</a></td>

@ -2,14 +2,6 @@
{% block content %}
{% for i in tx_info %}
{{i.block_height}}
{{i.block_timestamp}}
{{i.double_spend_seen}}
{{i.in_pool}}
{{i.output_indices}}
{% endfor %}
<section id="main">
<div class="container">
<section id="slim-header">
@ -20,7 +12,7 @@
<header class="major">
<h2>Transaction {{ tx_hash | truncate(length=4) }}</h2>
<p class="subheader"><strong>Full Hash</strong>: {{ tx_hash }}</p>
<p class="subheader"><strong>Block Timestamp</strong>: {% if tx_info.0.block_timestamp %}{{ tx_info.0.block_timestamp }}{% else %}?{% endif %}</p>
<p class="subheader"><strong>Block Timestamp</strong>: {% if tx_info.0.block_timestamp %}{{ tx_info.0.block_timestamp | date(format="%Y-%m-%d %H:%M") }}{% else %}?{% endif %}</p>
</header>
<div class="row">
<div class="col-4 col-6-medium col-12-small">
@ -47,10 +39,46 @@
<p>{{ tx_info.0.double_spend_seen }}</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Transaction Fee</h3>
</header>
<p>{{ tx_info.0.as_json_full.rct_signatures.txnFee / 1000000000000 | default(value="?") }} WOW</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Version</h3>
</header>
<p>{{ tx_info.0.as_json_full.version | default(value="?") }}</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Inputs / Outputs</h3>
</header>
<p>{{ tx_info.0.as_json_full.vin | length | default(value="?") }} / {{ tx_info.0.as_json_full.vout | length | default(value="?") }}</p>
</section>
</div>
</div>
</section>
</div>
<br><br>
<header class="major">
<div class="tx-table">
<header>
<h2>Stealth Addresses</h2>
</header>
<ol>
{% for i in tx_info.0.as_json_full.vout %}
<li>{{ i.target.key }}</li>
{% endfor %}
</ol>
</div>
</header>
<header class="major">
{% if tx_info.0.block_height %}<h2><a href="/block/height/{{ tx_info.0.block_height }}">View Block</a></h2>{% endif %}
</header>