List JM wallets and add download button

This commit is contained in:
Taylor Helsper 2021-03-26 23:16:00 -05:00
parent 095bb1ef01
commit 00bd292e4a
3 changed files with 67 additions and 2 deletions

View File

@ -121,7 +121,7 @@ def bitcoind_status_page():
}
return render_template('bitcoin.html', **templateData)
@mynode_bitcoin.route("/download_wallet", methods=["GET"])
@mynode_bitcoin.route("/bitcoin/download_wallet", methods=["GET"])
def bitcoin_download_wallet():
check_logged_in()
wallet_name = request.args.get('wallet')

View File

@ -1,12 +1,28 @@
from flask import Blueprint, render_template, redirect
from flask import Blueprint, render_template, redirect, request, flash, send_from_directory
from user_management import check_logged_in
from device_info import read_ui_settings
from systemctl_info import *
import os
import time
import subprocess
import os
mynode_joininbox = Blueprint('mynode_joininbox',__name__)
def get_jm_wallets():
wallets = []
wallet_folder = "/mnt/hdd/mynode/joinmarket/wallets/"
try:
if os.path.isdir(wallet_folder):
for f in os.listdir(wallet_folder):
wallet_path = wallet_folder + f
if os.path.isfile( wallet_path ):
wallet = {}
wallet["name"] = f
wallets.append(wallet)
except Exception as e:
wallets.append({"name": str(e)})
return wallets
### Page functions
@mynode_joininbox.route("/joininbox")
@ -16,6 +32,25 @@ def joininbox_page():
# Load page
templateData = {
"title": "myNode JoininBox / JoinMarket",
"wallets": get_jm_wallets(),
"ui_settings": read_ui_settings(),
}
return render_template('joininbox.html', **templateData)
@mynode_joininbox.route("/joininbox/download_wallet", methods=["GET"])
def joininbox_download_wallet():
check_logged_in()
wallet_folder = "/mnt/hdd/mynode/joinmarket/wallets/"
wallet_name = request.args.get('wallet')
if wallet_name is None:
flash("Error finding wallet name!", category="error")
return redirect("/joininbox")
full_file_path = wallet_folder + wallet_name
if not os.path.isfile( full_file_path ):
time.sleep(3)
flash("Error finding wallet to download!", category="error")
return redirect("/joininbox")
return send_from_directory(directory=wallet_folder, filename=wallet_name, as_attachment=True)

View File

@ -9,6 +9,8 @@
<a class="ui-button ui-widget ui-corner-all mynode_back" href="/"><span class="ui-icon ui-icon-home"></span>home&nbsp;</a>
</div>
{% include 'includes/message_display.html' %}
<div class="main_header">JoininBox / JoinMarket</div>
<br/>
@ -20,6 +22,34 @@
</div>
{% if wallets is not none and wallets|length > 0 %}
<br/>
<div class="main_header">Wallets</div>
<table class="bitcoind_table">
<thead class="bitcoind_table_header">
<td>Wallet</td>
<td>Actions</td>
</thead>
<tbody>
{% for wallet in wallets %}
<tr>
<td>{{ wallet.name }}</td>
<td>
<a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 100px;" href="/joininbox/download_wallet?wallet={{wallet.name|urlencode}}">download</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<p style="font-size: 12px; color: gray; text-align: center;">
*These wallets are not your main lightning wallet. These have been created manually or via other applications.<br/>
**Wallet files may contain private keys and sensitive data. Be very cautious when downloading copies.<br/>
***Wallet files may be encrypted and require a password to use.
</p>
<br/>
{% endif %}
<div class="instructions">
<div class="instructions-header">Instructions to setup JoininBox / JoinMarket</div>
<ol class="instructions-steps">