Add ability to change alias
This commit is contained in:
parent
046eeaa092
commit
f6523fcc21
|
@ -82,7 +82,7 @@ fi
|
||||||
|
|
||||||
# Setup LND Node Name
|
# Setup LND Node Name
|
||||||
if [ ! -f /home/bitcoin/.mynode/.lndalias ]; then
|
if [ ! -f /home/bitcoin/.mynode/.lndalias ]; then
|
||||||
echo "mynodebtc.com [myNode]"> /home/bitcoin/.mynode/.lndalias
|
echo "mynodebtc.com [myNode]" > /home/bitcoin/.mynode/.lndalias
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ from pprint import pprint, pformat
|
||||||
from threading import Timer
|
from threading import Timer
|
||||||
from bitcoin_info import *
|
from bitcoin_info import *
|
||||||
from lightning_info import *
|
from lightning_info import *
|
||||||
|
from settings import reboot_device
|
||||||
import base64
|
import base64
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
|
@ -10,7 +11,7 @@ import pam
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
import os.path
|
import os
|
||||||
|
|
||||||
|
|
||||||
mynode_lnd = Blueprint('mynode_lnd',__name__)
|
mynode_lnd = Blueprint('mynode_lnd',__name__)
|
||||||
|
@ -234,3 +235,35 @@ def page_lnd_lndconnect():
|
||||||
"lndconnect_remote_rest_img": lndconnect_remote_rest_img
|
"lndconnect_remote_rest_img": lndconnect_remote_rest_img
|
||||||
}
|
}
|
||||||
return render_template('lndconnect.html', **templateData)
|
return render_template('lndconnect.html', **templateData)
|
||||||
|
|
||||||
|
|
||||||
|
@mynode_lnd.route("/lnd/change_alias", methods=["POST"])
|
||||||
|
def page_lnd_change_alias():
|
||||||
|
# Load page
|
||||||
|
p = pam.pam()
|
||||||
|
pw = request.form.get('password_change_alias')
|
||||||
|
if pw == None or p.authenticate("admin", pw) == False:
|
||||||
|
return redirect(url_for(".page_lnd", error_message="Invalid Password"))
|
||||||
|
|
||||||
|
# Change alias
|
||||||
|
alias = request.form.get('alias')
|
||||||
|
if alias == None or alias == "":
|
||||||
|
return redirect(url_for(".page_lnd", error_message="Empty Alias"))
|
||||||
|
if len(alias) > 35:
|
||||||
|
return redirect(url_for(".page_lnd", error_message="Invalid Alias"))
|
||||||
|
with open("/home/bitcoin/.mynode/.lndalias", "w") as f:
|
||||||
|
utf8_alias = alias.decode('utf-8', 'ignore')
|
||||||
|
f.write(utf8_alias)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
# Reboot
|
||||||
|
t = Timer(1.0, reboot_device)
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
# Wait until device is restarted
|
||||||
|
templateData = {
|
||||||
|
"title": "myNode Reboot",
|
||||||
|
"header_text": "Restarting",
|
||||||
|
"subheader_text": "This will take several minutes..."
|
||||||
|
}
|
||||||
|
return render_template('reboot.html', **templateData)
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
alias="{{alias}}"
|
||||||
|
|
||||||
function downloadMacaroon() {
|
function downloadMacaroon() {
|
||||||
$("#download_macaroon_form").submit();
|
$("#download_macaroon_form").submit();
|
||||||
download_macaroon_dialog.dialog( "close" );
|
download_macaroon_dialog.dialog( "close" );
|
||||||
|
@ -43,6 +45,32 @@
|
||||||
download_macaroon_dialog.dialog( "close" );
|
download_macaroon_dialog.dialog( "close" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function change_alias() {
|
||||||
|
$("#change_alias_form").submit();
|
||||||
|
change_alias_dialog.dialog( "close" );
|
||||||
|
}
|
||||||
|
change_alias_dialog = $( "#change-alias-dialog" ).dialog({
|
||||||
|
autoOpen: false,
|
||||||
|
resizable: false,
|
||||||
|
height: "auto",
|
||||||
|
width: 600,
|
||||||
|
modal: true,
|
||||||
|
position: { my: "center top", at: "center top", of: window, collision: "none" },
|
||||||
|
buttons: {
|
||||||
|
"Save": change_alias,
|
||||||
|
Cancel: function() {
|
||||||
|
change_alias_dialog.dialog( "close" );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
open: function() {
|
||||||
|
$("#alias").val(alias)
|
||||||
|
$("#password_change_alias").val("")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#change_alias").on("click", function() {
|
||||||
|
change_alias_dialog.dialog( "open" );
|
||||||
|
});
|
||||||
|
|
||||||
function lndconnect() {
|
function lndconnect() {
|
||||||
$("#lndconnect_form").submit();
|
$("#lndconnect_form").submit();
|
||||||
lndconnect_dialog.dialog( "close" );
|
lndconnect_dialog.dialog( "close" );
|
||||||
|
@ -148,7 +176,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="info_tile">
|
<div class="info_tile">
|
||||||
<div class="info_tile_header">Alias</div>
|
<div class="info_tile_header">Alias</div>
|
||||||
<div class="info_tile_contents">{{alias}}</div>
|
<div class="info_tile_contents">{{alias}} <a class="ui-button ui-widget ui-corner-all mynode_button_small" id="change_alias" href="#"><span class="ui-icon ui-icon-gear"></a></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="info_tile">
|
<div class="info_tile">
|
||||||
<div class="info_tile_header">Num Peers</div>
|
<div class="info_tile_header">Num Peers</div>
|
||||||
|
@ -249,6 +277,23 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</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>
|
||||||
|
<p>Please enter a new alias and your current password.</p>
|
||||||
|
<b>New Alias:</b>
|
||||||
|
<br/>
|
||||||
|
<input type="text" name="alias" id="alias" value="" class="text ui-widget-content ui-corner-all" size="35" maxlength="35">
|
||||||
|
<br/><br/>
|
||||||
|
<b>Password:</b>
|
||||||
|
<br/>
|
||||||
|
<input type="password" name="password_change_alias" id="password_change_alias" 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="lndconnect-dialog" title="LND Connect Access" style="display:none;">
|
<div id="lndconnect-dialog" title="LND Connect Access" style="display:none;">
|
||||||
<form id="lndconnect_form" name="lndconnect_form" action="/lnd/lndconnect" method="POST">
|
<form id="lndconnect_form" name="lndconnect_form" action="/lnd/lndconnect" method="POST">
|
||||||
<p>LND Connect info will allow access to your Lightning Wallet! Do not share this info with others
|
<p>LND Connect info will allow access to your Lightning Wallet! Do not share this info with others
|
||||||
|
|
Loading…
Reference in New Issue
Block a user