Skip to content

Commit f21e66e

Browse files
committed
feat(docker): enhance configuration for Bitcoin node selection and pre-synced image support
1 parent e815757 commit f21e66e

File tree

1 file changed

+118
-45
lines changed

1 file changed

+118
-45
lines changed

docker-setup

Lines changed: 118 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ BITCOIN_RPC_PORT="$BITCOIN_RPC_PORT"
5757
BITCOIN_ZMQ_PORT="$BITCOIN_ZMQ_PORT"
5858
BITCOIN_RPC_USER="$BITCOIN_RPC_USER"
5959
BITCOIN_RPC_PASSWORD="$BITCOIN_RPC_PASSWORD"
60+
SAVED_BITCOIN_TAG="$SAVED_BITCOIN_TAG"
6061
MAKERD_PORT="$MAKERD_PORT"
6162
MAKERD_RPC_PORT="$MAKERD_RPC_PORT"
6263
USE_TAPROOT="$USE_TAPROOT"
@@ -120,9 +121,14 @@ setup_env() {
120121
# export variables for docker-compose
121122
export IMAGE_NAME="${IMAGE_NAME}"
122123
export BITCOIN_IMAGE_NAME="${BITCOIN_IMAGE_NAME}"
123-
export BITCOIN_TAG="latest"
124-
if [ -f "$VERSION_FILE" ]; then
125-
export BITCOIN_TAG=$(grep "^TAG=" "$VERSION_FILE" | cut -d'=' -f2)
124+
125+
if [ -n "$SAVED_BITCOIN_TAG" ]; then
126+
export BITCOIN_TAG="$SAVED_BITCOIN_TAG"
127+
else
128+
export BITCOIN_TAG="latest"
129+
if [ -f "$VERSION_FILE" ]; then
130+
export BITCOIN_TAG=$(grep "^TAG=" "$VERSION_FILE" | cut -d'=' -f2)
131+
fi
126132
fi
127133

128134
export BITCOIN_RPC_PORT
@@ -197,63 +203,124 @@ configure_setup() {
197203

198204
echo ""
199205
echo "Select Bitcoin Node Source:"
200-
echo "1) Run Local Node (Docker)"
206+
echo ""
207+
echo " 1) Connect to your existing bitcoind node (Recommended)"
208+
echo " - Most sovereign option, requires your own node"
209+
echo " - Must be configured per docs/bitcoind.md"
210+
echo ""
211+
echo " 2) Use pre-configured bitcoind Docker image"
212+
echo " - Quick setup, runs locally in Docker"
213+
echo ""
201214
if [ "$BITCOIN_NETWORK" == "signet" ]; then
202-
echo "2) Use Coinswap Public Node"
215+
echo " 3) Connect to Public Mutinynet Node (Dev testing only)"
216+
echo " - WARNING: Leaks your transaction graph to a third party"
217+
echo " - Only use for quick developer testing, never for real funds"
218+
echo ""
203219
fi
204-
echo "3) Connect to External Node"
205220

206-
read -p "Source [1]: " source_choice
221+
read -p "Select option [1]: " source_choice
222+
source_choice=${source_choice:-1}
207223

208224
USE_EXTERNAL_BITCOIND="false"
225+
SAVED_BITCOIN_TAG=""
226+
configure_docker_node="false"
209227

210-
if [ "$BITCOIN_NETWORK" == "signet" ] && [ "${source_choice:-1}" == "2" ]; then
211-
USE_EXTERNAL_BITCOIND="true"
212-
EXTERNAL_BITCOIND_HOST="172.81.178.3:48332"
213-
BITCOIN_ZMQ_PORT="58332"
214-
BITCOIN_RPC_USER="user"
215-
BITCOIN_RPC_PASSWORD="password"
216-
print_info "Using Coinswap Public Node at $EXTERNAL_BITCOIND_HOST"
217-
elif [ "${source_choice:-1}" == "3" ] || ([ "$BITCOIN_NETWORK" != "signet" ] && [ "${source_choice:-1}" == "2" ]); then
218-
USE_EXTERNAL_BITCOIND="true"
219-
read -p "Bitcoin RPC host [localhost:$BITCOIN_RPC_PORT]: " btc_host
220-
EXTERNAL_BITCOIND_HOST="${btc_host:-localhost:$BITCOIN_RPC_PORT}"
221-
222-
read -p "Bitcoin RPC user [${DEFAULT_RPC_USER}]: " rpc_user
223-
BITCOIN_RPC_USER="${rpc_user:-$DEFAULT_RPC_USER}"
224-
225-
read -p "Bitcoin RPC password [${DEFAULT_RPC_PASSWORD}]: " rpc_pass
226-
BITCOIN_RPC_PASSWORD="${rpc_pass:-$DEFAULT_RPC_PASSWORD}"
227-
else
228-
if check_bitcoind_running "$BITCOIN_RPC_PORT"; then
229-
print_warning "Detected Bitcoin Core running on port $BITCOIN_RPC_PORT"
230-
read -p "Port is in use. Use this existing instance instead? [Y/n]: " use_existing
231-
if [[ "${use_existing:-Y}" =~ ^[Yy]$ ]]; then
228+
case "$source_choice" in
229+
1)
230+
echo ""
231+
print_warning "Your node must be configured correctly as per: docs/bitcoind.md"
232+
print_warning "Required: server=1, txindex=1, blockfilterindex=1, and correct RPC/ZMQ settings"
233+
echo ""
234+
read -p "Are you sure your node is configured properly? [y/N]: " confirm_existing
235+
if [[ ! "${confirm_existing}" =~ ^[Yy]$ ]]; then
236+
print_info "Falling back to Docker image..."
237+
configure_docker_node="true"
238+
else
232239
USE_EXTERNAL_BITCOIND="true"
233-
EXTERNAL_BITCOIND_HOST="localhost:$BITCOIN_RPC_PORT"
240+
241+
read -p "Bitcoin RPC host [localhost:$BITCOIN_RPC_PORT]: " btc_host
242+
EXTERNAL_BITCOIND_HOST="${btc_host:-localhost:$BITCOIN_RPC_PORT}"
234243

235244
read -p "Bitcoin RPC user [${DEFAULT_RPC_USER}]: " rpc_user
236245
BITCOIN_RPC_USER="${rpc_user:-$DEFAULT_RPC_USER}"
237246

238247
read -p "Bitcoin RPC password [${DEFAULT_RPC_PASSWORD}]: " rpc_pass
239248
BITCOIN_RPC_PASSWORD="${rpc_pass:-$DEFAULT_RPC_PASSWORD}"
249+
250+
read -p "Bitcoin ZMQ port [$BITCOIN_ZMQ_PORT]: " btc_zmq_port
251+
BITCOIN_ZMQ_PORT="${btc_zmq_port:-$BITCOIN_ZMQ_PORT}"
252+
fi
253+
;;
254+
3)
255+
if [ "$BITCOIN_NETWORK" == "signet" ]; then
256+
echo ""
257+
print_error "============================================"
258+
print_error " PRIVACY WARNING"
259+
print_error "============================================"
260+
print_warning "Using a public node exposes your transaction graph!"
261+
print_warning "The node operator can see all your wallet activity."
262+
print_warning "DO NOT use this for real funds or private swaps."
263+
print_warning "This option is ONLY for quick developer testing."
264+
echo ""
265+
read -p "I understand the privacy risks and want to continue [y/N]: " confirm_public
266+
if [[ ! "${confirm_public}" =~ ^[Yy]$ ]]; then
267+
print_info "Falling back to Docker image..."
268+
configure_docker_node="true"
269+
else
270+
USE_EXTERNAL_BITCOIND="true"
271+
EXTERNAL_BITCOIND_HOST="172.81.178.3:48332"
272+
BITCOIN_ZMQ_PORT="58332"
273+
BITCOIN_RPC_USER="user"
274+
BITCOIN_RPC_PASSWORD="password"
275+
print_info "Using Coinswap Public Node at $EXTERNAL_BITCOIND_HOST"
276+
fi
240277
else
241-
print_warning "Continuing with local node configuration. Startup may fail if port is bound."
278+
print_error "Public node only available for Mutinynet."
279+
configure_docker_node="true"
242280
fi
281+
;;
282+
*)
283+
configure_docker_node="true"
284+
;;
285+
esac
286+
287+
if [ "$configure_docker_node" == "true" ]; then
288+
USE_EXTERNAL_BITCOIND="false"
289+
echo ""
290+
echo "Select Docker Image Type:"
291+
echo ""
292+
echo " A) Sync from scratch"
293+
echo " - Downloads ~8GB of blockchain data"
294+
echo " - IBD takes approximately 1 hour"
295+
echo ""
296+
if [ "$BITCOIN_NETWORK" == "signet" ]; then
297+
echo " B) Start from pre-synced image"
298+
echo " - Downloads ~8GB pre-synced image"
299+
echo " - No IBD needed, ready immediately"
300+
echo ""
243301
fi
244302

