Compare commits

...

5 Commits

4 changed files with 8 additions and 6 deletions

View File

@ -4,11 +4,13 @@ import * as bip39 from "@scure/bip39";
import { wordlist } from "@scure/bip39/wordlists/english"; import { wordlist } from "@scure/bip39/wordlists/english";
import { errorExit } from "./error.js"; import { errorExit } from "./error.js";
const BIP44_PATH = "m/44'/1627'/0'/0'/0'";
export function getSeed() { export function getSeed() {
const seed = config.str("seed"); const seed = config.str("seed");
let err = bip39.validateMnemonic(seed, wordlist); let valid = bip39.validateMnemonic(seed, wordlist);
if (err !== null) { if (!valid) {
errorExit("LUME_WEB_RELAY_SEED is invalid. Aborting."); errorExit("LUME_WEB_RELAY_SEED is invalid. Aborting.");
} }
@ -16,7 +18,7 @@ export function getSeed() {
} }
export function getHDKey(): HDKey { export function getHDKey(): HDKey {
return HDKey.fromMasterSeed(getSeed()).derive("m/44'/1627'/0'/0"); return HDKey.fromMasterSeed(getSeed()).derive(BIP44_PATH);
} }
export function getKeyPair() { export function getKeyPair() {

View File

@ -2,7 +2,7 @@ import express, { Express } from "express";
import http from "http"; import http from "http";
import { AddressInfo } from "net"; import { AddressInfo } from "net";
import log from "loglevel"; import log from "loglevel";
import { getKeyPair } from "./swarm.js"; import { getKeyPair } from "../lib/seed.js";
let app: Express; let app: Express;
let router = express.Router(); let router = express.Router();

View File

@ -7,7 +7,7 @@ import * as fs from "fs";
import path from "path"; import path from "path";
import type { Logger } from "loglevel"; import type { Logger } from "loglevel";
import { getSeed } from "../lib/util.js"; import { getSeed } from "../lib/seed.js";
import pluginRpc from "./plugins/rpc"; import pluginRpc from "./plugins/rpc";
import pluginCore from "./plugins/core"; import pluginCore from "./plugins/core";
import type Config from "@lumeweb/cfg"; import type Config from "@lumeweb/cfg";

View File

@ -8,7 +8,7 @@ import {
import promiseRetry from "promise-retry"; import promiseRetry from "promise-retry";
import config from "../config.js"; import config from "../config.js";
import log from "loglevel"; import log from "loglevel";
import { getSeed } from "../lib/util.js"; import { getSeed } from "../lib/seed.js";
import type { import type {
IndependentFileSmall, IndependentFileSmall,
SavedSslData, SavedSslData,