seperated connect to node python to src

This commit is contained in:
0ceanSlim 2024-01-02 13:44:46 -05:00
parent 98b8494967
commit c2bc4ac9b0
3 changed files with 12 additions and 9 deletions

View File

@ -2,17 +2,10 @@ from flask import Flask, request, jsonify, render_template
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from src import create_wallet
from src import create_wallet, connect_to_node
app = Flask(__name__, static_folder="static")
# Function to establish an RPC connection to the Bitcoin node
def connect_to_node(rpc_host, rpc_port, rpc_user, rpc_password):
rpc_connection = AuthServiceProxy(
f"http://{rpc_user}:{rpc_password}@{rpc_host}:{rpc_port}"
)
return rpc_connection
@app.route("/")
def show_wallet_form():
return render_template("index.html")

View File

@ -1,4 +1,5 @@
from .create_wallet import create_wallet
from .connect_to_node import connect_to_node
__all__ = ["create_wallet",]
__all__ = ["create_wallet", "connect_to_node"]

View File

@ -0,0 +1,9 @@
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
# Function to establish an RPC connection to the Elements node
def connect_to_node(rpc_host, rpc_port, rpc_user, rpc_password):
rpc_connection = AuthServiceProxy(
f"http://{rpc_user}:{rpc_password}@{rpc_host}:{rpc_port}"
)
return rpc_connection