245-
if [[ "$USE_EXTERNAL_BITCOIND" == "false" ]]; then
246-
read -p "Bitcoin RPC port [$BITCOIN_RPC_PORT]: " btc_port
247-
BITCOIN_RPC_PORT="${btc_port:-$BITCOIN_RPC_PORT}"
248-
read -p "Bitcoin ZMQ port [$BITCOIN_ZMQ_PORT]: " btc_zmq_port
249-
BITCOIN_ZMQ_PORT="${btc_zmq_port:-$BITCOIN_ZMQ_PORT}"
250-
251-
read -p "Bitcoin RPC user [${DEFAULT_RPC_USER}]: " rpc_user
252-
BITCOIN_RPC_USER="${rpc_user:-$DEFAULT_RPC_USER}"
253-
254-
read -p "Bitcoin RPC password [${DEFAULT_RPC_PASSWORD}]: " rpc_pass
255-
BITCOIN_RPC_PASSWORD="${rpc_pass:-$DEFAULT_RPC_PASSWORD}"
303+
read -p "Select Option [A]: " docker_btc_option
304+
docker_btc_option=${docker_btc_option:-A}
305+
306+
if [ "$BITCOIN_NETWORK" == "signet" ] && [[ "${docker_btc_option}" =~ ^[Bb]$ ]]; then
307+
SAVED_BITCOIN_TAG="presynced-latest"
308+
print_info "Selected pre-synced image (no IBD required)."
309+
else
310+
SAVED_BITCOIN_TAG=""
311+
print_info "Selected standard image (will sync from scratch)."
256312
fi
313+
314+
read -p "Bitcoin RPC port [$BITCOIN_RPC_PORT]: " btc_port
315+
BITCOIN_RPC_PORT="${btc_port:-$BITCOIN_RPC_PORT}"
316+
read -p "Bitcoin ZMQ port [$BITCOIN_ZMQ_PORT]: " btc_zmq_port
317+
BITCOIN_ZMQ_PORT="${btc_zmq_port:-$BITCOIN_ZMQ_PORT}"
318+
319+
read -p "Bitcoin RPC user [${DEFAULT_RPC_USER}]: " rpc_user
320+
BITCOIN_RPC_USER="${rpc_user:-$DEFAULT_RPC_USER}"
321+
322+
read -p "Bitcoin RPC password [${DEFAULT_RPC_PASSWORD}]: " rpc_pass
323+
BITCOIN_RPC_PASSWORD="${rpc_pass:-$DEFAULT_RPC_PASSWORD}"
257324
fi
258325

