mirror of
https://github.com/mynodebtc/mynode.git
synced 2024-11-12 08:29:16 +00:00
Show wallet info on bitcoin page
This commit is contained in:
parent
1b14ea73a3
commit
232c68485b
|
@ -22,6 +22,9 @@ rpcallowip=192.168.0.0/16
|
||||||
main.wallet=wallet.dat
|
main.wallet=wallet.dat
|
||||||
main.wallet=joinmarket_wallet.dat
|
main.wallet=joinmarket_wallet.dat
|
||||||
|
|
||||||
|
test.wallet=wallet.dat
|
||||||
|
test.wallet=joinmarket_wallet.dat
|
||||||
|
|
||||||
# Enable Bloom filters
|
# Enable Bloom filters
|
||||||
whitelist=bloomfilter@127.0.0.1
|
whitelist=bloomfilter@127.0.0.1
|
||||||
whitelist=bloomfilter@10.0.0.0/8
|
whitelist=bloomfilter@10.0.0.0/8
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from config import *
|
from config import *
|
||||||
from threading import Timer
|
from threading import Timer
|
||||||
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
|
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
|
||||||
|
import urllib
|
||||||
import subprocess
|
import subprocess
|
||||||
import copy
|
import copy
|
||||||
import time
|
import time
|
||||||
|
@ -14,7 +15,7 @@ bitcoin_recent_blocks = None
|
||||||
bitcoin_recent_blocks_last_cache_height = 566000
|
bitcoin_recent_blocks_last_cache_height = 566000
|
||||||
bitcoin_peers = []
|
bitcoin_peers = []
|
||||||
bitcoin_network_info = None
|
bitcoin_network_info = None
|
||||||
bitcoin_wallet_info = None
|
bitcoin_wallets = None
|
||||||
bitcoin_mempool = None
|
bitcoin_mempool = None
|
||||||
bitcoin_version = None
|
bitcoin_version = None
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ def update_bitcoin_other_info():
|
||||||
global bitcoin_peers
|
global bitcoin_peers
|
||||||
global bitcoin_network_info
|
global bitcoin_network_info
|
||||||
global bitcoin_mempool
|
global bitcoin_mempool
|
||||||
global bitcoin_wallet_info
|
global bitcoin_wallets
|
||||||
|
|
||||||
while bitcoin_blockchain_info == None:
|
while bitcoin_blockchain_info == None:
|
||||||
# Wait until we have gotten the important info...
|
# Wait until we have gotten the important info...
|
||||||
|
@ -103,7 +104,14 @@ def update_bitcoin_other_info():
|
||||||
bitcoin_mempool = rpc_connection.getmempoolinfo()
|
bitcoin_mempool = rpc_connection.getmempoolinfo()
|
||||||
|
|
||||||
# Get wallet info
|
# 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:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -187,9 +195,9 @@ def get_bitcoin_mempool_size():
|
||||||
size = float(info["bytes"]) / 1000 / 1000
|
size = float(info["bytes"]) / 1000 / 1000
|
||||||
return "{:.3} MB".format(size)
|
return "{:.3} MB".format(size)
|
||||||
|
|
||||||
def get_bitcoin_wallet_info():
|
def get_bitcoin_wallets():
|
||||||
global bitcoin_wallet_info
|
global bitcoin_wallets
|
||||||
return copy.deepcopy(bitcoin_wallet_info)
|
return copy.deepcopy(bitcoin_wallets)
|
||||||
|
|
||||||
def get_default_bitcoin_config():
|
def get_default_bitcoin_config():
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -23,6 +23,8 @@ def runcmd(cmd):
|
||||||
results = str(e)
|
results = str(e)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def cleanup_download_wallets():
|
||||||
|
os.system("rm -rf /tmp/download_wallets/*")
|
||||||
|
|
||||||
### Page functions
|
### Page functions
|
||||||
@mynode_bitcoind.route("/bitcoind")
|
@mynode_bitcoind.route("/bitcoind")
|
||||||
|
@ -35,7 +37,7 @@ def bitcoind_status_page():
|
||||||
blockdata = get_bitcoin_recent_blocks()
|
blockdata = get_bitcoin_recent_blocks()
|
||||||
peerdata = get_bitcoin_peers()
|
peerdata = get_bitcoin_peers()
|
||||||
networkdata = get_bitcoin_network_info()
|
networkdata = get_bitcoin_network_info()
|
||||||
walletdata = get_bitcoin_wallet_info()
|
walletdata = get_bitcoin_wallets()
|
||||||
version = get_bitcoin_version()
|
version = get_bitcoin_version()
|
||||||
rpc_password = get_bitcoin_rpc_password()
|
rpc_password = get_bitcoin_rpc_password()
|
||||||
|
|
||||||
|
@ -89,16 +91,6 @@ def bitcoind_status_page():
|
||||||
if ("localaddresses" in networkdata) and (len(networkdata["localaddresses"]) > 0):
|
if ("localaddresses" in networkdata) and (len(networkdata["localaddresses"]) > 0):
|
||||||
local_address = "{}:{}".format(networkdata["localaddresses"][0]["address"], networkdata["localaddresses"][0]["port"])
|
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:
|
except Exception as e:
|
||||||
templateData = {
|
templateData = {
|
||||||
"title": "myNode Bitcoin Error",
|
"title": "myNode Bitcoin Error",
|
||||||
|
@ -121,18 +113,33 @@ def bitcoind_status_page():
|
||||||
"mempool_tx": mempool["size"],
|
"mempool_tx": mempool["size"],
|
||||||
"mempool_size": "{:.3} MB".format(float(mempool["bytes"]) / 1000 / 1000),
|
"mempool_size": "{:.3} MB".format(float(mempool["bytes"]) / 1000 / 1000),
|
||||||
"is_testnet_enabled": is_testnet_enabled(),
|
"is_testnet_enabled": is_testnet_enabled(),
|
||||||
"confirmed_balance": walletinfo["balance"],
|
"wallets": walletdata,
|
||||||
"unconfirmed_balance": walletinfo["unconfirmed_balance"],
|
|
||||||
"bitcoin_whitepaper_exists": bitcoin_whitepaper_exists,
|
"bitcoin_whitepaper_exists": bitcoin_whitepaper_exists,
|
||||||
"version": version,
|
"version": version,
|
||||||
"ui_settings": read_ui_settings()
|
"ui_settings": read_ui_settings()
|
||||||
}
|
}
|
||||||
return render_template('bitcoind_status.html', **templateData)
|
return render_template('bitcoind_status.html', **templateData)
|
||||||
|
|
||||||
@mynode_bitcoind.route("/bitcoind/wallet.dat")
|
@mynode_bitcoind.route("/bitcoind/download_wallet", methods=["GET"])
|
||||||
def bitcoin_wallet_dat():
|
def bitcoin_download_wallet():
|
||||||
check_logged_in()
|
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")
|
@mynode_bitcoind.route("/bitcoind/bitcoin_whitepaper.pdf")
|
||||||
def bitcoin_whitepaper_pdf():
|
def bitcoin_whitepaper_pdf():
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
<a class="ui-button ui-widget ui-corner-all mynode_back" href="/"><span class="ui-icon ui-icon-home"></span>home </a>
|
<a class="ui-button ui-widget ui-corner-all mynode_back" href="/"><span class="ui-icon ui-icon-home"></span>home </a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% include 'includes/message_display.html' %}
|
||||||
|
|
||||||
<div class="main_header">Bitcoin Status</div>
|
<div class="main_header">Bitcoin Status</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
@ -93,22 +95,16 @@
|
||||||
<table class="info_table">
|
<table class="info_table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Config</th>
|
<th>Config</th>
|
||||||
<td><a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 70%;" href="/bitcoind/config">view / edit</a></td>
|
<td><a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 100px;" href="/bitcoind/config">view / edit</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>CLI</th>
|
<th>CLI</th>
|
||||||
<td><a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 70%;" href="/bitcoind/cli">CLI</a></td>
|
<td><a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 100px;" href="/bitcoind/cli">CLI</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Whitepaper</th>
|
<th>Whitepaper</th>
|
||||||
<td><a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 70%;" href="/bitcoind/bitcoin_whitepaper.pdf">download</a></td>
|
<td><a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 100px;" href="/bitcoind/bitcoin_whitepaper.pdf">download</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if confirmed_balance > 0.0 or unconfirmed_balance > 0.0 %}
|
|
||||||
<tr>
|
|
||||||
<th>Wallet Backup</th>
|
|
||||||
<td><a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 70%;" href="/bitcoind/wallet.dat">download</a></td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -121,22 +117,37 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if wallets is not none %}
|
||||||
{% if confirmed_balance > 0.0 %}
|
|
||||||
<br/>
|
<br/>
|
||||||
<div class="main_header">Wallet balance</div>
|
<div class="main_header">Wallets</div>
|
||||||
<table class="bitcoind_table">
|
<table class="bitcoind_table">
|
||||||
<thead class="bitcoind_table_header">
|
<thead class="bitcoind_table_header">
|
||||||
<td>Confirmed Balance</td>
|
<td>Wallet</td>
|
||||||
<td>Unconfirmed Balance</td>
|
<td>Balance</td>
|
||||||
|
<td>Actions</td>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
{% for wallet in wallets %}
|
||||||
<td>{{ "%.8f"|format(confirmed_balance) }}</td>
|
<tr>
|
||||||
<td>{{ "%.8f"|format(unconfirmed_balance) }}</td>
|
<td>{{ wallet.walletname }}</td>
|
||||||
</tr>
|
<td>
|
||||||
|
{{ "%.8f"|format(wallet.balance) }}
|
||||||
|
{% if wallet.unconfirmed_balance > 0 %}
|
||||||
|
<br/>
|
||||||
|
<span style="font-size: 12px;">{{ "%.8f"|format(wallet.unconfirmed_balance) }} pending</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 100px;" href="/bitcoind/download_wallet?wallet={{wallet.walletname|urlencode}}">download</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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.
|
||||||
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user