Closed obycode closed 2 months ago
Alternatively (and preferably if time permits): check for funded UTXOs during startup in a loop every N seconds. Exiting constantly can cause an exponential backoff delay between container restarts, making the operator wait longer than needed. A check loop instead of exiting would avoid this.
I do think some improvements here in stacks-core could be helpful, including:
But also, here's a simple bash script that polls and waits until more than 0 UTXOs are found:
#!/usr/bin/env bash
# check if UTXOs exist, otherwise exit
while :; do
length=$(bitcoin-cli -rpcconnect=127.0.0.1 -rpcport=18443 -rpcuser=blah -rpcpassword=blah listunspent 1 999999 "[\"MY_MINER_ADDR\"]" | jq length)
# echo "$length UTXOs"
if [ "$length" -gt 0 ]; then
echo "UTXOs found. Exiting."
exit 0
fi
# echo "Not found. Sleeping.."
sleep 10
done
@hstove thanks for the tip, that's similar to what I ended up using:
...
address_ready="$(bitcoin-cli \
-rpcconnect=${BITCOIN_HOSTNAME} \
-rpcport=${BITCOIN_PORT} \
-rpcuser=${BITCOIN_CREDS} \
-rpcpassword=${BITCOIN_CREDS} \
-rpcwait listaddressgroupings | \
jq -r --arg miner_address "${miner_address}" '.[][] | select(.[0]==$miner_address) | .[1] | select(. > 0)')"
...
We'll add a simple loop to recheck every X seconds, or exit if no UTXOs found after Y minutes.
Can we close this?
Yup.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Currently, we have a case where if your node config has
miner = true
but then the node is unable to find any UTXOs during startup, it will print a warning:but then keep running as a follower node. This problem would probably be easier to diagnose if instead of printing a warning and then continuing to run, it would just print that warning and exit.