Skip to content

Commit

Permalink
Merge pull request #140 from Start9Labs/feat/datacarrier
Browse files Browse the repository at this point in the history
datacarrier, baremultisig, and better boolean algebra
  • Loading branch information
MattDHill authored Mar 13, 2024
2 parents 8bb65f2 + daca27d commit 05a4f8f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 29 deletions.
19 changes: 19 additions & 0 deletions assets/compat/bitcoin.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 32 additions & 5 deletions scripts/services/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_]+$",
Expand All @@ -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,
Expand Down Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -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: {
Expand All @@ -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,
},
Expand Down
47 changes: 23 additions & 24 deletions scripts/services/setConfig.ts
Original file line number Diff line number Diff line change
@@ -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.',
};
}

Expand All @@ -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",
Expand All @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 05a4f8f

Please sign in to comment.