Skip to content

Commit

Permalink
Merge pull request #3 from remcoros/feat/more_settings
Browse files Browse the repository at this point in the history
add backend and coordinator settings
  • Loading branch information
remcoros authored May 19, 2024
2 parents f724726 + 8b73fb4 commit 839c6c8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 28 deletions.
36 changes: 23 additions & 13 deletions docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export PUID=1000
export PGID=1000
export TZ=Etc/UTC
export TITLE="$(yq e '.title' /root/data/start9/config.yaml)"
export CUSTOM_USER="$(yq e '.username' /root/data/start9/config.yaml)"
export PASSWORD="$(yq e '.password' /root/data/start9/config.yaml)"
CUSTOM_USER="$(yq e '.username' /root/data/start9/config.yaml)"
PASSWORD="$(yq e '.password' /root/data/start9/config.yaml)"

cat <<EOF >/root/data/start9/stats.yaml
version: 2
Expand All @@ -30,9 +30,6 @@ data:
masked: true
EOF

unset CUSTOM_USER
unset PASSWORD

# Copy default files
cp /defaults/.backupignore /config/.backupignore

Expand Down Expand Up @@ -78,19 +75,32 @@ if [ $(yq e '.wasabi.managesettings' /root/data/start9/config.yaml) = "true" ];
yq e -i '.UseTor = false' -o=json /config/.walletwasabi/client/Config.json
fi

# Wasabi Backend URI
MainNetBackendUri="$(yq e '.wasabi.mainNetBackendUri' /root/data/start9/config.yaml)"
yq e -i ".MainNetBackendUri = \"$MainNetBackendUri\"" -o=json /config/.walletwasabi/client/Config.json

# Custom Coordinator
MainNetCoordinatorUri="$(yq e '.wasabi.mainNetCoordinatorUri' /root/data/start9/config.yaml)"
if [ ! -z "$MainNetCoordinatorUri" ] && [ "$MainNetCoordinatorUri" != "null" ]; then
yq e -i ".MainNetCoordinatorUri = \"$MainNetCoordinatorUri\"" -o=json /config/.walletwasabi/client/Config.json
else
yq e -i "del(.MainNetCoordinatorUri)" -o=json /config/.walletwasabi/client/Config.json
fi

# Json RPC server
if [ $(yq e '.wasabi.rpc.enable' /root/data/start9/config.yaml) = "true" ]; then
echo "Configuring Wasabi Json RPC server"

export RPC_TOR_ADDRESS="$(yq e '.wasabi.rpc.rpc-tor-address' /root/data/start9/config.yaml)"
export RPC_ADDRESS=${RPC_TOR_ADDRESS%".onion"}.local
export RPC_USER=$(yq e '.wasabi.rpc.username' /root/data/start9/config.yaml)
export RPC_PASS=$(yq e '.wasabi.rpc.password' /root/data/start9/config.yaml)
RPC_TOR_ADDRESS="$(yq e '.wasabi.rpc.rpc-tor-address' /root/data/start9/config.yaml)"
RPC_ADDRESS=${RPC_TOR_ADDRESS%".onion"}.local
RPC_USER=$(yq e '.wasabi.rpc.username' /root/data/start9/config.yaml)
RPC_PASS=$(yq e '.wasabi.rpc.password' /root/data/start9/config.yaml)

yq e -i '.JsonRpcServerEnabled = true' -o=json /config/.walletwasabi/client/Config.json
yq e -i '.JsonRpcUser = strenv(RPC_USER)' -o=json /config/.walletwasabi/client/Config.json
yq e -i '.JsonRpcPassword = strenv(RPC_PASS)' -o=json /config/.walletwasabi/client/Config.json
yq e -i '.JsonRpcServerPrefixes = ["http://+:37128/"]' -o=json /config/.walletwasabi/client/Config.json
yq e -i "
.JsonRpcServerEnabled = true |
.JsonRpcUser = \"$RPC_USER\" |
.JsonRpcPassword = \"$RPC_PASS\" |
.JsonRpcServerPrefixes = [\"http://+:37128/\"]" -o=json /config/.walletwasabi/client/Config.json

cat << EOF >>/root/data/start9/stats.yaml
"Tor RPC Url":
Expand Down
1 change: 1 addition & 0 deletions manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: "Wasabi"
version: 2.0.7.2
release-notes: |
* Update to Wasabi 2.0.7.2 - See [full changelog](https://github.com/zkSNACKs/WalletWasabi/releases/tag/v2.0.7.2)
* Add options to allow setting a custom backend and coordinator url
license: MIT
wrapper-repo: "https://github.com/remcoros/wasabi-webtop-startos"
upstream-repo: "https://github.com/zkSNACKs/WalletWasabi"
Expand Down
23 changes: 21 additions & 2 deletions scripts/procedures/getConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { compat, types as T } from "../deps.ts";
import { compat } from "../deps.ts";

export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({
export const [getConfig, setConfigMatcher] = compat.getConfigAndMatcher({
title: {
type: "string",
nullable: false,
Expand Down Expand Up @@ -76,6 +76,23 @@ export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({
description: "Configure Wasabi to use the Tor network.",
default: true,
},
mainNetBackendUri: {
type: "string",
name: "Wasabi Backend url",
description: "URL of the Wasabi Backend. The default is: https://api.wasabiwallet.io/",
nullable: false,
pattern: "^https?://.+$",
"pattern-description": "A valid URL starting with http(s)://",
default: "https://api.wasabiwallet.io/"
},
mainNetCoordinatorUri: {
type: "string",
name: "Custom coordinator url",
description: "URL of the custom CoinJoin Coordinator to use",
nullable: true,
pattern: "^https?://.+$",
"pattern-description": "A valid URL starting with http(s)://"
},
rpc: {
type: "object",
name: "RPC Settings",
Expand Down Expand Up @@ -131,3 +148,5 @@ export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({
},
},
});

export type Config = typeof setConfigMatcher._TYPE;
18 changes: 5 additions & 13 deletions scripts/procedures/setConfig.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import { compat, types as T } from "../deps.ts";
import { Config, setConfigMatcher } from "./getConfig.ts";

// Define a custom type for T.Config to include the 'server' property with a 'type' property
interface WasabiConfig extends T.Config {
wasabi?: {
server?: {
type?: string;
};
};
}

// deno-lint-ignore require-await
export const setConfig: T.ExpectedExports.setConfig = async (
effects: T.Effects,
newConfig: WasabiConfig,
input: T.Config,
) => {
const config: Config = setConfigMatcher.unsafeCast(input);
const depsBitcoind: { [key: string]: string[] } =
newConfig?.wasabi?.server?.type === "bitcoind" ? { "bitcoind": [] } : {};
config.wasabi.server.type === "bitcoind" ? { "bitcoind": [] } : {};

return compat.setConfig(effects, newConfig, {
return await compat.setConfig(effects, config, {
...depsBitcoind,
});
};

0 comments on commit 839c6c8

Please sign in to comment.