Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable json only on mainnet #4138

Closed
wants to merge 16 commits into from
2 changes: 1 addition & 1 deletion deploy/ord.service
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ExecStart=/usr/local/bin/ord \
--csp-origin https://${CSP_ORIGIN} \
--http \
--https \
--disable-json-api
${JSON_API}
Group=ord
LimitNOFILE=65536
MemoryDenyWriteExecute=true
Expand Down
9 changes: 7 additions & 2 deletions deploy/setup
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,31 @@ case $CHAIN in
main)
COOKIE_FILE_DIR=/var/lib/bitcoind
CSP_ORIGIN=ordinals.com
JSON_API='--disable-json-api'
ufw allow 8333
;;
regtest)
COOKIE_FILE_DIR=/var/lib/bitcoind/regtest
CSP_ORIGIN=regtest.ordinals.com
JSON_API='--enable-json-api'
ufw allow 18444
;;
signet)
COOKIE_FILE_DIR=/var/lib/bitcoind/signet
CSP_ORIGIN=signet.ordinals.com
JSON_API='--enable-json-api'
ufw allow 38333
;;
test)
COOKIE_FILE_DIR=/var/lib/bitcoind/testnet3
CSP_ORIGIN=testnet.ordinals.com
JSON_API='--enable-json-api'
ufw allow 18333
;;
testnet4)
COOKIE_FILE_DIR=/var/lib/bitcoind/testnet4
CSP_ORIGIN=testnet4.ordinals.com
JSON_API='--enable-json-api'
ufw allow 48333
;;
*)
Expand All @@ -73,7 +78,7 @@ mkdir -p \
/etc/systemd/system/bitcoind.service.d \
/etc/systemd/system/ord.service.d

printf "[Service]\nEnvironment=CHAIN=%s\nEnvironment=CSP_ORIGIN=%s\n" $CHAIN $CSP_ORIGIN \
printf "[Service]\nEnvironment=CHAIN=%s\nEnvironment=CSP_ORIGIN=%s\nEnvironment=JSON_API=%s\n" $CHAIN $CSP_ORIGIN $JSON_API \
| tee /etc/systemd/system/bitcoind.service.d/override.conf \
> /etc/systemd/system/ord.service.d/override.conf

Expand All @@ -89,7 +94,7 @@ fi

bitcoind --version

chown bitcoin:bitcoin /var/lib/bitcoind/settings.json
rm -f /var/lib/bitcoind/settings.json

if [[ ! -e ~/.cargo/env ]]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
Expand Down
16 changes: 14 additions & 2 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,19 @@ pub struct Server {
help = "Decompress encoded content. Currently only supports brotli. Be careful using this on production instances. A decompressed inscription may be arbitrarily large, making decompression a DoS vector."
)]
pub(crate) decompress: bool,
#[arg(long, help = "Disable JSON API.")]
#[arg(
long,
default_value_t = true,
conflicts_with = "disable_json_api",
help = "Enable JSON API (enabled by default)"
)]
pub(crate) enable_json_api: bool,
#[arg(
long,
default_value_t = false,
conflicts_with = "enable_json_api",
help = "Disable JSON API"
)]
pub(crate) disable_json_api: bool,
#[arg(
long,
Expand Down Expand Up @@ -173,7 +185,7 @@ impl Server {
decompress: self.decompress,
domain: acme_domains.first().cloned(),
index_sats: index.has_sat_index(),
json_api_enabled: !self.disable_json_api,
json_api_enabled: self.enable_json_api && !self.disable_json_api,
proxy: self.proxy.clone(),
});

Expand Down
Loading