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

fix: limit the UTXOs of the miners to avoid bug #45

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.9"

x-common-vars:
- &STACKS_BLOCKCHAIN_COMMIT 5321154f30c2387ed52e0f82ffd9476fe963cc84 # develop, Aug 15, 11:30
- &STACKS_BLOCKCHAIN_COMMIT b5250c60877fa3380b450a7b7e7e9d3e87da6112 # develop, Sep 23, 08:30
- &STACKS_API_COMMIT f6e50f6d28f292d79dbebd70b2b00831c95997f6 # 7.13.2
- &BTC_ADDR miEJtNKa3ASpA19v5ZhvbKTEieYjLpzCYT
- &MINER_SEED 9e446f6b0c6a96cf2190e54bcd5a8569c3e386f091605499464389b8d4e0bfc201 # stx: STEW4ZNT093ZHK4NEQKX8QJGM2Y7WWJ2FQQS5C19, btc: miEJtNKa3ASpA19v5ZhvbKTEieYjLpzCYT, pub_key: 035379aa40c02890d253cfa577964116eb5295570ae9f7287cbae5f2585f5b2c7c, wif: cStMQXkK5yTFGP3KbNXYQ3sJf2qwQiKrZwR9QJnksp32eKzef1za
Expand Down Expand Up @@ -83,7 +83,14 @@ services:
bitcoin-cli -rpcconnect=bitcoind importaddress $${BTC_ADDR} "" false
bitcoin-cli -rpcconnect=bitcoind generatetoaddress $${INIT_BLOCKS} $${BTC_ADDR}
DEFAULT_TIMEOUT=$$(($$(date +%s) + 30))
RANDOM_ADDR=$$(bitcoin-cli -rpcconnect=bitcoind getnewaddress)
zone117x marked this conversation as resolved.
Show resolved Hide resolved
while true; do
UTXO_COUNT=$$(bitcoin-cli -rpcconnect=bitcoind listunspent 0 9999999 '[ "'"$${BTC_ADDR}"'" ]' | jq '. | length')
if [ "$${UTXO_COUNT}" -gt 100 ]; then
MINING_ADDR="$${RANDOM_ADDR}"
else
MINING_ADDR="$${BTC_ADDR}"
fi
TX=$$(bitcoin-cli -rpcconnect=bitcoind listtransactions '*' 1 0 true)
CONFS=$$(echo "$${TX}" | jq '.[].confirmations')
if [ "$${CONFS}" = "0" ] || [ $$(date +%s) -gt $$DEFAULT_TIMEOUT ]; then
Expand All @@ -92,7 +99,7 @@ services:
else
echo "Detected Stacks mining mempool tx, mining btc block..."
fi
bitcoin-cli -rpcconnect=bitcoind generatetoaddress 1 "$${BTC_ADDR}"
bitcoin-cli -rpcconnect=bitcoind generatetoaddress 1 "$${MINING_ADDR}"
DEFAULT_TIMEOUT=$$(($$(date +%s) + 30))
else
echo "No Stacks mining tx detected"
Expand Down
Loading