From 77a9c6d20e3f2a2b92ff7551a293823185148c13 Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 11 Apr 2023 17:05:52 -0600 Subject: [PATCH] feat: Implentation of the daemons --- lib/health/trigger/TriggerInput.ts | 4 +- lib/mainFn/Daemons.ts | 53 ++- lib/mainFn/index.ts | 9 +- lib/types.ts | 116 ++--- output.ts | 713 ++++++++++++----------------- 5 files changed, 370 insertions(+), 525 deletions(-) diff --git a/lib/health/trigger/TriggerInput.ts b/lib/health/trigger/TriggerInput.ts index 8f5779f..18e7756 100644 --- a/lib/health/trigger/TriggerInput.ts +++ b/lib/health/trigger/TriggerInput.ts @@ -1,4 +1,4 @@ export type TriggerInput = { - lastResult: "success" | "failure" | null; - hadSuccess: boolean; + lastResult?: "success" | "failure" | null; + hadSuccess?: boolean; }; diff --git a/lib/mainFn/Daemons.ts b/lib/mainFn/Daemons.ts index ba2fd0d..1056363 100644 --- a/lib/mainFn/Daemons.ts +++ b/lib/mainFn/Daemons.ts @@ -1,13 +1,10 @@ import { HealthReceipt, ReadyProof } from "../health"; import { CheckResult } from "../health/checkFns"; import { Trigger } from "../health/trigger"; -import { Effects, ValidIfNoStupidEscape } from "../types"; +import { defaultTrigger } from "../health/trigger/defaultTrigger"; +import { DaemonReturned, Effects, ValidIfNoStupidEscape } from "../types"; import { InterfaceReceipt } from "./interfaceReceipt"; -type Daemon< - Ids extends string | never, - Command extends string, - Id extends string -> = { +type Daemon = { id: Id; command: ValidIfNoStupidEscape | [string, ...string[]]; @@ -20,11 +17,9 @@ type Daemon< trigger?: Trigger; }; requires?: Exclude[]; + intervalTime?: number; }; -const todo = (): A => { - throw new Error("TODO"); -}; /** * Used during the main of a function, it allows us to describe and ensure a set of daemons are running. * With the dependency, we are using this like an init system, where we can ensure that a daemon is running @@ -53,7 +48,7 @@ export class Daemons { private constructor( readonly effects: Effects, readonly started: (onTerm: () => void) => null, - readonly daemons?: Daemon[] + readonly daemons?: Daemon[] ) {} static of(config: { @@ -64,15 +59,39 @@ export class Daemons { }) { return new Daemons(config.effects, config.started); } - addDaemon( - newDaemon: Daemon - ) { - const daemons = [...(this?.daemons ?? [])]; - daemons.push(newDaemon as any); + addDaemon(newDaemon: Daemon) { + const daemons = ((this?.daemons ?? []) as any[]).concat(newDaemon); return new Daemons(this.effects, this.started, daemons); } - build() { - return todo(); + async build() { + const daemonsStarted = {} as Record>; + const { effects } = this; + const daemons = this.daemons ?? []; + const _config = await effects.getServiceConfig(); + for (const daemon of daemons) { + const requiredPromise = Promise.all(daemon.requires?.map((id) => daemonsStarted[id]) ?? []); + daemonsStarted[daemon.id] = requiredPromise.then(async () => { + const { command } = daemon; + + const child = effects.runDaemon(command); + const trigger = (daemon.ready.trigger ?? defaultTrigger)(); + for (let res = await trigger.next({}); !res.done; res = await trigger.next({})) { + const response = await daemon.ready.fn(); + if (response.status === "passing") { + return child; + } + } + return child; + }); + } + return { + async term() { + await Promise.all(Object.values>(daemonsStarted).map((x) => x.then((x) => x.term()))); + }, + async wait() { + await Promise.all(Object.values>(daemonsStarted).map((x) => x.then((x) => x.wait()))); + }, + }; } } diff --git a/lib/mainFn/index.ts b/lib/mainFn/index.ts index ee614bd..8ee9fb3 100644 --- a/lib/mainFn/index.ts +++ b/lib/mainFn/index.ts @@ -22,13 +22,10 @@ export { Daemons } from "./Daemons"; * @returns */ export const runningMain: ( - fn: (o: { - effects: Effects; - started(onTerm: () => void): null; - }) => Promise> + fn: (o: { effects: Effects; started(onTerm: () => void): null }) => Promise> ) => ExpectedExports.main = (fn) => { return async (options) => { - /// TODO BLUJ - return null as any; + const result = await fn(options); + await result.build().then((x) => x.wait()); }; }; diff --git a/lib/types.ts b/lib/types.ts index 6f4e7f4..450b564 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -4,39 +4,24 @@ import { InputSpec } from "./config/configTypes"; export namespace ExpectedExports { version: 1; /** Set configuration is called after we have modified and saved the configuration in the embassy ui. Use this to make a file for the docker to read from for configuration. */ - export type setConfig = (options: { - effects: Effects; - input: Record; - }) => Promise; + export type setConfig = (options: { effects: Effects; input: Record }) => Promise; /** Get configuration returns a shape that describes the format that the embassy ui will generate, and later send to the set config */ - export type getConfig = (options: { - effects: Effects; - config: unknown; - }) => Promise; + export type getConfig = (options: { effects: Effects; config: unknown }) => Promise; /** These are how we make sure the our dependency configurations are valid and if not how to fix them. */ export type dependencies = Dependencies; /** For backing up service data though the embassyOS UI */ - export type createBackup = (options: { - effects: Effects; - }) => Promise; + export type createBackup = (options: { effects: Effects }) => Promise; /** For restoring service data that was previously backed up using the embassyOS UI create backup flow. Backup restores are also triggered via the embassyOS UI, or doing a system restore flow during setup. */ - export type restoreBackup = (options: { - effects: Effects; - }) => Promise; + export type restoreBackup = (options: { effects: Effects }) => Promise; /** Properties are used to get values from the docker, like a username + password, what ports we are hosting from */ - export type properties = (options: { - effects: Effects; - }) => Promise; + export type properties = (options: { effects: Effects }) => Promise; /** Health checks are used to determine if the service is working properly after starting * A good use case is if we are using a web server, seeing if we can get to the web server. */ export type health = { /** Should be the health check id */ - [id: string]: (options: { - effects: Effects; - input: TimeMs; - }) => Promise; + [id: string]: (options: { effects: Effects; input: TimeMs }) => Promise; }; /** @@ -45,43 +30,29 @@ export namespace ExpectedExports { * service starting, and that file would indicate that it would rescan all the data. */ export type action = { - [id: string]: (options: { - effects: Effects; - input?: Record; - }) => Promise; + [id: string]: (options: { effects: Effects; input?: Record }) => Promise; }; /** * This is the entrypoint for the main container. Used to start up something like the service that the * package represents, like running a bitcoind in a bitcoind-wrapper. */ - export type main = (options: { - effects: Effects; - started(onTerm: () => void): null; - }) => Promise; + export type main = (options: { effects: Effects; started(onTerm: () => void): null }) => Promise; /** * Every time a package completes an install, this function is called before the main. * Can be used to do migration like things. */ - export type init = (options: { - effects: Effects; - previousVersion: null | string; - }) => Promise; + export type init = (options: { effects: Effects; previousVersion: null | string }) => Promise; /** This will be ran during any time a package is uninstalled, for example during a update * this will be called. */ - export type uninit = (options: { - effects: Effects; - nextVersion: null | string; - }) => Promise; + export type uninit = (options: { effects: Effects; nextVersion: null | string }) => Promise; } export type TimeMs = number; export type VersionString = string; -export type ValidIfNoStupidEscape = A extends - | `${string}'"'"'${string}` - | `${string}\\"${string}` +export type ValidIfNoStupidEscape = A extends `${string}'"'"'${string}` | `${string}\\"${string}` ? never : "" extends A & "" ? never @@ -106,18 +77,17 @@ export type Daemon = { export type HealthStatus = "passing" | "warning" | "failing" | "disabled"; -export type CommandType = - | ValidIfNoStupidEscape - | [string, ...string[]]; +export type CommandType = ValidIfNoStupidEscape | [string, ...string[]]; + +export type DaemonReturned = { + wait(): Promise; + term(): Promise; +}; /** Used to reach out from the pure js runtime */ export type Effects = { /** Usable when not sandboxed */ - writeFile(input: { - path: string; - volumeId: string; - toWrite: string; - }): Promise; + writeFile(input: { path: string; volumeId: string; toWrite: string }): Promise; readFile(input: { volumeId: string; path: string }): Promise; metadata(input: { volumeId: string; path: string }): Promise; /** Create a directory. Usable when not sandboxed */ @@ -129,17 +99,10 @@ export type Effects = { removeFile(input: { volumeId: string; path: string }): Promise; /** Write a json file into an object. Usable when not sandboxed */ - writeJsonFile(input: { - volumeId: string; - path: string; - toWrite: Record; - }): Promise; + writeJsonFile(input: { volumeId: string; path: string; toWrite: Record }): Promise; /** Read a json file into an object */ - readJsonFile(input: { - volumeId: string; - path: string; - }): Promise>; + readJsonFile(input: { volumeId: string; path: string }): Promise>; runCommand( command: ValidIfNoStupidEscape | [string, ...string[]], @@ -151,13 +114,7 @@ export type Effects = { wait(): Promise; term(): Promise; }; - runDaemon( - command: ValidIfNoStupidEscape | [string, ...string[]] - ): { - wait(): Promise; - term(): Promise; - [DaemonProof]: never; - }; + runDaemon(command: ValidIfNoStupidEscape | [string, ...string[]]): DaemonReturned; /** Uses the chown on the system */ chown(input: { volumeId: string; path: string; uid: string }): Promise; @@ -185,11 +142,7 @@ export type Effects = { /** Declaring that we are opening a interface on some protocal for local network */ bindLan(options: { internalPort: number; name: string }): Promise; /** Declaring that we are opening a interface on some protocal for tor network */ - bindTor(options: { - internalPort: number; - name: string; - externalPort: number; - }): Promise; + bindTor(options: { internalPort: number; name: string; externalPort: number }): Promise; /** Similar to the fetch api via the mdn, this is simplified but the point is * to get something from some website, and return the response. @@ -239,17 +192,11 @@ export type Effects = { getLocalHostname(): Promise; getIPHostname(): Promise; /** Get the address for another service for tor interfaces */ - getServiceTorHostname( - interfaceId: string, - packageId?: string - ): Promise; + getServiceTorHostname(interfaceId: string, packageId?: string): Promise; /** * Get the port address for another service */ - getServicePortForward( - internalPort: number, - packageId?: string - ): Promise; + getServicePortForward(internalPort: number, packageId?: string): Promise; /** When we want to create a link in the front end interfaces, and example is * exposing a url to view a web service @@ -319,20 +266,13 @@ export type Effects = { * * @returns PEM encoded fullchain (ecdsa) */ - getSslCertificate: ( - packageId: string, - algorithm?: "ecdsa" | "ed25519" - ) => [string, string, string]; + getSslCertificate: (packageId: string, algorithm?: "ecdsa" | "ed25519") => [string, string, string]; /** * @returns PEM encoded ssl key (ecdsa) */ getSslKey: (packageId: string, algorithm?: "ecdsa" | "ed25519") => string; - setHealth(o: { - name: string; - status: HealthStatus; - message?: string; - }): Promise; + setHealth(o: { name: string; status: HealthStatus; message?: string }): Promise; }; /* rsync options: https://linux.die.net/man/1/rsync @@ -456,6 +396,4 @@ export type Dependencies = { }; }; -export type DeepPartial = T extends {} - ? { [P in keyof T]?: DeepPartial } - : T; +export type DeepPartial = T extends {} ? { [P in keyof T]?: DeepPartial } : T; diff --git a/output.ts b/output.ts index e0421f6..f7f4228 100644 --- a/output.ts +++ b/output.ts @@ -1,476 +1,367 @@ -import { Config, Value, List, Variants } from "start-sdk/config/builder"; + + import {Config, Value, List, Variants} from 'start-sdk/config/builder'; export const name = Value.string({ - name: "Node Name", - default: "Embassy LND", - description: "Name of this node in the list", - warning: null, - required: true, - masked: false, - placeholder: null, - pattern: null, - patternDescription: null, + "name": "Node Name", + "default": "Embassy LND", + "description": "Name of this node in the list", + "warning": null, + "required": true, + "masked": false, + "placeholder": null, + "pattern": null, + "patternDescription": null }); -export const lnd = Config.of({ name: name }); -export const lightningNodesVariants = Variants.of({ - lnd: { name: "lnd", spec: lnd }, -}); -export const lightningNodesUnion = Value.union( - { - name: "Type", - description: - "- LND: Lightning Network Daemon from Lightning Labs\n- CLN: Core Lightning from Blockstream\n", - warning: null, - required: true, - default: "lnd", - }, - lightningNodesVariants -); -export const lightningNodesListConfig = Config.of({ - union: lightningNodesUnion, -}); -export const lightningNodesList = List.obj( - { - name: "Lightning Nodes", - range: "[1,*)", - default: [], - description: "List of Lightning Network node instances to manage", - warning: null, - }, - { - spec: lightningNodesListConfig, - displayAs: "{{name}}", - uniqueBy: "name", - } -); +export const lnd = Config.of({"name": name,});; +export const lightningNodesVariants = Variants.of({"lnd": {name: "lnd", spec: lnd},}); +export const lightningNodesUnion = + Value.union({ + name: "Type", + description: "- LND: Lightning Network Daemon from Lightning Labs\n- CLN: Core Lightning from Blockstream\n", + warning: null, + required: true, + default: "lnd", + }, lightningNodesVariants) + ; +export const lightningNodesListConfig = + Config.of({ + "union": lightningNodesUnion + }) + ; +export const lightningNodesList = List.obj({ + name:"Lightning Nodes", + range:"[1,*)", + default: [], + description: "List of Lightning Network node instances to manage", + warning: null, + }, { + spec: lightningNodesListConfig, + displayAs: "{{name}}", + uniqueBy: "name", + }); export const testListUnion = Value.list(lightningNodesList); export const enable = Value.boolean({ - name: "Enable", - default: true, - description: "Allow remote RPC requests.", - warning: null, + "name": "Enable", + "default": true, + "description": "Allow remote RPC requests.", + "warning": null }); export const username = Value.string({ - name: "Username", - default: "bitcoin", - description: "The username for connecting to Bitcoin over RPC.", - warning: null, - required: true, - masked: true, - placeholder: null, - pattern: "^[a-zA-Z0-9_]+$", - patternDescription: "Must be alphanumeric (can contain underscore).", + "name": "Username", + "default": "bitcoin", + "description": "The username for connecting to Bitcoin over RPC.", + "warning": null, + "required": true, + "masked": true, + "placeholder": null, + "pattern": "^[a-zA-Z0-9_]+$", + "patternDescription": "Must be alphanumeric (can contain underscore)." }); export const password = Value.string({ - name: "RPC Password", - default: { - charset: "a-z,2-7", - len: 20, + "name": "RPC Password", + "default": { + "charset": "a-z,2-7", + "len": 20 }, - description: "The password for connecting to Bitcoin over RPC.", - warning: null, - required: true, - masked: true, - placeholder: null, - pattern: '^[^\\n"]*$', - patternDescription: "Must not contain newline or quote characters.", + "description": "The password for connecting to Bitcoin over RPC.", + "warning": null, + "required": true, + "masked": true, + "placeholder": null, + "pattern": "^[^\\n\"]*$", + "patternDescription": "Must not contain newline or quote characters." }); export const bio = Value.textarea({ - name: "Username", - description: "The username for connecting to Bitcoin over RPC.", - warning: null, - required: true, - placeholder: null, + "name": "Username", + "description": "The username for connecting to Bitcoin over RPC.", + "warning": null, + "required": true, + "placeholder": null }); -export const authorizationList = List.string( - { - name: "Authorization", - range: "[0,*)", - default: [], - description: - "Username and hashed password for JSON-RPC connections. RPC clients connect using the usual http basic authentication.", - warning: null, - }, - { - masked: false, - placeholder: null, - pattern: "^[a-zA-Z0-9_-]+:([0-9a-fA-F]{2})+\\$([0-9a-fA-F]{2})+$", - patternDescription: - 'Each item must be of the form ":$".', - } -); +export const authorizationList = List.string({ + "name": "Authorization", + "range": "[0,*)", + "default": [], + "description": "Username and hashed password for JSON-RPC connections. RPC clients connect using the usual http basic authentication.", + "warning": null +}, {"masked":false,"placeholder":null,"pattern":"^[a-zA-Z0-9_-]+:([0-9a-fA-F]{2})+\\$([0-9a-fA-F]{2})+$","patternDescription":"Each item must be of the form \":$\"."}); export const auth = Value.list(authorizationList); export const serialversion = Value.select({ - name: "Serialization Version", - description: - "Return raw transaction or block hex with Segwit or non-SegWit serialization.", - warning: null, - default: "segwit", - required: true, - values: { + "name": "Serialization Version", + "description": "Return raw transaction or block hex with Segwit or non-SegWit serialization.", + "warning": null, + "default": "segwit", + "required": true, + "values": { "non-segwit": "non-segwit", - segwit: "segwit", - }, + "segwit": "segwit" + } } as const); export const servertimeout = Value.number({ - name: "Rpc Server Timeout", - default: 30, - description: - "Number of seconds after which an uncompleted RPC call will time out.", - warning: null, - required: true, - range: "[5,300]", - integral: true, - units: "seconds", - placeholder: null, + "name": "Rpc Server Timeout", + "default": 30, + "description": "Number of seconds after which an uncompleted RPC call will time out.", + "warning": null, + "required": true, + "range": "[5,300]", + "integral": true, + "units": "seconds", + "placeholder": null }); export const threads = Value.number({ - name: "Threads", - default: 16, - description: - "Set the number of threads for handling RPC calls. You may wish to increase this if you are making lots of calls via an integration.", - warning: null, - required: true, - range: "[1,64]", - integral: true, - units: null, - placeholder: null, + "name": "Threads", + "default": 16, + "description": "Set the number of threads for handling RPC calls. You may wish to increase this if you are making lots of calls via an integration.", + "warning": null, + "required": true, + "range": "[1,64]", + "integral": true, + "units": null, + "placeholder": null }); export const workqueue = Value.number({ - name: "Work Queue", - default: 128, - description: - "Set the depth of the work queue to service RPC calls. Determines how long the backlog of RPC requests can get before it just rejects new ones.", - warning: null, - required: true, - range: "[8,256]", - integral: true, - units: "requests", - placeholder: null, + "name": "Work Queue", + "default": 128, + "description": "Set the depth of the work queue to service RPC calls. Determines how long the backlog of RPC requests can get before it just rejects new ones.", + "warning": null, + "required": true, + "range": "[8,256]", + "integral": true, + "units": "requests", + "placeholder": null }); -export const advancedSpec = Config.of({ - auth: auth, - serialversion: serialversion, - servertimeout: servertimeout, - threads: threads, - workqueue: workqueue, -}); -export const advanced = Value.object( - { - name: "Advanced", - description: "Advanced RPC Settings", - warning: null, - }, - advancedSpec -); -export const rpcSettingsSpec = Config.of({ - enable: enable, - username: username, - password: password, - bio: bio, - advanced: advanced, -}); -export const rpc = Value.object( - { - name: "RPC Settings", - description: "RPC configuration options.", - warning: null, - }, - rpcSettingsSpec -); +export const advancedSpec = Config.of({"auth": auth,"serialversion": serialversion,"servertimeout": servertimeout,"threads": threads,"workqueue": workqueue,});; +export const advanced = Value.object({ + name: "Advanced", + description: "Advanced RPC Settings", + warning: null, + }, advancedSpec); +export const rpcSettingsSpec = Config.of({"enable": enable,"username": username,"password": password,"bio": bio,"advanced": advanced,});; +export const rpc = Value.object({ + name: "RPC Settings", + description: "RPC configuration options.", + warning: null, + }, rpcSettingsSpec); export const zmqEnabled = Value.boolean({ - name: "ZeroMQ Enabled", - default: true, - description: "Enable the ZeroMQ interface", - warning: null, + "name": "ZeroMQ Enabled", + "default": true, + "description": "Enable the ZeroMQ interface", + "warning": null }); export const txindex = Value.boolean({ - name: "Transaction Index", - default: true, - description: "Enable the Transaction Index (txindex)", - warning: null, + "name": "Transaction Index", + "default": true, + "description": "Enable the Transaction Index (txindex)", + "warning": null }); export const enable1 = Value.boolean({ - name: "Enable Wallet", - default: true, - description: "Load the wallet and enable wallet RPC calls.", - warning: null, + "name": "Enable Wallet", + "default": true, + "description": "Load the wallet and enable wallet RPC calls.", + "warning": null }); export const avoidpartialspends = Value.boolean({ - name: "Avoid Partial Spends", - default: true, - description: - "Group outputs by address, selecting all or none, instead of selecting on a per-output basis. This improves privacy at the expense of higher transaction fees.", - warning: null, + "name": "Avoid Partial Spends", + "default": true, + "description": "Group outputs by address, selecting all or none, instead of selecting on a per-output basis. This improves privacy at the expense of higher transaction fees.", + "warning": null }); export const discardfee = Value.number({ - name: "Discard Change Tolerance", - default: 0.0001, - description: - "The fee rate (in BTC/kB) that indicates your tolerance for discarding change by adding it to the fee.", - warning: null, - required: true, - range: "[0,.01]", - integral: false, - units: "BTC/kB", - placeholder: null, + "name": "Discard Change Tolerance", + "default": 0.0001, + "description": "The fee rate (in BTC/kB) that indicates your tolerance for discarding change by adding it to the fee.", + "warning": null, + "required": true, + "range": "[0,.01]", + "integral": false, + "units": "BTC/kB", + "placeholder": null }); -export const walletSpec = Config.of({ - enable: enable1, - avoidpartialspends: avoidpartialspends, - discardfee: discardfee, -}); -export const wallet = Value.object( - { - name: "Wallet", - description: "Wallet Settings", - warning: null, - }, - walletSpec -); +export const walletSpec = Config.of({"enable": enable1,"avoidpartialspends": avoidpartialspends,"discardfee": discardfee,});; +export const wallet = Value.object({ + name: "Wallet", + description: "Wallet Settings", + warning: null, + }, walletSpec); export const mempoolfullrbf = Value.boolean({ - name: "Enable Full RBF", - default: false, - description: - "Policy for your node to use for relaying and mining unconfirmed transactions. For details, see https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-24.0.md#notice-of-new-option-for-transaction-replacement-policies", - warning: null, + "name": "Enable Full RBF", + "default": false, + "description": "Policy for your node to use for relaying and mining unconfirmed transactions. For details, see https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-24.0.md#notice-of-new-option-for-transaction-replacement-policies", + "warning": null }); export const persistmempool = Value.boolean({ - name: "Persist Mempool", - default: true, - description: "Save the mempool on shutdown and load on restart.", - warning: null, + "name": "Persist Mempool", + "default": true, + "description": "Save the mempool on shutdown and load on restart.", + "warning": null }); export const maxmempool = Value.number({ - name: "Max Mempool Size", - default: 300, - description: "Keep the transaction memory pool below megabytes.", - warning: null, - required: true, - range: "[1,*)", - integral: true, - units: "MiB", - placeholder: null, + "name": "Max Mempool Size", + "default": 300, + "description": "Keep the transaction memory pool below megabytes.", + "warning": null, + "required": true, + "range": "[1,*)", + "integral": true, + "units": "MiB", + "placeholder": null }); export const mempoolexpiry = Value.number({ - name: "Mempool Expiration", - default: 336, - description: "Do not keep transactions in the mempool longer than hours.", - warning: null, - required: true, - range: "[1,*)", - integral: true, - units: "Hr", - placeholder: null, + "name": "Mempool Expiration", + "default": 336, + "description": "Do not keep transactions in the mempool longer than hours.", + "warning": null, + "required": true, + "range": "[1,*)", + "integral": true, + "units": "Hr", + "placeholder": null }); -export const mempoolSpec = Config.of({ - mempoolfullrbf: mempoolfullrbf, - persistmempool: persistmempool, - maxmempool: maxmempool, - mempoolexpiry: mempoolexpiry, -}); -export const mempool = Value.object( - { - name: "Mempool", - description: "Mempool Settings", - warning: null, - }, - mempoolSpec -); +export const mempoolSpec = Config.of({"mempoolfullrbf": mempoolfullrbf,"persistmempool": persistmempool,"maxmempool": maxmempool,"mempoolexpiry": mempoolexpiry,});; +export const mempool = Value.object({ + name: "Mempool", + description: "Mempool Settings", + warning: null, + }, mempoolSpec); export const listen = Value.boolean({ - name: "Make Public", - default: true, - description: "Allow other nodes to find your server on the network.", - warning: null, + "name": "Make Public", + "default": true, + "description": "Allow other nodes to find your server on the network.", + "warning": null }); export const onlyconnect = Value.boolean({ - name: "Disable Peer Discovery", - default: false, - description: "Only connect to specified peers.", - warning: null, + "name": "Disable Peer Discovery", + "default": false, + "description": "Only connect to specified peers.", + "warning": null }); export const onlyonion = Value.boolean({ - name: "Disable Clearnet", - default: false, - description: "Only connect to peers over Tor.", - warning: null, + "name": "Disable Clearnet", + "default": false, + "description": "Only connect to peers over Tor.", + "warning": null }); export const hostname = Value.string({ - name: "Hostname", - default: null, - description: "Domain or IP address of bitcoin peer", - warning: null, - required: true, - masked: false, - placeholder: null, - pattern: - "(^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$)|((^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$)|(^[a-z2-7]{16}\\.onion$)|(^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$))", - patternDescription: - "Must be either a domain name, or an IPv4 or IPv6 address. Do not include protocol scheme (eg 'http://') or port.", + "name": "Hostname", + "default": null, + "description": "Domain or IP address of bitcoin peer", + "warning": null, + "required": true, + "masked": false, + "placeholder": null, + "pattern": "(^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$)|((^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$)|(^[a-z2-7]{16}\\.onion$)|(^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$))", + "patternDescription": "Must be either a domain name, or an IPv4 or IPv6 address. Do not include protocol scheme (eg 'http://') or port." }); export const port = Value.number({ - name: "Port", - default: null, - description: "Port that peer is listening on for inbound p2p connections", - warning: null, - required: false, - range: "[0,65535]", - integral: true, - units: null, - placeholder: null, + "name": "Port", + "default": null, + "description": "Port that peer is listening on for inbound p2p connections", + "warning": null, + "required": false, + "range": "[0,65535]", + "integral": true, + "units": null, + "placeholder": null }); -export const addNodesSpec = Config.of({ hostname: hostname, port: port }); -export const addNodesList = List.obj( - { - name: "Add Nodes", - range: "[0,*)", - default: [], - description: "Add addresses of nodes to connect to.", - warning: null, - }, - { - spec: addNodesSpec, - displayAs: null, - uniqueBy: null, - } -); +export const addNodesSpec = Config.of({"hostname": hostname,"port": port,});; +export const addNodesList = List.obj({ + name: "Add Nodes", + range: "[0,*)", + default: [], + description: "Add addresses of nodes to connect to.", + warning: null, + }, { + spec: addNodesSpec, + displayAs: null, + uniqueBy: null, + }); export const addnode = Value.list(addNodesList); -export const peersSpec = Config.of({ - listen: listen, - onlyconnect: onlyconnect, - onlyonion: onlyonion, - addnode: addnode, -}); -export const peers = Value.object( - { - name: "Peers", - description: "Peer Connection Settings", - warning: null, - }, - peersSpec -); +export const peersSpec = Config.of({"listen": listen,"onlyconnect": onlyconnect,"onlyonion": onlyonion,"addnode": addnode,});; +export const peers = Value.object({ + name: "Peers", + description: "Peer Connection Settings", + warning: null, + }, peersSpec); export const dbcache = Value.number({ - name: "Database Cache", - default: null, - description: - "How much RAM to allocate for caching the TXO set. Higher values improve syncing performance, but increase your chance of using up all your system's memory or corrupting your database in the event of an ungraceful shutdown. Set this high but comfortably below your system's total RAM during IBD, then turn down to 450 (or leave blank) once the sync completes.", - warning: - "WARNING: Increasing this value results in a higher chance of ungraceful shutdowns, which can leave your node unusable if it happens during the initial block download. Use this setting with caution. Be sure to set this back to the default (450 or leave blank) once your node is synced. DO NOT press the STOP button if your dbcache is large. Instead, set this number back to the default, hit save, and wait for bitcoind to restart on its own.", - required: false, - range: "(0,*)", - integral: true, - units: "MiB", - placeholder: null, + "name": "Database Cache", + "default": null, + "description": "How much RAM to allocate for caching the TXO set. Higher values improve syncing performance, but increase your chance of using up all your system's memory or corrupting your database in the event of an ungraceful shutdown. Set this high but comfortably below your system's total RAM during IBD, then turn down to 450 (or leave blank) once the sync completes.", + "warning": "WARNING: Increasing this value results in a higher chance of ungraceful shutdowns, which can leave your node unusable if it happens during the initial block download. Use this setting with caution. Be sure to set this back to the default (450 or leave blank) once your node is synced. DO NOT press the STOP button if your dbcache is large. Instead, set this number back to the default, hit save, and wait for bitcoind to restart on its own.", + "required": false, + "range": "(0,*)", + "integral": true, + "units": "MiB", + "placeholder": null }); -export const disabled = Config.of({}); +export const disabled = Config.of({});; export const size = Value.number({ - name: "Max Chain Size", - default: 550, - description: "Limit of blockchain size on disk.", - warning: "Increasing this value will require re-syncing your node.", - required: true, - range: "[550,1000000)", - integral: true, - units: "MiB", - placeholder: null, + "name": "Max Chain Size", + "default": 550, + "description": "Limit of blockchain size on disk.", + "warning": "Increasing this value will require re-syncing your node.", + "required": true, + "range": "[550,1000000)", + "integral": true, + "units": "MiB", + "placeholder": null }); -export const automatic = Config.of({ size: size }); +export const automatic = Config.of({"size": size,});; export const size1 = Value.number({ - name: "Failsafe Chain Size", - default: 65536, - description: "Prune blockchain if size expands beyond this.", - warning: null, - required: true, - range: "[550,1000000)", - integral: true, - units: "MiB", - placeholder: null, + "name": "Failsafe Chain Size", + "default": 65536, + "description": "Prune blockchain if size expands beyond this.", + "warning": null, + "required": true, + "range": "[550,1000000)", + "integral": true, + "units": "MiB", + "placeholder": null }); -export const manual = Config.of({ size: size1 }); -export const pruningSettingsVariants = Variants.of({ - disabled: { name: "Disabled", spec: disabled }, - automatic: { name: "Automatic", spec: automatic }, - manual: { name: "Manual", spec: manual }, -}); -export const pruning = Value.union( - { - name: "Pruning Settings", - description: - '- Disabled: Disable pruning\n- Automatic: Limit blockchain size on disk to a certain number of megabytes\n- Manual: Prune blockchain with the "pruneblockchain" RPC\n', - warning: null, - required: true, - default: "disabled", - }, - pruningSettingsVariants -); +export const manual = Config.of({"size": size1,});; +export const pruningSettingsVariants = Variants.of({"disabled": {name: "Disabled", spec: disabled},"automatic": {name: "Automatic", spec: automatic},"manual": {name: "Manual", spec: manual},}); +export const pruning = Value.union({ + name: "Pruning Settings", + description: "- Disabled: Disable pruning\n- Automatic: Limit blockchain size on disk to a certain number of megabytes\n- Manual: Prune blockchain with the \"pruneblockchain\" RPC\n", + warning: null, + required: true, + default: "disabled", + }, pruningSettingsVariants); export const blockfilterindex = Value.boolean({ - name: "Compute Compact Block Filters (BIP158)", - default: true, - description: - "Generate Compact Block Filters during initial sync (IBD) to enable 'getblockfilter' RPC. This is useful if dependent services need block filters to efficiently scan for addresses/transactions etc.", - warning: null, + "name": "Compute Compact Block Filters (BIP158)", + "default": true, + "description": "Generate Compact Block Filters during initial sync (IBD) to enable 'getblockfilter' RPC. This is useful if dependent services need block filters to efficiently scan for addresses/transactions etc.", + "warning": null }); export const peerblockfilters = Value.boolean({ - name: "Serve Compact Block Filters to Peers (BIP157)", - default: false, - description: - "Serve Compact Block Filters as a peer service to other nodes on the network. This is useful if you wish to connect an SPV client to your node to make it efficient to scan transactions without having to download all block data. 'Compute Compact Block Filters (BIP158)' is required.", - warning: null, + "name": "Serve Compact Block Filters to Peers (BIP157)", + "default": false, + "description": "Serve Compact Block Filters as a peer service to other nodes on the network. This is useful if you wish to connect an SPV client to your node to make it efficient to scan transactions without having to download all block data. 'Compute Compact Block Filters (BIP158)' is required.", + "warning": null }); -export const blockFiltersSpec = Config.of({ - blockfilterindex: blockfilterindex, - peerblockfilters: peerblockfilters, -}); -export const blockfilters = Value.object( - { - name: "Block Filters", - description: "Settings for storing and serving compact block filters", - warning: null, - }, - blockFiltersSpec -); +export const blockFiltersSpec = Config.of({"blockfilterindex": blockfilterindex,"peerblockfilters": peerblockfilters,});; +export const blockfilters = Value.object({ + name: "Block Filters", + description: "Settings for storing and serving compact block filters", + warning: null, + }, blockFiltersSpec); export const peerbloomfilters = Value.boolean({ - name: "Serve Bloom Filters to Peers", - default: false, - description: - "Peers have the option of setting filters on each connection they make after the version handshake has completed. Bloom filters are for clients implementing SPV (Simplified Payment Verification) that want to check that block headers connect together correctly, without needing to verify the full blockchain. The client must trust that the transactions in the chain are in fact valid. It is highly recommended AGAINST using for anything except Bisq integration.", - warning: - "This is ONLY for use with Bisq integration, please use Block Filters for all other applications.", -}); -export const bloomFiltersBip37Spec = Config.of({ - peerbloomfilters: peerbloomfilters, -}); -export const bloomfilters = Value.object( - { - name: "Bloom Filters (BIP37)", - description: "Setting for serving Bloom Filters", - warning: null, - }, - bloomFiltersBip37Spec -); -export const advancedSpec1 = Config.of({ - mempool: mempool, - peers: peers, - dbcache: dbcache, - pruning: pruning, - blockfilters: blockfilters, - bloomfilters: bloomfilters, -}); -export const advanced1 = Value.object( - { - name: "Advanced", - description: "Advanced Settings", - warning: null, - }, - advancedSpec1 -); -export const inputSpec = Config.of({ - testListUnion: testListUnion, - rpc: rpc, - "zmq-enabled": zmqEnabled, - txindex: txindex, - wallet: wallet, - advanced: advanced1, + "name": "Serve Bloom Filters to Peers", + "default": false, + "description": "Peers have the option of setting filters on each connection they make after the version handshake has completed. Bloom filters are for clients implementing SPV (Simplified Payment Verification) that want to check that block headers connect together correctly, without needing to verify the full blockchain. The client must trust that the transactions in the chain are in fact valid. It is highly recommended AGAINST using for anything except Bisq integration.", + "warning": "This is ONLY for use with Bisq integration, please use Block Filters for all other applications." }); +export const bloomFiltersBip37Spec = Config.of({"peerbloomfilters": peerbloomfilters,});; +export const bloomfilters = Value.object({ + name: "Bloom Filters (BIP37)", + description: "Setting for serving Bloom Filters", + warning: null, + }, bloomFiltersBip37Spec); +export const advancedSpec1 = Config.of({"mempool": mempool,"peers": peers,"dbcache": dbcache,"pruning": pruning,"blockfilters": blockfilters,"bloomfilters": bloomfilters,});; +export const advanced1 = Value.object({ + name: "Advanced", + description: "Advanced Settings", + warning: null, + }, advancedSpec1); +export const inputSpec = Config.of({"testListUnion": testListUnion,"rpc": rpc,"zmq-enabled": zmqEnabled,"txindex": txindex,"wallet": wallet,"advanced": advanced1,});; export const matchInputSpec = inputSpec.validator(); -export type InputSpec = typeof matchInputSpec._TYPE; +export type InputSpec = typeof matchInputSpec._TYPE; \ No newline at end of file