diff --git a/backend/mempool-config.sample.json b/backend/mempool-config.sample.json index d7ac621a3..48b79a175 100644 --- a/backend/mempool-config.sample.json +++ b/backend/mempool-config.sample.json @@ -34,7 +34,8 @@ "HOST": "127.0.0.1", "PORT": 8332, "USERNAME": "mempool", - "PASSWORD": "mempool" + "PASSWORD": "mempool", + "TIMEOUT": 60000 }, "ELECTRUM": { "HOST": "127.0.0.1", @@ -48,7 +49,8 @@ "HOST": "127.0.0.1", "PORT": 8332, "USERNAME": "mempool", - "PASSWORD": "mempool" + "PASSWORD": "mempool", + "TIMEOUT": 60000 }, "DATABASE": { "ENABLED": true, @@ -92,7 +94,8 @@ "LND": { "TLS_CERT_PATH": "tls.cert", "MACAROON_PATH": "readonly.macaroon", - "REST_API_URL": "https://localhost:8080" + "REST_API_URL": "https://localhost:8080", + "TIMEOUT": 10000 }, "CLIGHTNING": { "SOCKET": "lightning-rpc" diff --git a/backend/src/__fixtures__/mempool-config.template.json b/backend/src/__fixtures__/mempool-config.template.json index 0ad2bc10d..276cddbfb 100644 --- a/backend/src/__fixtures__/mempool-config.template.json +++ b/backend/src/__fixtures__/mempool-config.template.json @@ -35,7 +35,8 @@ "HOST": "__CORE_RPC_HOST__", "PORT": 15, "USERNAME": "__CORE_RPC_USERNAME__", - "PASSWORD": "__CORE_RPC_PASSWORD__" + "PASSWORD": "__CORE_RPC_PASSWORD__", + "TIMEOUT": "__CORE_RPC_TIMEOUT__" }, "ELECTRUM": { "HOST": "__ELECTRUM_HOST__", @@ -49,7 +50,8 @@ "HOST": "__SECOND_CORE_RPC_HOST__", "PORT": 17, "USERNAME": "__SECOND_CORE_RPC_USERNAME__", - "PASSWORD": "__SECOND_CORE_RPC_PASSWORD__" + "PASSWORD": "__SECOND_CORE_RPC_PASSWORD__", + "TIMEOUT": "__SECOND_CORE_RPC_TIMEOUT__" }, "DATABASE": { "ENABLED": false, @@ -108,7 +110,8 @@ "LND": { "TLS_CERT_PATH": "", "MACAROON_PATH": "", - "REST_API_URL": "https://localhost:8080" + "REST_API_URL": "https://localhost:8080", + "TIMEOUT": 10000 }, "CLIGHTNING": { "SOCKET": "__CLIGHTNING_SOCKET__" diff --git a/backend/src/__tests__/config.test.ts b/backend/src/__tests__/config.test.ts index fdffd593f..487fb4e78 100644 --- a/backend/src/__tests__/config.test.ts +++ b/backend/src/__tests__/config.test.ts @@ -53,14 +53,16 @@ describe('Mempool Backend Config', () => { HOST: '127.0.0.1', PORT: 8332, USERNAME: 'mempool', - PASSWORD: 'mempool' + PASSWORD: 'mempool', + TIMEOUT: 60000 }); expect(config.SECOND_CORE_RPC).toStrictEqual({ HOST: '127.0.0.1', PORT: 8332, USERNAME: 'mempool', - PASSWORD: 'mempool' + PASSWORD: 'mempool', + TIMEOUT: 60000 }); expect(config.DATABASE).toStrictEqual({ diff --git a/backend/src/api/bitcoin/bitcoin-client.ts b/backend/src/api/bitcoin/bitcoin-client.ts index 85a410496..429638984 100644 --- a/backend/src/api/bitcoin/bitcoin-client.ts +++ b/backend/src/api/bitcoin/bitcoin-client.ts @@ -7,7 +7,7 @@ const nodeRpcCredentials: BitcoinRpcCredentials = { port: config.CORE_RPC.PORT, user: config.CORE_RPC.USERNAME, pass: config.CORE_RPC.PASSWORD, - timeout: 60000, + timeout: config.CORE_RPC.TIMEOUT, }; export default new bitcoin.Client(nodeRpcCredentials); diff --git a/backend/src/api/bitcoin/bitcoin-second-client.ts b/backend/src/api/bitcoin/bitcoin-second-client.ts index 39633a317..7f81a96a0 100644 --- a/backend/src/api/bitcoin/bitcoin-second-client.ts +++ b/backend/src/api/bitcoin/bitcoin-second-client.ts @@ -7,7 +7,7 @@ const nodeRpcCredentials: BitcoinRpcCredentials = { port: config.SECOND_CORE_RPC.PORT, user: config.SECOND_CORE_RPC.USERNAME, pass: config.SECOND_CORE_RPC.PASSWORD, - timeout: 60000, + timeout: config.SECOND_CORE_RPC.TIMEOUT, }; export default new bitcoin.Client(nodeRpcCredentials); diff --git a/backend/src/api/lightning/lnd/lnd-api.ts b/backend/src/api/lightning/lnd/lnd-api.ts index 1480f9b8f..31b868df9 100644 --- a/backend/src/api/lightning/lnd/lnd-api.ts +++ b/backend/src/api/lightning/lnd/lnd-api.ts @@ -17,7 +17,7 @@ class LndApi implements AbstractLightningApi { httpsAgent: new Agent({ ca: fs.readFileSync(config.LND.TLS_CERT_PATH) }), - timeout: 10000 + timeout: config.LND.TIMEOUT }; } } diff --git a/backend/src/config.ts b/backend/src/config.ts index b364f100b..ca5ad5487 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -52,6 +52,7 @@ interface IConfig { TLS_CERT_PATH: string; MACAROON_PATH: string; REST_API_URL: string; + TIMEOUT: number; }; CLIGHTNING: { SOCKET: string; @@ -66,12 +67,14 @@ interface IConfig { PORT: number; USERNAME: string; PASSWORD: string; + TIMEOUT: number; }; SECOND_CORE_RPC: { HOST: string; PORT: number; USERNAME: string; PASSWORD: string; + TIMEOUT: number; }; DATABASE: { ENABLED: boolean; @@ -170,13 +173,15 @@ const defaults: IConfig = { 'HOST': '127.0.0.1', 'PORT': 8332, 'USERNAME': 'mempool', - 'PASSWORD': 'mempool' + 'PASSWORD': 'mempool', + 'TIMEOUT': 60000, }, 'SECOND_CORE_RPC': { 'HOST': '127.0.0.1', 'PORT': 8332, 'USERNAME': 'mempool', - 'PASSWORD': 'mempool' + 'PASSWORD': 'mempool', + 'TIMEOUT': 60000, }, 'DATABASE': { 'ENABLED': true, @@ -216,6 +221,7 @@ const defaults: IConfig = { 'TLS_CERT_PATH': '', 'MACAROON_PATH': '', 'REST_API_URL': 'https://localhost:8080', + 'TIMEOUT': 10000, }, 'CLIGHTNING': { 'SOCKET': '', diff --git a/docker/README.md b/docker/README.md index 13a4094cc..3c08d9c3a 100644 --- a/docker/README.md +++ b/docker/README.md @@ -34,6 +34,7 @@ If you want to use different credentials, specify them in the `docker-compose.ym CORE_RPC_PORT: "8332" CORE_RPC_USERNAME: "customuser" CORE_RPC_PASSWORD: "custompassword" + CORE_RPC_TIMEOUT: "60000" ``` The IP address in the example above refers to Docker's default gateway IP address so that the container can hit the `bitcoind` instance running on the host machine. If your setup is different, update it accordingly. @@ -160,7 +161,8 @@ Corresponding `docker-compose.yml` overrides: "HOST": "127.0.0.1", "PORT": 8332, "USERNAME": "mempool", - "PASSWORD": "mempool" + "PASSWORD": "mempool", + "TIMEOUT": 60000 }, ``` @@ -172,6 +174,7 @@ Corresponding `docker-compose.yml` overrides: CORE_RPC_PORT: "" CORE_RPC_USERNAME: "" CORE_RPC_PASSWORD: "" + CORE_RPC_TIMEOUT: 60000 ... ``` @@ -221,7 +224,8 @@ Corresponding `docker-compose.yml` overrides: "HOST": "127.0.0.1", "PORT": 8332, "USERNAME": "mempool", - "PASSWORD": "mempool" + "PASSWORD": "mempool", + "TIMEOUT": 60000 }, ``` @@ -233,6 +237,7 @@ Corresponding `docker-compose.yml` overrides: SECOND_CORE_RPC_PORT: "" SECOND_CORE_RPC_USERNAME: "" SECOND_CORE_RPC_PASSWORD: "" + SECOND_CORE_RPC_TIMEOUT: "" ... ``` @@ -405,6 +410,7 @@ Corresponding `docker-compose.yml` overrides: "TLS_CERT_PATH": "" "MACAROON_PATH": "" "REST_API_URL": "https://localhost:8080" + "TIMEOUT": 10000 } ``` @@ -415,6 +421,7 @@ Corresponding `docker-compose.yml` overrides: LND_TLS_CERT_PATH: "" LND_MACAROON_PATH: "" LND_REST_API_URL: "https://localhost:8080" + LND_TIMEOUT: 10000 ... ``` diff --git a/docker/backend/mempool-config.json b/docker/backend/mempool-config.json index 6e20cc695..e78a370f0 100644 --- a/docker/backend/mempool-config.json +++ b/docker/backend/mempool-config.json @@ -33,7 +33,8 @@ "HOST": "__CORE_RPC_HOST__", "PORT": __CORE_RPC_PORT__, "USERNAME": "__CORE_RPC_USERNAME__", - "PASSWORD": "__CORE_RPC_PASSWORD__" + "PASSWORD": "__CORE_RPC_PASSWORD__", + "TIMEOUT": __CORE_RPC_TIMEOUT__ }, "ELECTRUM": { "HOST": "__ELECTRUM_HOST__", @@ -47,7 +48,8 @@ "HOST": "__SECOND_CORE_RPC_HOST__", "PORT": __SECOND_CORE_RPC_PORT__, "USERNAME": "__SECOND_CORE_RPC_USERNAME__", - "PASSWORD": "__SECOND_CORE_RPC_PASSWORD__" + "PASSWORD": "__SECOND_CORE_RPC_PASSWORD__", + "TIMEOUT": __SECOND_CORE_RPC_TIMEOUT__ }, "DATABASE": { "ENABLED": __DATABASE_ENABLED__, @@ -84,7 +86,8 @@ "LND": { "TLS_CERT_PATH": "__LND_TLS_CERT_PATH__", "MACAROON_PATH": "__LND_MACAROON_PATH__", - "REST_API_URL": "__LND_REST_API_URL__" + "REST_API_URL": "__LND_REST_API_URL__", + "TIMEOUT": "__LND_TIMEOUT__" }, "CLIGHTNING": { "SOCKET": "__CLIGHTNING_SOCKET__" diff --git a/docker/backend/start.sh b/docker/backend/start.sh index cdf9ab67e..61f16098c 100755 --- a/docker/backend/start.sh +++ b/docker/backend/start.sh @@ -37,6 +37,7 @@ __CORE_RPC_HOST__=${CORE_RPC_HOST:=127.0.0.1} __CORE_RPC_PORT__=${CORE_RPC_PORT:=8332} __CORE_RPC_USERNAME__=${CORE_RPC_USERNAME:=mempool} __CORE_RPC_PASSWORD__=${CORE_RPC_PASSWORD:=mempool} +__CORE_RPC_TIMEOUT__=${CORE_RPC_TIMEOUT:=60000} # ELECTRUM __ELECTRUM_HOST__=${ELECTRUM_HOST:=127.0.0.1} @@ -51,6 +52,7 @@ __SECOND_CORE_RPC_HOST__=${SECOND_CORE_RPC_HOST:=127.0.0.1} __SECOND_CORE_RPC_PORT__=${SECOND_CORE_RPC_PORT:=8332} __SECOND_CORE_RPC_USERNAME__=${SECOND_CORE_RPC_USERNAME:=mempool} __SECOND_CORE_RPC_PASSWORD__=${SECOND_CORE_RPC_PASSWORD:=mempool} +__SECOND_CORE_RPC_TIMEOUT__=${SECOND_CORE_RPC_TIMEOUT:=60000} # DATABASE __DATABASE_ENABLED__=${DATABASE_ENABLED:=true} @@ -108,6 +110,7 @@ __LIGHTNING_LOGGER_UPDATE_INTERVAL__=${LIGHTNING_LOGGER_UPDATE_INTERVAL:=30} __LND_TLS_CERT_PATH__=${LND_TLS_CERT_PATH:=""} __LND_MACAROON_PATH__=${LND_MACAROON_PATH:=""} __LND_REST_API_URL__=${LND_REST_API_URL:="https://localhost:8080"} +__LND_TIMEOUT__=${LND_TIMEOUT:=10000} # CLN __CLIGHTNING_SOCKET__=${CLIGHTNING_SOCKET:=""} @@ -156,6 +159,7 @@ sed -i "s/__CORE_RPC_HOST__/${__CORE_RPC_HOST__}/g" mempool-config.json sed -i "s/__CORE_RPC_PORT__/${__CORE_RPC_PORT__}/g" mempool-config.json sed -i "s/__CORE_RPC_USERNAME__/${__CORE_RPC_USERNAME__}/g" mempool-config.json sed -i "s/__CORE_RPC_PASSWORD__/${__CORE_RPC_PASSWORD__}/g" mempool-config.json +sed -i "s/__CORE_RPC_TIMEOUT__/${__CORE_RPC_TIMEOUT__}/g" mempool-config.json sed -i "s/__ELECTRUM_HOST__/${__ELECTRUM_HOST__}/g" mempool-config.json sed -i "s/__ELECTRUM_PORT__/${__ELECTRUM_PORT__}/g" mempool-config.json @@ -167,6 +171,7 @@ sed -i "s/__SECOND_CORE_RPC_HOST__/${__SECOND_CORE_RPC_HOST__}/g" mempool-config sed -i "s/__SECOND_CORE_RPC_PORT__/${__SECOND_CORE_RPC_PORT__}/g" mempool-config.json sed -i "s/__SECOND_CORE_RPC_USERNAME__/${__SECOND_CORE_RPC_USERNAME__}/g" mempool-config.json sed -i "s/__SECOND_CORE_RPC_PASSWORD__/${__SECOND_CORE_RPC_PASSWORD__}/g" mempool-config.json +sed -i "s/__SECOND_CORE_RPC_TIMEOUT__/${__SECOND_CORE_RPC_TIMEOUT__}/g" mempool-config.json sed -i "s/__DATABASE_ENABLED__/${__DATABASE_ENABLED__}/g" mempool-config.json sed -i "s/__DATABASE_HOST__/${__DATABASE_HOST__}/g" mempool-config.json @@ -218,6 +223,7 @@ sed -i "s!__LIGHTNING_LOGGER_UPDATE_INTERVAL__!${__LIGHTNING_LOGGER_UPDATE_INTER sed -i "s!__LND_TLS_CERT_PATH__!${__LND_TLS_CERT_PATH__}!g" mempool-config.json sed -i "s!__LND_MACAROON_PATH__!${__LND_MACAROON_PATH__}!g" mempool-config.json sed -i "s!__LND_REST_API_URL__!${__LND_REST_API_URL__}!g" mempool-config.json +sed -i "s!__LND_TIMEOUT__!${__LND_TIMEOUT__}!g" mempool-config.json # CLN sed -i "s!__CLIGHTNING_SOCKET__!${__CLIGHTNING_SOCKET__}!g" mempool-config.json