ensure wallet loaded - wip
This commit is contained in:
@@ -28,6 +28,28 @@ if not API_TOKEN:
|
||||
print(f"[web-wallet] API token: {API_TOKEN}")
|
||||
|
||||
|
||||
def create_base_rpc_client() -> AuthServiceProxy:
|
||||
url = f"http://{RIN_RPC_USER}:{RIN_RPC_PASSWORD}@{RIN_RPC_HOST}:{RIN_RPC_PORT}"
|
||||
return AuthServiceProxy(url, timeout=15)
|
||||
|
||||
|
||||
def ensure_wallet_loaded():
|
||||
"""Ensure the wallet is loaded at startup."""
|
||||
try:
|
||||
base_rpc = create_base_rpc_client()
|
||||
base_rpc.loadwallet(RIN_WALLET_NAME)
|
||||
print(f"[web-wallet] Loaded wallet: {RIN_WALLET_NAME}")
|
||||
except Exception as exc:
|
||||
print(f"[web-wallet] Warning: Could not load wallet {RIN_WALLET_NAME}: {exc}")
|
||||
# Try to create if loading failed
|
||||
try:
|
||||
base_rpc = create_base_rpc_client()
|
||||
base_rpc.createwallet(RIN_WALLET_NAME, False, True, "", False, True, True)
|
||||
print(f"[web-wallet] Created and loaded wallet: {RIN_WALLET_NAME}")
|
||||
except Exception as create_exc:
|
||||
print(f"[web-wallet] Warning: Could not create wallet {RIN_WALLET_NAME}: {create_exc}")
|
||||
|
||||
|
||||
def create_rpc_client() -> AuthServiceProxy:
|
||||
url = f"http://{RIN_RPC_USER}:{RIN_RPC_PASSWORD}@{RIN_RPC_HOST}:{RIN_RPC_PORT}/wallet/{RIN_WALLET_NAME}"
|
||||
return AuthServiceProxy(url, timeout=15)
|
||||
@@ -211,10 +233,10 @@ def static_proxy(path):
|
||||
|
||||
|
||||
def main():
|
||||
ensure_wallet_loaded()
|
||||
port = int(os.environ.get("RIN_WEB_WALLET_PORT", "8787"))
|
||||
app.run(host="127.0.0.1", port=port, debug=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user