ensure wallet loaded - wip
This commit is contained in:
@@ -19,7 +19,7 @@ Send RIN to another wallet address.
|
||||
|
||||
**Example:**
|
||||
```bash
|
||||
./send_rin.sh rin1qvj0yyt9phvled9kxflju3p687a4s7kareglpk5 100.0
|
||||
./send_rin.sh rin1qm5qg07qh0fy3tgxc3ftfgq0fujgfgm4n6ggt5f 100.0
|
||||
```
|
||||
|
||||
### check_balance.sh
|
||||
@@ -59,7 +59,7 @@ General-purpose RPC call script for any RIN RPC method.
|
||||
./rpc_call.sh getinfo
|
||||
./rpc_call.sh getnewaddress myaccount
|
||||
./rpc_call.sh listtransactions "*" 10
|
||||
./rpc_call.sh validateaddress rin1qvj0yyt9phvled9kxflju3p687a4s7kareglpk5
|
||||
./rpc_call.sh validateaddress rin1qm5qg07qh0fy3tgxc3ftfgq0fujgfgm4n6ggt5f
|
||||
./rpc_call.sh loadwallet
|
||||
```
|
||||
|
||||
@@ -87,6 +87,7 @@ Set which wallet the web interface should use.
|
||||
|
||||
### find_address.sh
|
||||
Check if an address belongs to any loaded wallet.
|
||||
we need to see what is this address.
|
||||
|
||||
```bash
|
||||
./find_address.sh rin1qvj0yyt9phvled9kxflju3p687a4s7kareglpk5
|
||||
|
||||
@@ -176,3 +176,4 @@ echo " curl -s -u \"$RPC_USER:$RPC_PASSWORD\" -d '{\"jsonrpc\": \"2.0\", \"id\
|
||||
echo ""
|
||||
echo " List wallets:"
|
||||
echo " ./list_wallets.sh"
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ set -euo pipefail
|
||||
SCRIPT_DIR=$(cd -- "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
CONTAINER="rincoin-node2"
|
||||
|
||||
if ! sudo docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then
|
||||
echo "Error: ${CONTAINER} container is not running. Start it with 'sudo docker start ${CONTAINER}'."
|
||||
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER}$"; then
|
||||
echo "Error: ${CONTAINER} container is not running. Start it with 'docker start ${CONTAINER}'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -43,4 +43,3 @@ export PYTHONPATH="${SCRIPT_DIR}"
|
||||
flask run --host 127.0.0.1 --port 8787
|
||||
|
||||
# Note: To clean up the virtual environment, run: rm -rf "${SCRIPT_DIR}/venv"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user