How get bitcoin dashboard code

Comment

Author: Admin | 2025-04-28

I'm trying to create a bitcoin wallet website and I've written some python code so far.I have downloaded bitcoin core and have created a wallet in the directory:C:\Users\MylesUsername\AppData\Roaming\Bitcoin\wallets\test2 In which I can see my wallet.dat file but when I try to run my python code I get the error message:Traceback (most recent call last): File "C:\Users\MylesUsername\Desktop\app.py", line 11, in wallet = Wallet(wallet_name) File "C:\Users\MylesUsername\AppData\Local\Programs\Python\Python39\lib\site-packages\bitcoinlib\wallets.py", line 1408, in __init__ raise WalletError("Wallet '%s' not found, please specify correct wallet ID or name." % wallet)bitcoinlib.wallets.WalletError: Wallet 'C:\Users\MylesUsername\AppData\Roaming\Bitcoin\wallets\test2\wallet.dat' not found, please specify correct wallet ID or name. so it seems my python code can't find the wallet.dat file? I also don't know why it's mentioning the bitcoinlib directory at the start?This is the python code for my bitcoin wallet website so far:from flask import Flask, render_template, request, redirect, url_for, sessionfrom bitcoinlib.wallets import Walletapp = Flask(__name__)app.secret_key = 'your_secret_key' # Change this to a secret key# Provide the name or ID of the walletwallet_name = 'C:\\Users\\MylesUsername\\AppData\\Roaming\\Bitcoin\\wallets\\test2\\wallet.dat' # Change this to your actual wallet name or ID# Create a Wallet objectwallet = Wallet(wallet_name)# User data (this should be stored securely in a database in a production environment)users = { 'user1': { 'password': 'password1', 'address': wallet.get_key().address # Generate a Bitcoin address for the user }}# Check if the user is logged indef is_user_logged_in(): return 'username' in session# Create a root route@app.route('/')def home(): if is_user_logged_in(): return redirect(url_for('dashboard')) return "Welcome to the Bitcoin Flask app!"# Create a login page@app.route('/login', methods=['GET', 'POST'])def login(): if is_user_logged_in(): return redirect(url_for('dashboard')) if request.method == 'POST': username = request.form['username'] password = request.form['password'] if username in users and users[username]['password'] == password: session['username'] = username # Store the username in the session return redirect(url_for('dashboard')) else: return render_template('login.html', error='Invalid username or password.') return render_template('login.html')# Create a dashboard page@app.route('/dashboard')def dashboard(): if not is_user_logged_in(): return redirect(url_for('login')) username = session['username'] address = users[username]['address'] balance = wallet.balance() return render_template('dashboard.html', username=username, address=address, balance=balance)# Create a send Bitcoin page@app.route('/send', methods=['GET', 'POST'])def send(): if not is_user_logged_in(): return redirect(url_for('login')) if request.method == 'POST': to_address = request.form['to_address'] amount = float(request.form['amount']) # Send the Bitcoin txid = wallet.send_to(to_address, amount, fee='normal') return redirect(url_for('dashboard')) return render_template('send.html')# Create a reset password page@app.route('/reset_password', methods=['GET', 'POST'])def reset_password(): if not is_user_logged_in(): return redirect(url_for('login')) username = session['username'] if request.method == 'POST': new_password = request.form['new_password'] if len(new_password) I've check my bitcoin core software and it seems to be running fine and has completed downloading everything.I've added a bitcoin.conf file to my bitcoin core folder which allows rpc.I've made sure the wallet isn't encrypted

Add Comment