forked from MutinyWallet/mutiny-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mine.sh
executable file
·23 lines (22 loc) · 952 Bytes
/
mine.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
NBITS=${NBITS:-"1e0377ae"} #minimum difficulty in signet
while true; do
if [[ -f "${BITCOIN_DIR}/MINE_ADDRESS.txt" ]]; then
ADDR=$(cat ~/.bitcoin/MINE_ADDRESS.txt)
else
ADDR=${MINETO:-$(bitcoin-cli getnewaddress)}
fi
if [[ -f "${BITCOIN_DIR}/BLOCKPRODUCTIONDELAY.txt" ]]; then
BLOCKPRODUCTIONDELAY_OVERRIDE=$(cat ~/.bitcoin/BLOCKPRODUCTIONDELAY.txt)
echo "Delay OVERRIDE before next block" $BLOCKPRODUCTIONDELAY_OVERRIDE "seconds."
sleep $BLOCKPRODUCTIONDELAY_OVERRIDE
else
BLOCKPRODUCTIONDELAY=${BLOCKPRODUCTIONDELAY:="0"}
if [[ BLOCKPRODUCTIONDELAY -gt 0 ]]; then
echo "Delay before next block" $BLOCKPRODUCTIONDELAY "seconds."
sleep $BLOCKPRODUCTIONDELAY
fi
fi
echo "Mine To:" $ADDR
miner --cli="bitcoin-cli" generate --grind-cmd="bitcoin-util grind" --address=$ADDR --nbits=$NBITS --set-block-time=$(date +%s)
done