Add download link or readonly macaroon

This commit is contained in:
Taylor Helsper 2019-11-09 12:06:30 -06:00
parent b09d322331
commit d2a9e33559
3 changed files with 18 additions and 51 deletions

View File

@ -1,3 +1,5 @@
=== v0.1.65 ===
=== v0.1.64 ===
- Improve logging for upgrades
- Remove LND Admin

View File

@ -129,19 +129,20 @@ def lnd_tls_cert():
check_logged_in()
return send_from_directory(directory="/mnt/hdd/mynode/lnd/", filename="tls.cert")
@mynode_lnd.route("/lnd/admin.macaroon", methods=["POST"])
def lnd_macaroon():
@mynode_lnd.route("/lnd/admin.macaroon")
def lnd_admin_macaroon():
check_logged_in()
p = pam.pam()
pw = request.form.get('password_download_macaroon')
if pw == None or p.authenticate("admin", pw) == False:
flash("Invalid Password", category="error")
return redirect(url_for(".page_lnd"))
# Download macaroon
return send_from_directory(directory="/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/", filename="admin.macaroon")
@mynode_lnd.route("/lnd/readonly.macaroon")
def lnd_readonly_macaroon():
check_logged_in()
# Download macaroon
return send_from_directory(directory="/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/", filename="readonly.macaroon")
@mynode_lnd.route("/lnd/channel.backup")
def lnd_channel_backup():
check_logged_in()

View File

@ -8,34 +8,6 @@
$(document).ready(function() {
alias="{{alias}}"
function downloadMacaroon() {
$("#download_macaroon_form").submit();
download_macaroon_dialog.dialog( "close" );
}
download_macaroon_dialog = $( "#download-macaroon-dialog" ).dialog({
autoOpen: false,
resizable: false,
height: "auto",
width: 600,
modal: true,
position: { my: "center top", at: "center top", of: window, collision: "none" },
buttons: {
"Download": downloadMacaroon,
Cancel: function() {
download_macaroon_dialog.dialog( "close" );
}
},
open: function() {
$("#password_download_macaroon").val("")
}
});
$("#download_macaroon").on("click", function() {
download_macaroon_dialog.dialog( "open" );
});
$("#download_macaroon_form").on("submit", function() {
download_macaroon_dialog.dialog( "close" );
});
function change_alias() {
$("#change_alias_form").submit();
@ -163,7 +135,13 @@
<div class="info_tile">
<div class="info_tile_header">Admin Macaroon</div>
<div class="info_tile_contents">
<a class="ui-button ui-widget ui-corner-all mynode_button_small" id="download_macaroon" style="width: 70%;" href="#">download</a>
<a class="ui-button ui-widget ui-corner-all mynode_button_small" id="admin_macaroon" style="width: 70%;" href="/lnd/admin.macaroon">download</a>
</div>
</div>
<div class="info_tile">
<div class="info_tile_header">Read Only Macaroon</div>
<div class="info_tile_contents">
<a class="ui-button ui-widget ui-corner-all mynode_button_small" id="readonly_macaroon" style="width: 70%;" href="/lnd/readonly.macaroon">download</a>
</div>
</div>
{% endif %}
@ -274,20 +252,6 @@
</div>
{% endif %}
<div id="download-macaroon-dialog" title="Download Macaroon" style="display:none;">
<form id="download_macaroon_form" name="download_macaroon_form" action="/lnd/admin.macaroon" method="POST">
<p>The macaroon is an important key for controlling your Lightning Wallet. Do not share this file with others
or they will be able to control your funds.</p>
<p>Please enter your password to download your macaroon file.</p>
<b>Password:</b>
<br/>
<input type="password" name="password_download_macaroon" id="password_download_macaroon" value="" class="text ui-widget-content ui-corner-all">
<!-- Allow form submission with keyboard without duplicating the dialog button -->
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
</form>
</div>
<div id="change-alias-dialog" title="Change LND Alias" style="display:none;">
<form id="change_alias_form" name="change_alias_form" action="/lnd/change_alias" method="POST">
<p>The LND alias is a public name for your lightning node and you can modify it with the form below. Changing the alias will restart your myNode to take effect.</p>