diff --git a/account.py b/account.py index 8ca7144..bd1857b 100644 --- a/account.py +++ b/account.py @@ -57,6 +57,13 @@ def getBalance(account: str): return {'available': available, 'total': total} +def getAddress(account: str): + # Get the address + info = hsw.getAccountInfo(account, 'default') + if 'error' in info: + return '' + return info['receiveAddress'] + def getPendingTX(account: str): # Get the pending transactions info = hsw.getWalletTxHistory() diff --git a/main.py b/main.py index 8c7623c..03b2aa3 100644 --- a/main.py +++ b/main.py @@ -1,14 +1,16 @@ -from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory +from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory,send_file import os import dotenv import requests import account as account_module import render import re +from flask_qrcode import QRcode dotenv.load_dotenv() app = Flask(__name__) +qrcode = QRcode(app) @app.route('/') @@ -65,6 +67,7 @@ def send_page(): max = account_module.getBalance(account)['available'] # Subtract approx fee of 0.02 max = max - 0.02 + max = round(max, 2) message = '' address = '' @@ -120,6 +123,20 @@ def send(): return redirect("/send?message=" + response['error'] + "&address=" + address + "&amount=" + str(amount)) return redirect("/success?tx=" + response['tx']) + +@app.route('/receive') +def receive(): + # Check if the user is logged in + if request.cookies.get("account") is None: + return redirect("/login") + + account = account_module.check_account(request.cookies.get("account")) + if not account: + return redirect("/logout") + + address = account_module.getAddress(account) + + return render_template("receive.html", account=account, address=address) @app.route('/success') def success(): @@ -182,6 +199,13 @@ def logout(): #endregion + +#region Assets and default pages +@app.route('/qr/') +def qr(data): + return send_file(qrcode(data, mode="raw"), mimetype="image/png") + + @app.route('/assets/') def send_assets(path): return send_from_directory('templates/assets', path) @@ -194,12 +218,12 @@ def try_path(path): else: return page_not_found(404) - @app.errorhandler(404) def page_not_found(e): account = account_module.check_account(request.cookies.get("account")) return render_template('404.html',account=account), 404 +#endregion if __name__ == '__main__': app.run(debug=True) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 7843385..b7d627b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ requests gunicorn dnspython cryptography -requests-doh \ No newline at end of file +requests-doh +Flask-QRcode \ No newline at end of file diff --git a/templates/404.html b/templates/404.html index a03b659..5e189c5 100644 --- a/templates/404.html +++ b/templates/404.html @@ -13,6 +13,7 @@ + @@ -30,6 +31,7 @@ Send HNS +
diff --git a/templates/assets/fonts/MaterialIcons-Regular.eot b/templates/assets/fonts/MaterialIcons-Regular.eot new file mode 100644 index 0000000..70508eb Binary files /dev/null and b/templates/assets/fonts/MaterialIcons-Regular.eot differ diff --git a/templates/assets/fonts/MaterialIcons-Regular.svg b/templates/assets/fonts/MaterialIcons-Regular.svg new file mode 100644 index 0000000..a449327 --- /dev/null +++ b/templates/assets/fonts/MaterialIcons-Regular.svg @@ -0,0 +1,2373 @@ + + + + + +Created by FontForge 20151118 at Mon Feb 8 11:58:02 2016 + By shyndman +Copyright 2015 Google, Inc. All Rights Reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/assets/fonts/MaterialIcons-Regular.ttf b/templates/assets/fonts/MaterialIcons-Regular.ttf new file mode 100644 index 0000000..7015564 Binary files /dev/null and b/templates/assets/fonts/MaterialIcons-Regular.ttf differ diff --git a/templates/assets/fonts/MaterialIcons-Regular.woff b/templates/assets/fonts/MaterialIcons-Regular.woff new file mode 100644 index 0000000..b648a3e Binary files /dev/null and b/templates/assets/fonts/MaterialIcons-Regular.woff differ diff --git a/templates/assets/fonts/MaterialIcons-Regular.woff2 b/templates/assets/fonts/MaterialIcons-Regular.woff2 new file mode 100644 index 0000000..9fa2112 Binary files /dev/null and b/templates/assets/fonts/MaterialIcons-Regular.woff2 differ diff --git a/templates/assets/fonts/material-icons.min.css b/templates/assets/fonts/material-icons.min.css new file mode 100644 index 0000000..a14ee13 --- /dev/null +++ b/templates/assets/fonts/material-icons.min.css @@ -0,0 +1 @@ +@font-face{font-family:'Material Icons';font-style:normal;font-weight:400;src:url(MaterialIcons-Regular.eot);src:local('Material Icons'),local('MaterialIcons-Regular'),url(MaterialIcons-Regular.woff2) format('woff2'),url(MaterialIcons-Regular.woff) format('woff'),url(MaterialIcons-Regular.ttf) format('truetype')}.material-icons{font-family:'Material Icons';font-weight:400;font-style:normal;font-size:24px;display:inline-block;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;font-feature-settings:'liga'} \ No newline at end of file diff --git a/templates/assets/js/receive.min.js b/templates/assets/js/receive.min.js new file mode 100644 index 0000000..a8e8594 --- /dev/null +++ b/templates/assets/js/receive.min.js @@ -0,0 +1 @@ +function copyAddress(){var e=document.getElementById("copyLink").getAttribute("address"),t=document.createElement("input");t.value=e,document.body.appendChild(t),t.select(),t.setSelectionRange(0,99999),navigator.clipboard.writeText(t.value),document.body.removeChild(t),document.getElementById("copyLink").innerHTML="Copied!"} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 0c68eba..0c38862 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,6 +13,7 @@ + @@ -30,6 +31,7 @@ Send HNS +
diff --git a/templates/receive.html b/templates/receive.html new file mode 100644 index 0000000..1ce02b6 --- /dev/null +++ b/templates/receive.html @@ -0,0 +1,86 @@ + + + + + + + Receive - FireWallet + + + + + + + + + + + + +
+ +
+
+ +
+

Receive HNS or domains to this address

+
+
+
+

{{address}}

+

Use this address to receive HNS or Handshake domains from other people or wallets.

Copy +
+
+
+
+
+ +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/templates/send.html b/templates/send.html index dc03148..5b74a86 100644 --- a/templates/send.html +++ b/templates/send.html @@ -13,6 +13,7 @@ + @@ -30,6 +31,7 @@ Send HNS +
diff --git a/templates/success.html b/templates/success.html index 2a6cddf..2eb2117 100644 --- a/templates/success.html +++ b/templates/success.html @@ -13,6 +13,7 @@ + @@ -30,6 +31,7 @@ Send HNS +
diff --git a/templates/tx.html b/templates/tx.html index 27a5a23..a434150 100644 --- a/templates/tx.html +++ b/templates/tx.html @@ -13,6 +13,7 @@ + @@ -30,6 +31,7 @@ Send HNS +