From cfa14e7450122cf15d46bdbd1e1aa0c17f4150aa Mon Sep 17 00:00:00 2001 From: Marcos Date: Fri, 23 May 2025 16:02:23 +0200 Subject: [PATCH 1/2] fix: connection problems, healthcheck postgres --- .vscode/launch.json | 2 +- docker/docker-compose.yml | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 58374344..1c0e8945 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -21,7 +21,7 @@ }, "env": { "ASPNETCORE_ENVIRONMENT": "Development", - "POSTGRES_CONNECTIONSTRING": "Host=127.0.0.1;Port=5432;Database=nodeguard;Username=rw_dev;Password=rw_dev", + "POSTGRES_CONNECTIONSTRING": "Host=127.0.0.1;Port=25432;Database=nodeguard;Username=rw_dev;Password=rw_dev", "BITCOIN_NETWORK": "REGTEST", "MAXIMUM_WITHDRAWAL_BTC_AMOUNT": "21000000", "NBXPLORER_ENABLE_CUSTOM_BACKEND": "true", diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5bb4af40..13021b8a 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.4' +version: "3.4" name: nodeguard services: @@ -22,12 +22,16 @@ services: platform: linux/amd64 hostname: nbxplorer ports: - - "32838:32838" + - "32838:32838" + depends_on: + - nbxplorer_postgres environment: NBXPLORER_NETWORK: regtest NBXPLORER_BIND: 0.0.0.0:32838 NBXPLORER_TRIMEVENTS: 10000 NBXPLORER_SIGNALFILESDIR: /datadir + #Keeping dbtrie for dev until it is fully removed since we would need to modify nbxplorer docker image to wait for the db to be ready + NBXPLORER_DBTRIE: 0 NBXPLORER_POSTGRES: Host=nbxplorer_postgres;Port=5432;Database=nbxplorer;Username=rw_dev;Password=rw_dev NBXPLORER_CHAINS: "btc" NBXPLORER_BTCRPCUSER: "polaruser" @@ -36,7 +40,7 @@ services: NBXPLORER_BTCNODEENDPOINT: host.docker.internal:19444 command: ["--noauth"] volumes: - - "bitcoin_datadir:/root/.bitcoin" + - "bitcoin_datadir:/root/.bitcoin" nbxplorer_postgres: container_name: nbxplorer_postgres @@ -51,12 +55,15 @@ services: - nbxplorer_postgres_data:/var/lib/postgresql/data ports: - 35432:5432 - - + healthcheck: + test: ["CMD", "pg_isready", "-U", "rw_dev"] + interval: 10s + timeout: 5s + retries: 5 volumes: - nodeguard_postgres_data: - bitcoin_datadir: - nbxplorer_datadir: - nbxplorer_postgres_data: - nodeguard_data_keys_dir: + nodeguard_postgres_data: + bitcoin_datadir: + nbxplorer_datadir: + nbxplorer_postgres_data: + nodeguard_data_keys_dir: From 902ad88b1ab10b907a819b47234b188b865bfd5f Mon Sep 17 00:00:00 2001 From: Marcos Date: Thu, 24 Jul 2025 16:02:00 +0200 Subject: [PATCH 2/2] feat: return wallet id with utxos --- src/Proto/nodeguard.proto | 1 + src/Rpc/NodeGuardService.cs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Proto/nodeguard.proto b/src/Proto/nodeguard.proto index a511f37e..037bf575 100644 --- a/src/Proto/nodeguard.proto +++ b/src/Proto/nodeguard.proto @@ -371,6 +371,7 @@ message Utxo { int64 amount = 1; string outpoint = 2; string address = 3; + int64 walletId = 4; } message GetUtxosResponse { diff --git a/src/Rpc/NodeGuardService.cs b/src/Rpc/NodeGuardService.cs index 0d5d8b6b..e458ead0 100644 --- a/src/Rpc/NodeGuardService.cs +++ b/src/Rpc/NodeGuardService.cs @@ -232,7 +232,7 @@ public override async Task RequestWithdrawal(RequestW throw new RpcException(new Status(StatusCode.Internal, "Derivation strategy not found")); utxos = await _coinSelectionService.GetUTXOsByOutpointAsync(derivationStrategyBase, outpoints); - + } // Create destination objects for the withdrawal request @@ -963,13 +963,15 @@ public override async Task GetUtxos(GetUtxosRequest request, S { Amount = (Money)utxo.Value, Outpoint = utxo.Outpoint.ToString(), - Address = utxo.Address.ToString() + Address = utxo.Address.ToString(), + WalletId = wallet.Id })); unconfirmed.AddRange(walletUtxos.Unconfirmed.UTXOs.Select(utxo => new Utxo() { Amount = (Money)utxo.Value, Outpoint = utxo.Outpoint.ToString(), - Address = utxo.Address.ToString() + Address = utxo.Address.ToString(), + WalletId = wallet.Id })); }