@1sat/cli 0.0.48 → 0.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/serve.ts +17 -4
package/package.json
CHANGED
package/src/commands/serve.ts
CHANGED
|
@@ -146,7 +146,7 @@ async function resolveServe(opts: GlobalFlags): Promise<ResolvedServe> {
|
|
|
146
146
|
return {
|
|
147
147
|
chain,
|
|
148
148
|
host: server.host ?? DEFAULT_HOST,
|
|
149
|
-
port: server.port
|
|
149
|
+
port: resolvePort(server.port),
|
|
150
150
|
onesatURL: DEFAULT_ONESAT_URL,
|
|
151
151
|
storage,
|
|
152
152
|
dataDir,
|
|
@@ -164,6 +164,18 @@ function deriveSqliteFilename(dataDir: string, chain: string): string {
|
|
|
164
164
|
return join(dataDir, `wallet-${chain}.db`)
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
function resolvePort(configured: number | undefined): number {
|
|
168
|
+
const fromEnv = process.env.ONESAT_PORT
|
|
169
|
+
if (fromEnv && fromEnv.trim() !== '') {
|
|
170
|
+
const parsed = Number(fromEnv)
|
|
171
|
+
if (!Number.isFinite(parsed) || parsed <= 0 || parsed > 65535) {
|
|
172
|
+
fatal(`ONESAT_PORT must be a valid port number, got: ${fromEnv}`)
|
|
173
|
+
}
|
|
174
|
+
return parsed
|
|
175
|
+
}
|
|
176
|
+
return configured ?? DEFAULT_PORT
|
|
177
|
+
}
|
|
178
|
+
|
|
167
179
|
function resolveWalletStorageConfig(
|
|
168
180
|
resolved: ResolvedServe,
|
|
169
181
|
): NodeWalletStorageConfig {
|
|
@@ -214,9 +226,10 @@ async function runWithStorage(
|
|
|
214
226
|
storage,
|
|
215
227
|
activeRemote: resolved.activeRemote,
|
|
216
228
|
backups: resolved.backups,
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
|
|
229
|
+
// Every serve mode manages monitor work explicitly: wallet mode
|
|
230
|
+
// does none, monitor/all modes run startTasks. The factory's
|
|
231
|
+
// initial runOnce is redundant in all three cases.
|
|
232
|
+
skipInitialMonitor: true,
|
|
220
233
|
})
|
|
221
234
|
|
|
222
235
|
const accounts =
|