Add delete button for bitcoin wallets
This commit is contained in:
parent
8214914f16
commit
cede26e2fa
|
@ -168,6 +168,9 @@ def update_bitcoin_other_info():
|
|||
|
||||
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_info["can_delete"] = True
|
||||
if wallet_name == "wallet.dat" or wallet_name == "joinmarket_wallet.dat":
|
||||
wallet_info["can_delete"] = False
|
||||
wallet_data.append(wallet_info)
|
||||
bitcoin_wallets = wallet_data
|
||||
create_default_wallets()
|
||||
|
|
|
@ -116,6 +116,23 @@ def bitcoin_download_wallet():
|
|||
|
||||
return download_file(directory="/tmp/download_wallets/", filename=wallet_name)
|
||||
|
||||
@mynode_bitcoin.route("/bitcoin/delete_wallet", methods=["GET"])
|
||||
def bitcoin_delete_wallet():
|
||||
check_logged_in()
|
||||
wallet_name = request.args.get('wallet')
|
||||
if wallet_name is None:
|
||||
flash("Error finding wallet to delete!", category="error")
|
||||
return redirect("/bitcoin")
|
||||
|
||||
run_bitcoincli_command("unloadwallet {}".format(wallet_name))
|
||||
run_linux_cmd("rm -rf /mnt/hdd/mynode/bitcoin/{}".format(wallet_name))
|
||||
|
||||
# Update wallet info
|
||||
update_bitcoin_other_info()
|
||||
|
||||
flash("Wallet Deleted", category="message")
|
||||
return redirect("/bitcoin")
|
||||
|
||||
@mynode_bitcoin.route("/bitcoin/bitcoin_whitepaper.pdf")
|
||||
def bitcoin_whitepaper_pdf():
|
||||
check_logged_in()
|
||||
|
|
|
@ -5,6 +5,16 @@
|
|||
|
||||
|
||||
<script>
|
||||
function delete_wallet(wallet_name, wallet_name_encoded) {
|
||||
if (confirm("Are you sure you want to delete the '"+wallet_name+"'?\n\n CAUTION: This cannot be undone and could cause lost funds.")) {
|
||||
window.location.href='/bitcoin/delete_wallet?wallet='+wallet_name_encoded;
|
||||
}
|
||||
}
|
||||
|
||||
function download_wallet(wallet_name_encoded) {
|
||||
window.location.href = "/bitcoin/download_wallet?wallet="+wallet_name_encoded;
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$( document ).tooltip();
|
||||
|
@ -231,7 +241,7 @@
|
|||
<thead class="bitcoin_table_header">
|
||||
<td>Wallet</td>
|
||||
<td>Balance</td>
|
||||
<td>Actions</td>
|
||||
<td colspan="2">Actions</td>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for wallet in wallets %}
|
||||
|
@ -244,8 +254,13 @@
|
|||
<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="/bitcoin/download_wallet?wallet={{wallet.walletname|urlencode}}">download</a>
|
||||
<td style="width: 80px;">
|
||||
<button class="ui-button ui-widget ui-corner-all mynode_button" title="Download" style="width: 60px;" onclick="download_wallet('{{wallet.walletname|urlencode}}')"><i class="fas fa-arrow-down"></i></button>
|
||||
</td>
|
||||
<td style="width: 80px;">
|
||||
{% if wallet.can_delete %}
|
||||
<button class="ui-button ui-widget ui-corner-all mynode_button" title="Delete" style="width: 60px;" onclick="delete_wallet('{{wallet.walletname}}', '{{wallet.walletname|urlencode}}')"><i class='fas fa-trash'></i></button>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user