wallet deletion now works
This commit is contained in:
parent
09d74ad470
commit
0e0e308019
32
app/app.py
32
app/app.py
@ -89,5 +89,37 @@ def set_active_wallet():
|
|||||||
|
|
||||||
active_wallet = {} # Store active wallets in memory
|
active_wallet = {} # Store active wallets in memory
|
||||||
|
|
||||||
|
@app.route("/delete_active_wallet", methods=["DELETE"])
|
||||||
|
def delete_active_wallet():
|
||||||
|
global active_wallet # Assuming active_wallet is a global variable
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Retrieve the active wallet from the request data
|
||||||
|
wallet_name = request.json.get("walletName")
|
||||||
|
|
||||||
|
# Retrieve RPC credentials from localStorage (cookies)
|
||||||
|
rpc_host = request.cookies.get("rpcHost")
|
||||||
|
rpc_port = request.cookies.get("rpcPort")
|
||||||
|
rpc_user = request.cookies.get("rpcUser")
|
||||||
|
rpc_password = request.cookies.get("rpcPassword")
|
||||||
|
|
||||||
|
# Establish a connection to the Bitcoin node using RPC credentials
|
||||||
|
rpc_connection = AuthServiceProxy(
|
||||||
|
f"http://{rpc_user}:{rpc_password}@{rpc_host}:{rpc_port}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Unload the specified wallet from the node
|
||||||
|
rpc_connection.unloadwallet(wallet_name)
|
||||||
|
|
||||||
|
# Remove the wallet from active_wallet (if it's stored there)
|
||||||
|
if wallet_name in active_wallet:
|
||||||
|
del active_wallet[wallet_name]
|
||||||
|
|
||||||
|
return jsonify({"message": f"Deleted active wallet '{wallet_name}'"})
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
28
app/static/java/deleteWallet.js
Normal file
28
app/static/java/deleteWallet.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Function to delete the active wallet
|
||||||
|
function deleteActiveWallet() {
|
||||||
|
const activeWallet = localStorage.getItem('activeWallet');
|
||||||
|
|
||||||
|
fetch('/delete_active_wallet', {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ walletName: activeWallet }),
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
console.log('Active wallet deleted successfully');
|
||||||
|
// Optionally, perform any additional actions after successful deletion
|
||||||
|
} else {
|
||||||
|
console.error('Failed to delete active wallet');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attach a click event listener to the delete wallet button
|
||||||
|
const deleteButton = document.getElementById('deleteWalletButton');
|
||||||
|
deleteButton.addEventListener('click', deleteActiveWallet);
|
||||||
|
|
@ -544,14 +544,14 @@ video {
|
|||||||
position: static;
|
position: static;
|
||||||
}
|
}
|
||||||
|
|
||||||
.m-2 {
|
|
||||||
margin: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.m-1 {
|
.m-1 {
|
||||||
margin: 0.25rem;
|
margin: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-2 {
|
||||||
|
margin: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.mb-4 {
|
.mb-4 {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
@ -568,10 +568,6 @@ video {
|
|||||||
margin-top: 1.5rem;
|
margin-top: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mb-2 {
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-fit {
|
.w-fit {
|
||||||
width: -moz-fit-content;
|
width: -moz-fit-content;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
@ -581,14 +577,23 @@ video {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rounded-sm {
|
.rounded {
|
||||||
border-radius: 0.125rem;
|
border-radius: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rounded-md {
|
.rounded-md {
|
||||||
border-radius: 0.375rem;
|
border-radius: 0.375rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rounded-sm {
|
||||||
|
border-radius: 0.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-blue-400 {
|
||||||
|
--tw-bg-opacity: 1;
|
||||||
|
background-color: rgb(96 165 250 / var(--tw-bg-opacity));
|
||||||
|
}
|
||||||
|
|
||||||
.bg-green-600 {
|
.bg-green-600 {
|
||||||
--tw-bg-opacity: 1;
|
--tw-bg-opacity: 1;
|
||||||
background-color: rgb(22 163 74 / var(--tw-bg-opacity));
|
background-color: rgb(22 163 74 / var(--tw-bg-opacity));
|
||||||
@ -599,32 +604,32 @@ video {
|
|||||||
background-color: rgb(38 38 38 / var(--tw-bg-opacity));
|
background-color: rgb(38 38 38 / var(--tw-bg-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bg-red-500 {
|
||||||
|
--tw-bg-opacity: 1;
|
||||||
|
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
|
||||||
|
}
|
||||||
|
|
||||||
.bg-red-600 {
|
.bg-red-600 {
|
||||||
--tw-bg-opacity: 1;
|
--tw-bg-opacity: 1;
|
||||||
background-color: rgb(220 38 38 / var(--tw-bg-opacity));
|
background-color: rgb(220 38 38 / var(--tw-bg-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.bg-green-500 {
|
.p-1 {
|
||||||
--tw-bg-opacity: 1;
|
padding: 0.25rem;
|
||||||
background-color: rgb(34 197 94 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-blue-400 {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(96 165 250 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-blue-500 {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-2 {
|
.p-2 {
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-1 {
|
.px-4 {
|
||||||
padding: 0.25rem;
|
padding-left: 1rem;
|
||||||
|
padding-right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.py-2 {
|
||||||
|
padding-top: 0.5rem;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.font-mono {
|
.font-mono {
|
||||||
@ -654,6 +659,11 @@ video {
|
|||||||
color: rgb(255 255 255 / var(--tw-text-opacity));
|
color: rgb(255 255 255 / var(--tw-text-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hover\:bg-blue-300:hover {
|
||||||
|
--tw-bg-opacity: 1;
|
||||||
|
background-color: rgb(147 197 253 / var(--tw-bg-opacity));
|
||||||
|
}
|
||||||
|
|
||||||
.hover\:bg-green-800:hover {
|
.hover\:bg-green-800:hover {
|
||||||
--tw-bg-opacity: 1;
|
--tw-bg-opacity: 1;
|
||||||
background-color: rgb(22 101 52 / var(--tw-bg-opacity));
|
background-color: rgb(22 101 52 / var(--tw-bg-opacity));
|
||||||
@ -663,13 +673,3 @@ video {
|
|||||||
--tw-bg-opacity: 1;
|
--tw-bg-opacity: 1;
|
||||||
background-color: rgb(127 29 29 / var(--tw-bg-opacity));
|
background-color: rgb(127 29 29 / var(--tw-bg-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.hover\:bg-blue-200:hover {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(191 219 254 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.hover\:bg-blue-300:hover {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(147 197 253 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
@ -90,5 +90,10 @@
|
|||||||
<div id="activeWalletDisplay" class="p-1 m-2 font-bold bg-green-600 rounded-md w-fit"></div>
|
<div id="activeWalletDisplay" class="p-1 m-2 font-bold bg-green-600 rounded-md w-fit"></div>
|
||||||
<script src="{{ url_for('static', filename='java/activeWalletDisplay.js') }}"></script>
|
<script src="{{ url_for('static', filename='java/activeWalletDisplay.js') }}"></script>
|
||||||
|
|
||||||
|
<button id="deleteWalletButton" class="px-4 py-2 text-white bg-red-500 rounded">
|
||||||
|
Delete Active Wallet
|
||||||
|
</button>
|
||||||
|
<script src="{{ url_for('static', filename='java/deleteWallet.js') }}"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user