diff --git a/rootfs/standard/var/www/mynode/bitcoin.py b/rootfs/standard/var/www/mynode/bitcoin.py index 4b71464a..3815c6c3 100644 --- a/rootfs/standard/var/www/mynode/bitcoin.py +++ b/rootfs/standard/var/www/mynode/bitcoin.py @@ -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') diff --git a/rootfs/standard/var/www/mynode/joininbox.py b/rootfs/standard/var/www/mynode/joininbox.py index dd213ea9..78621cb5 100644 --- a/rootfs/standard/var/www/mynode/joininbox.py +++ b/rootfs/standard/var/www/mynode/joininbox.py @@ -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) diff --git a/rootfs/standard/var/www/mynode/templates/joininbox.html b/rootfs/standard/var/www/mynode/templates/joininbox.html index 188f968a..cf8c2e22 100644 --- a/rootfs/standard/var/www/mynode/templates/joininbox.html +++ b/rootfs/standard/var/www/mynode/templates/joininbox.html @@ -9,6 +9,8 @@ home + {% include 'includes/message_display.html' %} +
Wallet | +Actions | + + + {% for wallet in wallets %} +
{{ wallet.name }} | ++ download + | +
+ *These wallets are not your main lightning wallet. These have been created manually or via other applications.
+ **Wallet files may contain private keys and sensitive data. Be very cautious when downloading copies.
+ ***Wallet files may be encrypted and require a password to use.
+