Skip to content

Commit

Permalink
lightning module resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
huumn committed Nov 7, 2024
1 parent 012536c commit 558db5d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions api/ssrApollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export function getGetServerSideProps (
}

if (error || !data || (notFound && notFound(data, vars, me))) {
error && console.error(error)
res.writeHead(302, {
Location: '/404'
}).end()
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ services:
build:
context: ./docker/tor
container_name: tor
profiles:
- payments
restart: unless-stopped
volumes:
- tordata:/tordata/
Expand Down Expand Up @@ -371,11 +373,11 @@ services:
healthcheck:
<<: *healthcheck
test: ["CMD-SHELL", "lncli", "getinfo"]
depends_on:
depends_on:
tor:
condition: service_healthy
restart: true
<<: *depends_on_bitcoin
<<: *depends_on_bitcoin
env_file: *env_file
entrypoint: /tor-entrypoint
command:
Expand Down Expand Up @@ -471,7 +473,7 @@ services:
healthcheck:
<<: *healthcheck
test: ["CMD-SHELL", "su clightning -c 'lightning-cli --network=regtest getinfo'"]
depends_on:
depends_on:
tor:
condition: service_healthy
restart: true
Expand Down
15 changes: 10 additions & 5 deletions lib/lnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import { join } from 'path'
import apiForProto from 'lightning/lnd_grpc/api_for_proto'
import { defaultSocket, grpcSslCipherSuites, packageTypes, protoFiles, protosDir, serviceTypes } from 'lightning/grpc/index'
import grpcCredentials from 'lightning/lnd_grpc/grpc_credentials'
import { createRequire } from 'module'
import { existsSync } from 'fs'

const { GRPC_SSL_CIPHER_SUITES } = process.env
const { keys } = Object

export function authenticatedLndGrpc ({ cert, macaroon, path, socket }, withProxy) {
const req = createRequire(import.meta.url)

const lightningModulePath = req.resolve('lightning')
const pathForProto = proto => join(lightningModulePath, protosDir, proto)
const lightningModulePath = process.env.LIGHTNING_MODULE_PATH || require.resolve('lightning')
const pathForProto = proto => {
const path = join(lightningModulePath, protosDir, proto)
// check if path exists
if (!existsSync(path)) {
throw new Error(`Proto file not found: ${path}`)
}
return path
}

const { credentials } = grpcCredentials({ cert, macaroon })
const lndSocket = socket || defaultSocket
Expand Down
3 changes: 2 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ module.exports = withPlausibleProxy()({
env: {
NEXT_PUBLIC_COMMIT_HASH: commitHash,
NEXT_PUBLIC_LND_CONNECT_ADDRESS: process.env.LND_CONNECT_ADDRESS,
NEXT_PUBLIC_ASSET_PREFIX: isProd ? 'https://a.stacker.news' : ''
NEXT_PUBLIC_ASSET_PREFIX: isProd ? 'https://a.stacker.news' : '',
LIGHTNING_MODULE_PATH: require.resolve('lightning')
},
compress: false,
experimental: {
Expand Down

0 comments on commit 558db5d

Please sign in to comment.