259326
echo ""
@@ -277,11 +344,11 @@ configure_setup() {
277344
echo ""
278345
read -p "Are you sure your Tor is configured properly? [y/N]: " confirm_tor
279346
if [[ "${confirm_tor}" =~ ^[Yy]$ ]]; then
280-
USE_EXTERNAL_TOR="true"
347+
USE_EXTERNAL_TOR="true"
281348
TOR_CONFIGURED="true"
282349

283-
read -p "Tor SOCKS host [localhost:9050]: " tor_host
284-
EXTERNAL_TOR_HOST="${tor_host:-localhost:9050}"
350+
read -p "Tor SOCKS host [localhost:9050]: " tor_host
351+
EXTERNAL_TOR_HOST="${tor_host:-localhost:9050}"
285352

286353
read -p "Tor Auth Password [${DEFAULT_TOR_AUTH}]: " tor_auth
287354
TOR_AUTH_PASSWORD="${tor_auth:-$DEFAULT_TOR_AUTH}"
@@ -328,6 +395,12 @@ configure_setup() {
328395
echo "Use External Bitcoin: $USE_EXTERNAL_BITCOIND"
329396
if [[ "$USE_EXTERNAL_BITCOIND" == "true" ]]; then
330397
echo "External Bitcoin Host: $EXTERNAL_BITCOIND_HOST"
398+
else
399+
if [ -n "$SAVED_BITCOIN_TAG" ]; then
400+
echo "Bitcoin Image Tag: $SAVED_BITCOIN_TAG (pre-synced)"
401+
else
402+
echo "Bitcoin Image Tag: latest (sync from scratch)"
403+
fi
331404
fi
332405
echo "Use External Tor: $USE_EXTERNAL_TOR"
333406
if [[ "$USE_EXTERNAL_TOR" == "true" ]]; then

0 commit comments

Comments
 (0)