cleanup
This commit is contained in:
parent
e9acc97bdc
commit
ce4f379a8b
10 changed files with 40 additions and 204 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
# The developer is used by default or you may specify your own
|
# The developer is used by default or you may specify your own
|
||||||
# To disable this feature entirely overwrite the env with "null"
|
# To disable this feature entirely overwrite the env with "null"
|
||||||
#LIQUIDITY_PROVIDER_PUB=null
|
#LIQUIDITY_PROVIDER_PUB=null
|
||||||
|
#DISABLE_LIQUIDITY_PROVIDER=false
|
||||||
|
|
||||||
#DB
|
#DB
|
||||||
#DATABASE_FILE=db.sqlite
|
#DATABASE_FILE=db.sqlite
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,3 @@ export const chooseEnvBool = (key: string, dbEnv: Record<string, string | undefi
|
||||||
const v = chooseEnv(key, dbEnv, defaultValue.toString(), addToDb)
|
const v = chooseEnv(key, dbEnv, defaultValue.toString(), addToDb)
|
||||||
return v.toLowerCase() === 'true'
|
return v.toLowerCase() === 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StringSetting = { t: 'string', v?: string, defaultValue: string }
|
|
||||||
export type NumberSetting = { t: 'number', v?: number, defaultValue: number }
|
|
||||||
export type BooleanSetting = { t: 'boolean', v?: boolean, defaultValue: boolean }
|
|
||||||
export type EnvSetting = StringSetting | NumberSetting | BooleanSetting
|
|
||||||
export type SettingsJson = Record<string, Record<string, EnvSetting>>
|
|
||||||
|
|
@ -51,7 +51,7 @@ export default class {
|
||||||
outgoingOpsLocked = false
|
outgoingOpsLocked = false
|
||||||
liquidProvider: LiquidityProvider
|
liquidProvider: LiquidityProvider
|
||||||
utils: Utils
|
utils: Utils
|
||||||
constructor(getSettings: () => { lndSettings: LndSettings, lndNodeSettings: LndNodeSettings }, liquidProvider: LiquidityProvider, utils: Utils, addressPaidCb: AddressPaidCb, invoicePaidCb: InvoicePaidCb, newBlockCb: NewBlockCb, htlcCb: HtlcCb, channelEventCb: ChannelEventCb, nodeToUse?: "other" | "third" | "fourth") {
|
constructor(getSettings: () => { lndSettings: LndSettings, lndNodeSettings: LndNodeSettings }, liquidProvider: LiquidityProvider, utils: Utils, addressPaidCb: AddressPaidCb, invoicePaidCb: InvoicePaidCb, newBlockCb: NewBlockCb, htlcCb: HtlcCb, channelEventCb: ChannelEventCb) {
|
||||||
this.getSettings = getSettings
|
this.getSettings = getSettings
|
||||||
this.utils = utils
|
this.utils = utils
|
||||||
this.addressPaidCb = addressPaidCb
|
this.addressPaidCb = addressPaidCb
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import fs, { watchFile } from "fs";
|
import fs, { watchFile } from "fs";
|
||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
import { ERROR, getLogger } from "../helpers/logger.js";
|
import { ERROR, getLogger } from "../helpers/logger.js";
|
||||||
import { getDataPath } from "./settings.js";
|
|
||||||
import Storage from "../storage/index.js";
|
import Storage from "../storage/index.js";
|
||||||
import * as Types from '../../../proto/autogenerated/ts/types.js'
|
import * as Types from '../../../proto/autogenerated/ts/types.js'
|
||||||
import LND from "../lnd/lnd.js";
|
import LND from "../lnd/lnd.js";
|
||||||
|
|
@ -255,3 +254,7 @@ export class AdminManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getDataPath = (dataDir: string, dataPath: string) => {
|
||||||
|
return dataDir !== "" ? `${dataDir}/${dataPath}` : dataPath
|
||||||
|
}
|
||||||
|
|
@ -58,7 +58,7 @@ export const initMainHandler = async (log: PubLogger, settingsManager: SettingsM
|
||||||
return mainHandler.storage.applicationStorage.GenerateApplicationKeys(app);
|
return mainHandler.storage.applicationStorage.GenerateApplicationKeys(app);
|
||||||
} // --
|
} // --
|
||||||
else {
|
else {
|
||||||
return { privateKey: app.nostr_private_key, publicKey: app.nostr_public_key, appId: app.app_id, name: app.name, avatarUrl: app.avatar_url }
|
return { privateKey: app.nostr_private_key, publicKey: app.nostr_public_key, appId: app.app_id, name: app.name }
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
const liquidityProviderApp = apps.find(app => defaultNames.includes(app.name))
|
const liquidityProviderApp = apps.find(app => defaultNames.includes(app.name))
|
||||||
|
|
@ -80,7 +80,7 @@ export const initMainHandler = async (log: PubLogger, settingsManager: SettingsM
|
||||||
await mainHandler.appUserManager.CleanupInactiveUsers()
|
await mainHandler.appUserManager.CleanupInactiveUsers()
|
||||||
await mainHandler.appUserManager.CleanupNeverActiveUsers()
|
await mainHandler.appUserManager.CleanupNeverActiveUsers()
|
||||||
await mainHandler.paymentManager.watchDog.Start()
|
await mainHandler.paymentManager.watchDog.Start()
|
||||||
return { mainHandler, apps, liquidityProviderInfo, liquidityProviderApp, wizard, adminManager, settingsManager }
|
return { mainHandler, apps, liquidityProviderInfo, liquidityProviderApp, wizard, adminManager }
|
||||||
}
|
}
|
||||||
|
|
||||||
const processArgs = async (mainHandler: Main) => {
|
const processArgs = async (mainHandler: Main) => {
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@ import os from 'os'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
export type ServiceFeeSettings = {
|
export type ServiceFeeSettings = {
|
||||||
incomingTxFee: number // Hot
|
incomingTxFee: number
|
||||||
outgoingTxFee: number // Hot
|
outgoingTxFee: number
|
||||||
incomingAppInvoiceFee: number // Hot
|
incomingAppInvoiceFee: number
|
||||||
incomingAppUserInvoiceFee: number // Hot
|
incomingAppUserInvoiceFee: number
|
||||||
outgoingAppInvoiceFee: number // Hot
|
outgoingAppInvoiceFee: number
|
||||||
outgoingAppUserInvoiceFee: number // Hot
|
outgoingAppUserInvoiceFee: number
|
||||||
outgoingAppUserInvoiceFeeBps: number // Hot
|
outgoingAppUserInvoiceFeeBps: number
|
||||||
userToUserFee: number // Hot
|
userToUserFee: number
|
||||||
appToUserFee: number // Hot
|
appToUserFee: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LoadServiceFeeSettingsFromEnv = (dbEnv: Record<string, string | undefined>, addToDb?: EnvCacher): ServiceFeeSettings => {
|
export const LoadServiceFeeSettingsFromEnv = (dbEnv: Record<string, string | undefined>, addToDb?: EnvCacher): ServiceFeeSettings => {
|
||||||
|
|
@ -30,19 +30,19 @@ export const LoadServiceFeeSettingsFromEnv = (dbEnv: Record<string, string | und
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ServiceSettings = {
|
export type ServiceSettings = {
|
||||||
servicePort: number // Cold
|
servicePort: number
|
||||||
recordPerformance: boolean // Cold
|
recordPerformance: boolean
|
||||||
skipSanityCheck: boolean // Cold
|
skipSanityCheck: boolean
|
||||||
wizard: boolean // Cold
|
wizard: boolean
|
||||||
bridgeUrl: string, // Cold
|
bridgeUrl: string,
|
||||||
shockPushBaseUrl: string // Cold
|
shockPushBaseUrl: string
|
||||||
|
|
||||||
serviceUrl: string // Hot
|
serviceUrl: string
|
||||||
disableExternalPayments: boolean // Hot
|
disableExternalPayments: boolean
|
||||||
defaultAppName: string // Hot
|
defaultAppName: string
|
||||||
pushBackupsToNostr: boolean // Hot
|
pushBackupsToNostr: boolean
|
||||||
lnurlMetaText: string, // Hot
|
lnurlMetaText: string,
|
||||||
allowHttpUpgrade: boolean // Hot
|
allowHttpUpgrade: boolean
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -119,10 +119,6 @@ export type NostrRelaySettings = {
|
||||||
maxEventContentLength: number
|
maxEventContentLength: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const getEnvOrDefault = (name: string, defaultValue: string): string => {
|
|
||||||
return process.env[name] || defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const LoadNosrtRelaySettingsFromEnv = (dbEnv: Record<string, string | undefined>, addToDb?: EnvCacher): NostrRelaySettings => {
|
export const LoadNosrtRelaySettingsFromEnv = (dbEnv: Record<string, string | undefined>, addToDb?: EnvCacher): NostrRelaySettings => {
|
||||||
const relaysEnv = chooseEnv("NOSTR_RELAYS", dbEnv, "wss://relay.lightning.pub", addToDb);
|
const relaysEnv = chooseEnv("NOSTR_RELAYS", dbEnv, "wss://relay.lightning.pub", addToDb);
|
||||||
const maxEventContentLength = chooseEnvInt("NOSTR_MAX_EVENT_CONTENT_LENGTH", dbEnv, 40000, addToDb)
|
const maxEventContentLength = chooseEnvInt("NOSTR_MAX_EVENT_CONTENT_LENGTH", dbEnv, 40000, addToDb)
|
||||||
|
|
@ -208,46 +204,3 @@ export const LoadBitcoinCoreSettingsFromEnv = (): BitcoinCoreSettings => {
|
||||||
pass: EnvMustBeNonEmptyString("BITCOIN_CORE_PASS")
|
pass: EnvMustBeNonEmptyString("BITCOIN_CORE_PASS")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* export const LoadTestSettingsFromEnv = (): TestSettings => {
|
|
||||||
|
|
||||||
const settings = LoadMainSettingsFromEnv()
|
|
||||||
return {
|
|
||||||
...settings,
|
|
||||||
storageSettings: GetTestStorageSettings(settings.storageSettings),
|
|
||||||
lndSettings: {
|
|
||||||
...settings.lndSettings,
|
|
||||||
otherNode: {
|
|
||||||
lndAddr: EnvMustBeNonEmptyString("LND_OTHER_ADDR"),
|
|
||||||
lndCertPath: EnvMustBeNonEmptyString("LND_OTHER_CERT_PATH"),
|
|
||||||
lndMacaroonPath: EnvMustBeNonEmptyString("LND_OTHER_MACAROON_PATH")
|
|
||||||
},
|
|
||||||
thirdNode: {
|
|
||||||
lndAddr: EnvMustBeNonEmptyString("LND_THIRD_ADDR"),
|
|
||||||
lndCertPath: EnvMustBeNonEmptyString("LND_THIRD_CERT_PATH"),
|
|
||||||
lndMacaroonPath: EnvMustBeNonEmptyString("LND_THIRD_MACAROON_PATH")
|
|
||||||
},
|
|
||||||
fourthNode: {
|
|
||||||
lndAddr: EnvMustBeNonEmptyString("LND_FOURTH_ADDR"),
|
|
||||||
lndCertPath: EnvMustBeNonEmptyString("LND_FOURTH_CERT_PATH"),
|
|
||||||
lndMacaroonPath: EnvMustBeNonEmptyString("LND_FOURTH_MACAROON_PATH")
|
|
||||||
},
|
|
||||||
},
|
|
||||||
liquiditySettings: {
|
|
||||||
...settings.liquiditySettings,
|
|
||||||
liquidityProviderPub: "",
|
|
||||||
},
|
|
||||||
skipSanityCheck: true,
|
|
||||||
bitcoinCoreSettings: {
|
|
||||||
port: EnvMustBeInteger("BITCOIN_CORE_PORT"),
|
|
||||||
user: EnvMustBeNonEmptyString("BITCOIN_CORE_USER"),
|
|
||||||
pass: EnvMustBeNonEmptyString("BITCOIN_CORE_PASS")
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const getDataPath = (dataDir: string, dataPath: string) => {
|
|
||||||
return dataDir !== "" ? `${dataDir}/${dataPath}` : dataPath
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,15 @@
|
||||||
import Storage, { StorageSettings } from "../storage/index.js"
|
import Storage, { StorageSettings } from "../storage/index.js"
|
||||||
import { EnvCacher, EnvSetting, SettingsJson, StringSetting } from "../helpers/envParser.js"
|
import { EnvCacher } from "../helpers/envParser.js"
|
||||||
import { getLogger, PubLogger } from "../helpers/logger.js"
|
import { getLogger, PubLogger } from "../helpers/logger.js"
|
||||||
import {
|
import {
|
||||||
BitcoinCoreSettings, LiquiditySettings, LndNodeSettings, LndSettings, LoadBitcoinCoreSettingsFromEnv,
|
LiquiditySettings, LndNodeSettings, LndSettings, LoadLiquiditySettingsFromEnv,
|
||||||
LoadFourthLndSettingsFromEnv, LoadLiquiditySettingsFromEnv, LoadSecondLndSettingsFromEnv, LoadThirdLndSettingsFromEnv,
|
|
||||||
LoadLSPSettingsFromEnv, LSPSettings, ServiceFeeSettings, ServiceSettings, LoadServiceFeeSettingsFromEnv,
|
LoadLSPSettingsFromEnv, LSPSettings, ServiceFeeSettings, ServiceSettings, LoadServiceFeeSettingsFromEnv,
|
||||||
LoadNosrtRelaySettingsFromEnv, LoadServiceSettingsFromEnv, LoadWatchdogSettingsFromEnv
|
LoadNosrtRelaySettingsFromEnv, LoadServiceSettingsFromEnv, LoadWatchdogSettingsFromEnv,
|
||||||
|
LoadLndNodeSettingsFromEnv, LoadLndSettingsFromEnv, NostrRelaySettings, WatchdogSettings
|
||||||
} from "./settings.js"
|
} from "./settings.js"
|
||||||
import { LoadLndNodeSettingsFromEnv, LoadLndSettingsFromEnv, NostrRelaySettings, WatchdogSettings } from "./settings.js"
|
|
||||||
export default class SettingsManager {
|
export default class SettingsManager {
|
||||||
storage: Storage
|
storage: Storage
|
||||||
private settings: FullSettings | null = null
|
private settings: FullSettings | null = null
|
||||||
//private testSettings: TestSettings | null = null
|
|
||||||
|
|
||||||
log: PubLogger
|
log: PubLogger
|
||||||
constructor(storage: Storage) {
|
constructor(storage: Storage) {
|
||||||
|
|
@ -39,18 +37,6 @@ export default class SettingsManager {
|
||||||
this.settings = f(this.settings)
|
this.settings = f(this.settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* async InitTestSettings(): Promise<void> {
|
|
||||||
await this.InitSettings()
|
|
||||||
await this.updateSkipSanityCheck(true)
|
|
||||||
await this.updateDisableLiquidityProvider(true)
|
|
||||||
this.testSettings = {
|
|
||||||
secondLndSettings: LoadSecondLndSettingsFromEnv(),
|
|
||||||
thirdLndSettings: LoadThirdLndSettingsFromEnv(),
|
|
||||||
fourthLndSettings: LoadFourthLndSettingsFromEnv(),
|
|
||||||
bitcoinCoreSettings: LoadBitcoinCoreSettingsFromEnv(),
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
async InitSettings(): Promise<FullSettings> {
|
async InitSettings(): Promise<FullSettings> {
|
||||||
const dbSettings = await this.storage.settingsStorage.getAllDbEnvs()
|
const dbSettings = await this.storage.settingsStorage.getAllDbEnvs()
|
||||||
const toAdd: Record<string, string> = {}
|
const toAdd: Record<string, string> = {}
|
||||||
|
|
@ -58,6 +44,7 @@ export default class SettingsManager {
|
||||||
toAdd[key] = value
|
toAdd[key] = value
|
||||||
}
|
}
|
||||||
this.settings = this.loadEnvs(dbSettings, addToDb)
|
this.settings = this.loadEnvs(dbSettings, addToDb)
|
||||||
|
this.log("adding", toAdd.length, "settings to db")
|
||||||
for (const key in toAdd) {
|
for (const key in toAdd) {
|
||||||
await this.storage.settingsStorage.setDbEnvIFNeeded(key, toAdd[key])
|
await this.storage.settingsStorage.setDbEnvIFNeeded(key, toAdd[key])
|
||||||
}
|
}
|
||||||
|
|
@ -75,13 +62,6 @@ export default class SettingsManager {
|
||||||
return this.settings
|
return this.settings
|
||||||
}
|
}
|
||||||
|
|
||||||
/* getTestSettings(): TestSettings {
|
|
||||||
if (!this.testSettings) {
|
|
||||||
throw new Error("Test settings not initialized")
|
|
||||||
}
|
|
||||||
return this.testSettings
|
|
||||||
} */
|
|
||||||
|
|
||||||
async updateDefaultAppName(name: string): Promise<boolean> {
|
async updateDefaultAppName(name: string): Promise<boolean> {
|
||||||
if (!this.settings) {
|
if (!this.settings) {
|
||||||
throw new Error("Settings not initialized")
|
throw new Error("Settings not initialized")
|
||||||
|
|
@ -164,16 +144,9 @@ type FullSettings = {
|
||||||
lndNodeSettings: LndNodeSettings
|
lndNodeSettings: LndNodeSettings
|
||||||
lndSettings: LndSettings
|
lndSettings: LndSettings
|
||||||
liquiditySettings: LiquiditySettings
|
liquiditySettings: LiquiditySettings
|
||||||
watchDogSettings: WatchdogSettings, // Hot
|
watchDogSettings: WatchdogSettings,
|
||||||
nostrRelaySettings: NostrRelaySettings, // Hot
|
nostrRelaySettings: NostrRelaySettings,
|
||||||
serviceFeeSettings: ServiceFeeSettings, // Hot
|
serviceFeeSettings: ServiceFeeSettings,
|
||||||
serviceSettings: ServiceSettings, // Hot
|
serviceSettings: ServiceSettings,
|
||||||
lspSettings: LSPSettings
|
lspSettings: LSPSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
/* type TestSettings = {
|
|
||||||
secondLndSettings: LndNodeSettings
|
|
||||||
thirdLndSettings: LndNodeSettings
|
|
||||||
fourthLndSettings: LndNodeSettings
|
|
||||||
bitcoinCoreSettings: BitcoinCoreSettings
|
|
||||||
} */
|
|
||||||
|
|
@ -207,37 +207,6 @@ export default class Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* async Connect() {
|
|
||||||
const log = getLogger({})
|
|
||||||
log("conneting to relay...", this.settings.relays[0])
|
|
||||||
let relay: Relay | null = null
|
|
||||||
//const relay = relayInit(this.settings.relays[0]) // TODO: create multiple conns for multiple relays
|
|
||||||
try {
|
|
||||||
relay = await Relay.connect(this.settings.relays[0])
|
|
||||||
if (!relay.connected) {
|
|
||||||
throw new Error("failed to connect to relay")
|
|
||||||
}
|
|
||||||
} catch (err:any) {
|
|
||||||
log("failed to connect to relay, will try again in 2 seconds", err.message || err)
|
|
||||||
setTimeout(() => {
|
|
||||||
this.Connect()
|
|
||||||
}, 2000)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log("connected, subbing...")
|
|
||||||
relay.onclose = (() => {
|
|
||||||
log("relay disconnected, will try to reconnect in 2 seconds")
|
|
||||||
relay.close()
|
|
||||||
setTimeout(() => {
|
|
||||||
this.Connect()
|
|
||||||
}, 2000)
|
|
||||||
})
|
|
||||||
|
|
||||||
this.Subscribe(relay)
|
|
||||||
|
|
||||||
} */
|
|
||||||
|
|
||||||
Subscribe(relay: Relay) {
|
Subscribe(relay: Relay) {
|
||||||
const appIds = Object.keys(this.apps)
|
const appIds = Object.keys(this.apps)
|
||||||
this.log("🔍 [NOSTR SUBSCRIPTION] Setting up subscription", {
|
this.log("🔍 [NOSTR SUBSCRIPTION] Setting up subscription", {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { EnvSetting, SettingsJson } from "../helpers/envParser.js";
|
|
||||||
import { StorageInterface } from "./db/storageInterface.js";
|
import { StorageInterface } from "./db/storageInterface.js";
|
||||||
import { AdminSettings } from "./entity/AdminSettings.js";
|
import { AdminSettings } from "./entity/AdminSettings.js";
|
||||||
export default class SettingsStorage {
|
export default class SettingsStorage {
|
||||||
|
|
|
||||||
|
|
@ -187,13 +187,6 @@ export class Wizard {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateConfigs(pendingConfig: WizardSettings): Promise<void> {
|
|
||||||
await this.settings.updateDefaultAppName(pendingConfig.sourceName)
|
|
||||||
await this.settings.updateRelayUrl(pendingConfig.relayUrl)
|
|
||||||
await this.settings.updateDisableLiquidityProvider(pendingConfig.automateLiquidity)
|
|
||||||
await this.settings.updatePushBackupsToNostr(pendingConfig.pushBackupsToNostr)
|
|
||||||
}
|
|
||||||
|
|
||||||
updateDefaultApp = async (currentName: string, avatarUrl?: string): Promise<void> => {
|
updateDefaultApp = async (currentName: string, avatarUrl?: string): Promise<void> => {
|
||||||
const newName = this.settings.getSettings().serviceSettings.defaultAppName
|
const newName = this.settings.getSettings().serviceSettings.defaultAppName
|
||||||
try {
|
try {
|
||||||
|
|
@ -207,53 +200,4 @@ export class Wizard {
|
||||||
this.log(`Error updating app info: ${(e as Error).message}`)
|
this.log(`Error updating app info: ${(e as Error).message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
updateEnvFile = (pendingConfig: WizardSettings) => {
|
|
||||||
let envFileContent: string[] = []
|
|
||||||
try {
|
|
||||||
envFileContent = fs.readFileSync('.env', 'utf-8').split('\n')
|
|
||||||
} catch (err: any) {
|
|
||||||
if (err.code !== 'ENOENT') {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const toMerge: string[] = []
|
|
||||||
const sourceNameIndex = envFileContent.findIndex(line => line.startsWith('DEFAULT_APP_NAME'))
|
|
||||||
if (sourceNameIndex === -1) {
|
|
||||||
toMerge.push(`DEFAULT_APP_NAME=${pendingConfig.sourceName}`)
|
|
||||||
} else {
|
|
||||||
envFileContent[sourceNameIndex] = `DEFAULT_APP_NAME=${pendingConfig.sourceName}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const relayUrlIndex = envFileContent.findIndex(line => line.startsWith('RELAY_URL'))
|
|
||||||
if (relayUrlIndex === -1) {
|
|
||||||
toMerge.push(`RELAY_URL=${pendingConfig.relayUrl}`)
|
|
||||||
} else {
|
|
||||||
envFileContent[relayUrlIndex] = `RELAY_URL=${pendingConfig.relayUrl}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const automateLiquidityIndex = envFileContent.findIndex(line => line.startsWith('LIQUIDITY_PROVIDER_PUB'))
|
|
||||||
if (pendingConfig.automateLiquidity) {
|
|
||||||
if (automateLiquidityIndex !== -1) {
|
|
||||||
envFileContent.splice(automateLiquidityIndex, 1)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (automateLiquidityIndex === -1) {
|
|
||||||
toMerge.push(`LIQUIDITY_PROVIDER_PUB=null`)
|
|
||||||
} else {
|
|
||||||
envFileContent[automateLiquidityIndex] = `LIQUIDITY_PROVIDER_PUB=null`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const pushBackupsToNostrIndex = envFileContent.findIndex(line => line.startsWith('PUSH_BACKUPS_TO_NOSTR'))
|
|
||||||
if (pushBackupsToNostrIndex === -1) {
|
|
||||||
toMerge.push(`PUSH_BACKUPS_TO_NOSTR=${pendingConfig.pushBackupsToNostr ? 'true' : 'false'}`)
|
|
||||||
} else {
|
|
||||||
envFileContent[pushBackupsToNostrIndex] = `PUSH_BACKUPS_TO_NOSTR=${pendingConfig.pushBackupsToNostr ? 'true' : 'false'}`
|
|
||||||
}
|
|
||||||
const merged = [...envFileContent, ...toMerge].join('\n')
|
|
||||||
fs.writeFileSync('.env', merged)
|
|
||||||
loadEnvFile()
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue