diff --git a/Makefile b/Makefile index f3833f2..8a16447 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ make clean: lib/test/output.ts: lib/test/makeOutput.ts scripts/oldSpecToBuilder.ts npm run buildOutput -bundle: fmt $(TS_FILES) package.json .FORCE node_modules +bundle: fmt $(TS_FILES) package.json .FORCE node_modules test rm -rf dist || true npx tsc diff --git a/lib/config/configTypes.ts b/lib/config/configTypes.ts index 726d156..c089cec 100644 --- a/lib/config/configTypes.ts +++ b/lib/config/configTypes.ts @@ -1,41 +1,35 @@ import * as C from "./configTypesRaw"; export type ValueType = C.ValueType; -// prettier-ignore -export type WithOutOptionals = - A extends Record ? {[k in keyof A]: A[k]} : - A; -export type InputSpec = Record>; +export type InputSpec = Record>; -export type ValueSpec = WithOutOptionals; +export type ValueSpec = Required; /** core spec types. These types provide the metadata for performing validations */ -export type ValueSpecOf = WithOutOptionals< - C.ValueSpecOf ->; +export type ValueSpecOf = Required>; -export type ValueSpecString = WithOutOptionals; -export type ValueSpecTextarea = WithOutOptionals; -export type ValueSpecNumber = WithOutOptionals; -export type ValueSpecSelect = WithOutOptionals; -export type ValueSpecMultiselect = WithOutOptionals; -export type ValueSpecBoolean = WithOutOptionals; -export type ValueSpecUnion = WithOutOptionals; -export type ValueSpecFile = WithOutOptionals; -export type ValueSpecObject = WithOutOptionals; -export type WithStandalone = WithOutOptionals; -export type SelectBase = WithOutOptionals; -export type ListValueSpecType = WithOutOptionals; +export type ValueSpecString = Required; +export type ValueSpecTextarea = Required; +export type ValueSpecNumber = Required; +export type ValueSpecSelect = Required; +export type ValueSpecMultiselect = Required; +export type ValueSpecBoolean = Required; +export type ValueSpecUnion = Required; +export type ValueSpecFile = Required; +export type ValueSpecObject = Required; +export type WithStandalone = Required; +export type SelectBase = Required; +export type ListValueSpecType = Required; /** represents a spec for the values of a list */ -export type ListValueSpecOf = WithOutOptionals< +export type ListValueSpecOf = Required< C.ListValueSpecOf >; /** represents a spec for a list */ -export type ValueSpecList = WithOutOptionals; -export type ValueSpecListOf = WithOutOptionals< +export type ValueSpecList = Required; +export type ValueSpecListOf = Required< C.ValueSpecListOf >; @@ -46,11 +40,11 @@ export function isValueSpecListOf( ): t is ValueSpecListOf & { spec: ListValueSpecOf } { return t.spec.type === s; } -export type ListValueSpecString = WithOutOptionals; -export type ListValueSpecNumber = WithOutOptionals; -export type ListValueSpecObject = WithOutOptionals; -export type UniqueBy = WithOutOptionals; -export type DefaultString = WithOutOptionals; +export type ListValueSpecString = Required; +export type ListValueSpecNumber = Required; +export type ListValueSpecObject = Required; +export type UniqueBy = Required; +export type DefaultString = Required; export const unionSelectKey = "unionSelectKey" as const; export type UnionSelectKey = typeof unionSelectKey; diff --git a/lib/config/configTypesRaw.ts b/lib/config/configTypesRaw.ts index 9b88911..46a1be8 100644 --- a/lib/config/configTypesRaw.ts +++ b/lib/config/configTypesRaw.ts @@ -1,3 +1,11 @@ +export { + InputSpec, + UnionSelectKey, + UnionValueKey, + unionSelectKey, + unionValueKey, +} from "./configTypes"; + export type InputSpecRaw = Record; export type ValueType = | "string" @@ -33,6 +41,7 @@ export type ValueSpecOf = T extends "string" : T extends "union" ? ValueSpecUnion : never; + export interface ValueSpecString extends ListValueSpecString, WithStandalone { required: boolean; default?: DefaultString | null; diff --git a/lib/health/checkFns/checkWebUrl.ts b/lib/health/checkFns/checkWebUrl.ts index 57cd357..a8ebf45 100644 --- a/lib/health/checkFns/checkWebUrl.ts +++ b/lib/health/checkFns/checkWebUrl.ts @@ -9,8 +9,8 @@ import { timeoutPromise } from "./index"; * @returns */ export const checkWebUrl = async ( - url: string, effects: Effects, + url: string, { timeout = 1000, successMessage = `Reached ${url}`, diff --git a/lib/mainFn/Daemons.ts b/lib/mainFn/Daemons.ts index b18cbb6..163db49 100644 --- a/lib/mainFn/Daemons.ts +++ b/lib/mainFn/Daemons.ts @@ -74,7 +74,6 @@ export class Daemons { 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]) ?? [] diff --git a/lib/mainFn/LocalPort.ts b/lib/mainFn/LocalPort.ts index 0ae4da1..9a761ae 100644 --- a/lib/mainFn/LocalPort.ts +++ b/lib/mainFn/LocalPort.ts @@ -2,7 +2,7 @@ import { Effects } from "../types"; import { LocalBinding } from "./LocalBinding"; export class LocalPort { - constructor(readonly id: string, readonly effects: Effects) {} + constructor(readonly effects: Effects, readonly id: string) {} async bindLan(internalPort: number) { const [localAddress, ipAddress] = await this.effects.bindLan({ internalPort, diff --git a/lib/mainFn/NetworkBuilder.ts b/lib/mainFn/NetworkBuilder.ts index 6e052d0..4edbdac 100644 --- a/lib/mainFn/NetworkBuilder.ts +++ b/lib/mainFn/NetworkBuilder.ts @@ -9,9 +9,9 @@ export class NetworkBuilder { private constructor(private effects: Effects) {} getTorHostName(id: string) { - return new TorHostname(id, this.effects); + return new TorHostname(this.effects, id); } getPort(id: string) { - return new LocalPort(id, this.effects); + return new LocalPort(this.effects, id); } } diff --git a/lib/mainFn/TorHostname.ts b/lib/mainFn/TorHostname.ts index 0652659..9a3f5ce 100644 --- a/lib/mainFn/TorHostname.ts +++ b/lib/mainFn/TorHostname.ts @@ -2,7 +2,10 @@ import { Effects } from "../types"; import { TorBinding } from "./TorBinding"; export class TorHostname { - constructor(readonly id: string, readonly effects: Effects) {} + constructor(readonly effects: Effects, readonly id: string) {} + static of(effects: Effects, id: string) { + return new TorHostname(effects, id); + } async bindTor(internalPort: number, externalPort: number) { const address = await this.effects.bindTor({ internalPort, diff --git a/lib/properties/index.ts b/lib/properties/index.ts index 3e5d6ae..27e19e5 100644 --- a/lib/properties/index.ts +++ b/lib/properties/index.ts @@ -6,9 +6,7 @@ export { PropertyObject } from "./PropertyObject"; export { PropertyString } from "./PropertyString"; export const test = ""; -export type UnionToIntersection = ((x: T) => any) extends (x: infer R) => any - ? R - : never; +export type UnionToIntersection = ((x: T) => any) extends (x: infer R) => any ? R : never; /** * This is used during creating the type of properties fn in the service package. @@ -20,10 +18,12 @@ export type UnionToIntersection = ((x: T) => any) extends (x: infer R) => any export function setupPropertiesExport( fn: ( ...args: Parameters - ) => Promise | void | Promise> + ) => void | Promise | Promise> ): ExpectedExports.properties { return async (...args: Parameters) => { - const value = await fn(...args); - if (value) return value.build(); + const result = await fn(...args); + if (result) { + return result.build(); + } }; } diff --git a/lib/test/makeOutput.ts b/lib/test/makeOutput.ts index b127d85..1d62d25 100644 --- a/lib/test/makeOutput.ts +++ b/lib/test/makeOutput.ts @@ -1,7 +1,7 @@ import { writeConvertedFile } from "../../scripts/oldSpecToBuilder"; writeConvertedFile( - "./output.ts", // Make the location + "./lib/test/output.ts", // Make the location { // Put the config here testListUnion: { @@ -406,6 +406,6 @@ writeConvertedFile( }, }, { - startSdk: "start-sdk", + startSdk: "../", } ); diff --git a/lib/types.ts b/lib/types.ts index 74690fa..5f2703e 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -231,12 +231,22 @@ export type Effects = { progress: () => Promise; }; - getServiceConfig(options?: { + /** Get a value in a json like data, can be observed and subscribed */ + getWrapperData(options?: { + /** If there is no packageId it is assumed the current package */ packageId?: string; + /** The path defaults to root level, using the [JsonPath](https://jsonpath.com/) */ path?: string; - callback?: (config: unknown, previousConfig: unknown) => void; + callback: (config: unknown, previousConfig: unknown) => void; }): Promise; + /** Used to store values that can be accessed and subscribed to */ + setWrapperData(options?: { + /** Sets the value for the wrapper at the path, it will override, using the [JsonPath](https://jsonpath.com/) */ + path?: string; + value: unknown; + }): Promise; + getLocalHostname(): Promise; getIPHostname(): Promise; /** Get the address for another service for tor interfaces */ @@ -334,6 +344,9 @@ export type Effects = { status: HealthStatus; message?: string; }): Promise; + + restart(): void; + shutdown(): void; }; /* rsync options: https://linux.die.net/man/1/rsync diff --git a/lib/util/getWrapperData.ts b/lib/util/getWrapperData.ts new file mode 100644 index 0000000..9592c37 --- /dev/null +++ b/lib/util/getWrapperData.ts @@ -0,0 +1,45 @@ +import { Parser } from "ts-matches"; +import { Effects } from "../types"; + +export function getWrapperData( + effects: Effects, + validator: Parser, + options: { + /** Defaults to what ever the package currently in */ + packageId?: string | undefined; + /** JsonPath */ + path?: string | undefined; + } = {} +) { + return { + const: () => + effects + .getWrapperData({ + ...options, + callback: effects.restart, + }) + .then(validator.unsafeCast), + first: () => + effects + .getWrapperData({ + ...options, + callback: () => {}, + }) + .then(validator.unsafeCast), + overTime: async function* () { + while (true) { + let callback: () => void; + const waitForNext = new Promise((resolve) => { + callback = resolve; + }); + yield await effects + .getWrapperData({ + ...options, + callback: () => callback(), + }) + .then(validator.unsafeCast); + await waitForNext; + } + }, + }; +} diff --git a/lib/util/index.ts b/lib/util/index.ts index 7ecfe55..4d4df9d 100644 --- a/lib/util/index.ts +++ b/lib/util/index.ts @@ -1,8 +1,15 @@ +import { Parser, string } from "ts-matches"; import * as T from "../types"; +import FileHelper from "./fileHelper"; +import nullIfEmpty from "./nullIfEmpty"; +import { getWrapperData } from "./getWrapperData"; +import { checkPortListening, checkWebUrl } from "../health/checkFns"; +import { LocalPort, NetworkBuilder, TorHostname } from "../mainFn"; export { guardAll, typeFromProps } from "./propertiesMatcher"; export { default as nullIfEmpty } from "./nullIfEmpty"; export { FileHelper } from "./fileHelper"; +export { getWrapperData } from "./getWrapperData"; /** Used to check if the file exists before hand */ export const exists = ( @@ -16,3 +23,31 @@ export const exists = ( export const isKnownError = (e: unknown): e is T.KnownError => e instanceof Object && ("error" in e || "error-code" in e); + +type Cdr = A extends [unknown, ...infer Cdr] ? Cdr : []; + +export const utils = (effects: T.Effects) => ({ + readFile: (fileHelper: FileHelper) => fileHelper.read(effects), + writeFile: (fileHelper: FileHelper, data: A) => + fileHelper.write(data, effects), + exists: (props: { path: string; volumeId: string }) => exists(effects, props), + nullIfEmpty, + getWrapperData: ( + validator: Parser, + options: { + /** Defaults to what ever the package currently in */ + packageId?: string | undefined; + /** JsonPath */ + path?: string | undefined; + } = {} + ) => getWrapperData(effects, validator, options), + setWrapperData: ( + value: A, + options: { packageId?: string | undefined; path?: string | undefined } = {} + ) => effects.setWrapperData({ ...options, value }), + checkPortListening: checkPortListening.bind(null, effects), + checkWebUrl: checkWebUrl.bind(null, effects), + localPort: LocalPort.bind(null, effects), + networkBuilder: NetworkBuilder.of.bind(null, effects), + torHostName: TorHostname.of.bind(null, effects), +}); diff --git a/lib/util/propertiesMatcher.ts b/lib/util/propertiesMatcher.ts index efce533..2246b13 100644 --- a/lib/util/propertiesMatcher.ts +++ b/lib/util/propertiesMatcher.ts @@ -1,14 +1,11 @@ import * as matches from "ts-matches"; import { Parser, Validator } from "ts-matches"; -import { Variants } from "../config/builder"; import { - InputSpec, UnionSelectKey, - unionSelectKey, - unionValueKey, UnionValueKey, ValueSpec as ValueSpecAny, -} from "../config/configTypes"; +} from "../config/configTypesRaw"; +import { InputSpecRaw } from "../config/configTypesRaw"; const { string, @@ -336,7 +333,7 @@ export function guardAll( * @param valueDictionary * @returns */ -export function typeFromProps( +export function typeFromProps( valueDictionary: A ): Parser> { if (!recordString.test(valueDictionary)) return unknown as any; diff --git a/output.ts b/output.ts deleted file mode 100644 index e0421f6..0000000 --- a/output.ts +++ /dev/null @@ -1,476 +0,0 @@ -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, -}); -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, -}); -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).", -}); -export const password = Value.string({ - 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.", -}); -export const bio = Value.textarea({ - 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 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: { - "non-segwit": "non-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, -}); -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, -}); -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, -}); -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, -}); -export const txindex = Value.boolean({ - 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, -}); -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, -}); -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, -}); -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, -}); -export const persistmempool = Value.boolean({ - 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, -}); -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, -}); -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, -}); -export const onlyconnect = Value.boolean({ - 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, -}); -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.", -}); -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, -}); -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 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, -}); -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, -}); -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, -}); -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, -}); -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, -}); -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, -}); -export const matchInputSpec = inputSpec.validator(); -export type InputSpec = typeof matchInputSpec._TYPE; diff --git a/package-lock.json b/package-lock.json index a882993..983cdb6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "start-sdk", - "version": "0.4.0-lib0.charlie17", + "version": "0.4.0-lib0.charlie19", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "start-sdk", - "version": "0.4.0-lib0.charlie17", + "version": "0.4.0-lib0.charlie19", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index d6125e2..5810700 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "start-sdk", - "version": "0.4.0-lib0.charlie17", + "version": "0.4.0-lib0.charlie19", "description": "For making the patterns that are wanted in making services for the startOS.", "main": "./lib/index.js", "types": "./lib/index.d.ts",