From daca27d387346870c0460b2beb38e279c7c5eda4 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 12 Mar 2024 20:02:43 -0600 Subject: [PATCH] datacarrier, baremultisig, and better boolean algebra --- assets/compat/bitcoin.conf.template | 19 ++++++++++++ scripts/services/getConfig.ts | 37 ++++++++++++++++++++--- scripts/services/setConfig.ts | 47 ++++++++++++++--------------- 3 files changed, 74 insertions(+), 29 deletions(-) diff --git a/assets/compat/bitcoin.conf.template b/assets/compat/bitcoin.conf.template index 3bbf6be..72b6636 100644 --- a/assets/compat/bitcoin.conf.template +++ b/assets/compat/bitcoin.conf.template @@ -125,6 +125,25 @@ txindex=1 coinstatsindex=1 }} +## DATACARRIER +{{#IF advanced.mempool.datacarrier +datacarrier=1 +}} +{{#IF !advanced.mempool.datacarrier +datacarrier=0 +}} + +## DATACARRIER SIZE +datacarriersize={{advanced.mempool.datacarriersize}} + +## PERMIT BARE MULTISIG +{{#IF advanced.mempool.permitbaremultisig +permitbaremultisig=1 +}} +{{#IF !advanced.mempool.permitbaremultisig +permitbaremultisig=0 +}} + ## BIP37 {{#IF advanced.bloomfilters.peerbloomfilters peerbloomfilters=1 diff --git a/scripts/services/getConfig.ts b/scripts/services/getConfig.ts index 62cb919..2142b73 100644 --- a/scripts/services/getConfig.ts +++ b/scripts/services/getConfig.ts @@ -38,7 +38,8 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { nullable: false, name: "Username", description: "The username for connecting to Bitcoin over RPC.", - warning: "You will need to restart all services that depend on Bitcoin.", + warning: + "You will need to restart all services that depend on Bitcoin.", default: "bitcoin", masked: true, pattern: "^[a-zA-Z0-9_]+$", @@ -50,7 +51,8 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { nullable: false, name: "RPC Password", description: "The password for connecting to Bitcoin over RPC.", - warning: "You will need to restart all services that depend on Bitcoin.", + warning: + "You will need to restart all services that depend on Bitcoin.", default: { charset: "a-z,2-7", len: 20, @@ -212,6 +214,28 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { type: "boolean", default: false, }, + permitbaremultisig: { + type: "boolean", + name: "Permit Bare Multisig", + description: "Relay non-P2SH multisig transactions", + default: true, + }, + datacarrier: { + type: "boolean", + name: "Relay OP_RETURN Transactions", + description: "Relay transactions with OP_RETURN outputs", + default: true, + }, + datacarriersize: { + type: "number", + nullable: false, + name: "Max OP_RETURN Size", + description: "Maximum size of data in OP_RETURN outputs to relay", + range: "[1,10000]", + integral: true, + units: "bytes", + default: 83, + }, }, }, peers: { @@ -222,7 +246,8 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { listen: { type: "boolean", name: "Make Public", - description: "Allow other nodes to find your server on the network.", + description: + "Allow other nodes to find your server on the network.", default: true, }, onlyconnect: { @@ -240,7 +265,8 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { v2transport: { type: "boolean", name: "Use V2 P2P Transport Protocol", - description: "Enable or disable the use of BIP324 V2 P2P transport protocol.", + description: + "Enable or disable the use of BIP324 V2 P2P transport protocol.", default: false, }, addnode: { @@ -266,7 +292,8 @@ export const getConfig: T.ExpectedExports.getConfig = async (effects) => { type: "number", nullable: true, name: "Port", - description: "Port that peer is listening on for inbound p2p connections", + description: + "Port that peer is listening on for inbound p2p connections", range: "[0,65535]", integral: true, }, diff --git a/scripts/services/setConfig.ts b/scripts/services/setConfig.ts index ced7808..3645d79 100644 --- a/scripts/services/setConfig.ts +++ b/scripts/services/setConfig.ts @@ -1,43 +1,39 @@ -import { - matches, - compat, - types, - YAML -} from "../dependencies.ts"; -const { number, shape, boolean } = matches; +import { matches, types, YAML } from "../dependencies.ts"; +const { number } = matches; export const setConfig: types.ExpectedExports.setConfig = async ( effects: types.Effects, // deno-lint-ignore no-explicit-any - newConfig: any, + newConfig: any ) => { - if (!(newConfig?.rpc?.enable || !(newConfig.advanced?.pruning?.mode === "manual"))) { + if (newConfig.advanced.pruning.mode === "manual" && !newConfig.rpc.enable) { return { - error: "RPC must be enabled for manual.", + error: "RPC must be enabled for manual pruning.", }; } - if ( - !(!newConfig.txindex || (newConfig.advanced?.pruning?.mode === "disabled")) - ) { + + if (newConfig.txindex && newConfig.advanced.pruning.mode !== "disabled") { return { error: "Txindex not allowed on pruned nodes.", }; } + if ( - !(!newConfig.coinstatsindex || (newConfig.advanced?.pruning?.mode === "disabled")) + newConfig.coinstatsindex && + newConfig.advanced.pruning.mode !== "disabled" ) { return { error: "Coinstats index not allowed on pruned nodes.", }; } - // true, false only fail case + if ( - !(!newConfig.advanced.blockfilters.peerblockfilters || - (newConfig.advanced.blockfilters.blockfilterindex)) + newConfig.advanced.blockfilters.peerblockfilters && + !newConfig.advanced.blockfilters.blockfilterindex ) { return { error: - "'Compute Compact Block Filters' must be enabled if 'Serve Compact Block Filters to Peers' is enabled.", + '"Compute Compact Block Filters" must be enabled if "Serve Compact Block Filters to Peers" is enabled.', }; } @@ -48,10 +44,12 @@ export const setConfig: types.ExpectedExports.setConfig = async ( // config-set.sh - const oldConfig = await effects.readFile({ - path: "start9/config.yaml", - volumeId: "main", - }).catch(() => null); + const oldConfig = await effects + .readFile({ + path: "start9/config.yaml", + volumeId: "main", + }) + .catch(() => null); if (oldConfig) { await effects.writeFile({ path: "start9/config-old.yaml", @@ -63,7 +61,7 @@ export const setConfig: types.ExpectedExports.setConfig = async ( let oldPruningSize = 0; if (oldPruningTl !== "disabled") { oldPruningSize = number.unsafeCast( - oldConfigParsed?.advanced?.pruning?.size, + oldConfigParsed?.advanced?.pruning?.size ); } const newPruningTl = newConfig.advanced.pruning.mode; @@ -74,7 +72,8 @@ export const setConfig: types.ExpectedExports.setConfig = async ( if (oldPruningTl == "disabled" || !oldPruningTl) { effects.debug("No reindex required"); } else if ( - oldPruningTl === newPruningTl && oldPruningSize >= newPruningSize + oldPruningTl === newPruningTl && + oldPruningSize >= newPruningSize ) { effects.debug("No reindex required"); } else {