diff --git a/rootfs/standard/usr/share/mynode/bitcoin.conf b/rootfs/standard/usr/share/mynode/bitcoin.conf index 419bcd4c..3a79fcea 100644 --- a/rootfs/standard/usr/share/mynode/bitcoin.conf +++ b/rootfs/standard/usr/share/mynode/bitcoin.conf @@ -22,6 +22,9 @@ rpcallowip=192.168.0.0/16 main.wallet=wallet.dat main.wallet=joinmarket_wallet.dat +test.wallet=wallet.dat +test.wallet=joinmarket_wallet.dat + # Enable Bloom filters whitelist=bloomfilter@127.0.0.1 whitelist=bloomfilter@10.0.0.0/8 diff --git a/rootfs/standard/var/www/mynode/bitcoin_info.py b/rootfs/standard/var/www/mynode/bitcoin_info.py index b5ef1fd0..ad8e1517 100644 --- a/rootfs/standard/var/www/mynode/bitcoin_info.py +++ b/rootfs/standard/var/www/mynode/bitcoin_info.py @@ -1,6 +1,7 @@ from config import * from threading import Timer from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException +import urllib import subprocess import copy import time @@ -14,7 +15,7 @@ bitcoin_recent_blocks = None bitcoin_recent_blocks_last_cache_height = 566000 bitcoin_peers = [] bitcoin_network_info = None -bitcoin_wallet_info = None +bitcoin_wallets = None bitcoin_mempool = None bitcoin_version = None @@ -71,7 +72,7 @@ def update_bitcoin_other_info(): global bitcoin_peers global bitcoin_network_info global bitcoin_mempool - global bitcoin_wallet_info + global bitcoin_wallets while bitcoin_blockchain_info == None: # Wait until we have gotten the important info... @@ -103,7 +104,14 @@ def update_bitcoin_other_info(): bitcoin_mempool = rpc_connection.getmempoolinfo() # Get wallet info - bitcoin_wallet_info = rpc_connection.getwalletinfo() + wallets = rpc_connection.listwallets() + wallet_data = [] + for w in wallets: + wallet_name = urllib.pathname2url(w) + wallet_rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332/wallet/%s"%(rpc_user, rpc_pass, wallet_name), timeout=60) + wallet_info = wallet_rpc_connection.getwalletinfo() + wallet_data.append(wallet_info) + bitcoin_wallets = wallet_data except: pass @@ -187,9 +195,9 @@ def get_bitcoin_mempool_size(): size = float(info["bytes"]) / 1000 / 1000 return "{:.3} MB".format(size) -def get_bitcoin_wallet_info(): - global bitcoin_wallet_info - return copy.deepcopy(bitcoin_wallet_info) +def get_bitcoin_wallets(): + global bitcoin_wallets + return copy.deepcopy(bitcoin_wallets) def get_default_bitcoin_config(): try: diff --git a/rootfs/standard/var/www/mynode/bitcoind.py b/rootfs/standard/var/www/mynode/bitcoind.py index e46808fb..7e424f00 100644 --- a/rootfs/standard/var/www/mynode/bitcoind.py +++ b/rootfs/standard/var/www/mynode/bitcoind.py @@ -23,6 +23,8 @@ def runcmd(cmd): results = str(e) return results +def cleanup_download_wallets(): + os.system("rm -rf /tmp/download_wallets/*") ### Page functions @mynode_bitcoind.route("/bitcoind") @@ -35,7 +37,7 @@ def bitcoind_status_page(): blockdata = get_bitcoin_recent_blocks() peerdata = get_bitcoin_peers() networkdata = get_bitcoin_network_info() - walletdata = get_bitcoin_wallet_info() + walletdata = get_bitcoin_wallets() version = get_bitcoin_version() rpc_password = get_bitcoin_rpc_password() @@ -89,16 +91,6 @@ def bitcoind_status_page(): if ("localaddresses" in networkdata) and (len(networkdata["localaddresses"]) > 0): local_address = "{}:{}".format(networkdata["localaddresses"][0]["address"], networkdata["localaddresses"][0]["port"]) - # Balance - walletinfo = {} - walletinfo["balance"] = 0.0 - walletinfo["unconfirmed_balance"] = 0.0 - if walletdata != None: - if "balance" in walletdata: - walletinfo["balance"] = walletdata["balance"] - if "unconfirmed_balance" in walletdata: - walletinfo["unconfirmed_balance"] = walletdata["unconfirmed_balance"] - except Exception as e: templateData = { "title": "myNode Bitcoin Error", @@ -121,18 +113,33 @@ def bitcoind_status_page(): "mempool_tx": mempool["size"], "mempool_size": "{:.3} MB".format(float(mempool["bytes"]) / 1000 / 1000), "is_testnet_enabled": is_testnet_enabled(), - "confirmed_balance": walletinfo["balance"], - "unconfirmed_balance": walletinfo["unconfirmed_balance"], + "wallets": walletdata, "bitcoin_whitepaper_exists": bitcoin_whitepaper_exists, "version": version, "ui_settings": read_ui_settings() } return render_template('bitcoind_status.html', **templateData) -@mynode_bitcoind.route("/bitcoind/wallet.dat") -def bitcoin_wallet_dat(): +@mynode_bitcoind.route("/bitcoind/download_wallet", methods=["GET"]) +def bitcoin_download_wallet(): check_logged_in() - return send_from_directory(directory="/mnt/hdd/mynode/bitcoin/", filename="wallet.dat") + wallet_name = request.args.get('wallet') + if wallet_name is None: + flash("Error finding wallet to download!", category="error") + return redirect("/bitcoind") + + os.system("mkdir -p /tmp/download_wallets") + os.system("chmod 777 /tmp/download_wallets") + runcmd("-rpcwallet='"+wallet_name+"' dumpwallet '/tmp/download_wallets/"+wallet_name+"'") + + if not os.path.isfile("/tmp/download_wallets/"+wallet_name): + flash("Error exporting wallet data for download", category="error") + return redirect("/bitcoind") + + t = Timer(3.0, cleanup_download_wallets) + t.start() + + return send_from_directory(directory="/tmp/download_wallets/", filename=wallet_name, as_attachment=True) @mynode_bitcoind.route("/bitcoind/bitcoin_whitepaper.pdf") def bitcoin_whitepaper_pdf(): diff --git a/rootfs/standard/var/www/mynode/templates/bitcoind_status.html b/rootfs/standard/var/www/mynode/templates/bitcoind_status.html index 6a040f3a..7277a824 100644 --- a/rootfs/standard/var/www/mynode/templates/bitcoind_status.html +++ b/rootfs/standard/var/www/mynode/templates/bitcoind_status.html @@ -22,6 +22,8 @@ home  + {% include 'includes/message_display.html' %} +
Bitcoin Status

@@ -93,22 +95,16 @@ - + - + - + - {% if confirmed_balance > 0.0 or unconfirmed_balance > 0.0 %} - - - - - {% endif %}
Configview / editview / edit
CLICLICLI
Whitepaperdownloaddownload
Wallet Backupdownload
@@ -121,22 +117,37 @@ - - {% if confirmed_balance > 0.0 %} + {% if wallets is not none %}
-
Wallet balance
+
Wallets
- - + + + - - - - + {% for wallet in wallets %} + + + + + + {% endfor %}
Confirmed BalanceUnconfirmed BalanceWalletBalanceActions
{{ "%.8f"|format(confirmed_balance) }}{{ "%.8f"|format(unconfirmed_balance) }}
{{ wallet.walletname }} + {{ "%.8f"|format(wallet.balance) }} + {% if wallet.unconfirmed_balance > 0 %} +
+ {{ "%.8f"|format(wallet.unconfirmed_balance) }} pending + {% endif %} +
+ 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. +

{% endif %}