diff --git a/GNUmakefile b/GNUmakefile index 2848c7f2d..aee081119 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -401,7 +401,7 @@ endif ####################### .PHONY: blocknotify blocknotify: - bash -c 'install -v $(PWD)/scripts/blocknotify /usr/local/bin/blocknotify' + bash -c 'install -v $(PWD)/bitcoin-signet/blocknotify /usr/local/bin/blocknotify' ####################### .PHONY: initialize initialize:## install libs and dependencies diff --git a/bitcoin-signet/Dockerfile b/bitcoin-signet/Dockerfile index a35ea1fd5..59783ae70 100644 --- a/bitcoin-signet/Dockerfile +++ b/bitcoin-signet/Dockerfile @@ -34,6 +34,8 @@ EXPOSE 8332 8333 28332 28333 28334 38332 38333 38334 COPY --from=builder "/tmp/bin" /usr/local/bin +COPY blocknotify /usr/local/bin/blocknotify +COPY walletnotify /usr/local/bin/walletnotify COPY bitcoin.conf /usr/local/etc/bitcoin.conf COPY docker-entrypoint.sh /usr/local/bin/entrypoint.sh diff --git a/bitcoin-signet/bitcoin.conf b/bitcoin-signet/bitcoin.conf index b5ea9cbbc..97627881f 100644 --- a/bitcoin-signet/bitcoin.conf +++ b/bitcoin-signet/bitcoin.conf @@ -4,6 +4,8 @@ txindex=1 server=1 dnsseed=0 blockfilterindex=1 +blocknotify=blocknotify +walletnotify=walletnotify [signet] rpcbind=0.0.0.0:38332 rpcallowip=0.0.0.0/0 diff --git a/bitcoin-signet/blocknotify b/bitcoin-signet/blocknotify new file mode 100755 index 000000000..e1a213d52 --- /dev/null +++ b/bitcoin-signet/blocknotify @@ -0,0 +1,5 @@ +#!/bin/bash ++#This file is executed when a new block is recieved ++#It can be used to automate things in the container +ADDRESS=tb1q550ph67a0qztgg7zx5lxnuj6qj20wxav2mx47k +play-getcoins -a "$(play-getcoins -a $ADDRESS -r true)" > /dev/null 2>&1 diff --git a/bitcoin-signet/walletnotify b/bitcoin-signet/walletnotify new file mode 100755 index 000000000..4dc00b55c --- /dev/null +++ b/bitcoin-signet/walletnotify @@ -0,0 +1,7 @@ +#!/bin/bash +#This file is executed when sending/recieving/confirming bitcoin +#It can be used to automate things in the container +ADDRESS=tb1q550ph67a0qztgg7zx5lxnuj6qj20wxav2mx47k +play-getcoins -a "$(play-getcoins -a $ADDRESS -r true)" > /dev/null 2>&1 +echo %s +echo %w diff --git a/scripts/blocknotify b/scripts/blocknotify deleted file mode 100755 index 1cd2bd5e1..000000000 --- a/scripts/blocknotify +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash -#BEGIN OF OBJECT - -play-getcoins -a $( echo play-getcoins -a tb1qv07v5f0mmvnzczfs50c8wv8s76rrrdcr875y7z -r true) > /dev/null 2>&1 - -echo "{" -echo "\"blocknotify\":[" -echo "{" -echo "\"time\":\"$(date +%s)\"" -echo "}," -SELF_ADDRESS=$(bitcoin-cli -rpcwallet=playground-wallet getnewaddress) -export SELF_ADDRESS -echo { \"SELF_ADDRESS\": \"$SELF_ADDRESS\" }, -PLAY_BITCOIN_ADDRESS=$(play-bitcoin getnewaddress) -export PLAY_BITCOIN_ADDRESS -echo { \"PLAY_BITCOIN_ADDRESS\": \"$PLAY_BITCOIN_ADDRESS\" }, -#END OF OBJECT -#BEGIN OF OBJECT -#echo "{" -#echo "\"time\":\"$(date +%s)\"" -#echo "}," -#END OF OBJECT - -#BEGIN OF OBJECT inner function - -host-cli-automate(){ -################################################################################ -play-getcoins -a $( echo play-getcoins -a tb1qv07v5f0mmvnzczfs50c8wv8s76rrrdcr875y7z -r true) > /dev/null 2>&1 -play-getcoins -a $( echo play-getcoins -a tb1qch72khdxtc8wd2rdzedut7269j5a3sjszapnck -r true) > /dev/null 2>&1 - - -#settxfee alwats less than 0.1000 -echo "{ \"\$count\$k\$j\": \"$count$k$j\" }," - - -echo "{ \"settxfee 0.0$count$k$j\": \"$(bitcoin-cli settxfee 0.0$count$k$j)\" }," -#UNAMED -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet sendtoaddress "$SELF_ADDRESS" 0.$count$k$j) -echo "{ \"TXHASH\": \"$TXHASH\" }," -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet sendtoaddress "$PLAY_BITCOIN_ADDRESS" 0.$count$k$j) -echo "{ \"TXHASH\": \"$TXHASH\" }," -#NAMED -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet -named sendtoaddress address="$SELF_ADDRESS" amount=0.$count$k$j comment=$TIME-$count-$k-$j ) -echo "{ \"TXHASH\": \"$TXHASH\" }," -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet -named sendtoaddress address="$PLAY_BITCOIN_ADDRESS" amount=0.$count$k$j comment=$TIME-$count-$k-$j ) -echo "{ \"TXHASH\": \"$TXHASH\" }," - - -echo "{ \"settxfee 0.00$count$k$j\": \"$(bitcoin-cli settxfee 0.00$count$k$j)\" }," -#UNAMED -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet sendtoaddress "$SELF_ADDRESS" 0.$count$k$j) -echo "{ \"TXHASH\": \"$TXHASH\" }," -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet sendtoaddress "$PLAY_BITCOIN_ADDRESS" 0.$count$k$j) -echo "{ \"TXHASH\": \"$TXHASH\" }," -#NAMED -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet -named sendtoaddress address="$SELF_ADDRESS" amount=0.$count$k$j comment=$TIME-$count-$k-$j ) -echo "{ \"TXHASH\": \"$TXHASH\" }," -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet -named sendtoaddress address="$PLAY_BITCOIN_ADDRESS" amount=0.$count$k$j comment=$TIME-$count-$k-$j ) -echo "{ \"TXHASH\": \"$TXHASH\" }," - - -echo "{ \"settxfee 0.000$count$k$j\": \"$(bitcoin-cli settxfee 0.000$count$k$j)\" }," -#UNAMED -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet sendtoaddress "$SELF_ADDRESS" 0.$count$k$j) -echo "{ \"TXHASH\": \"$TXHASH\" }," -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet sendtoaddress "$PLAY_BITCOIN_ADDRESS" 0.$count$k$j) -echo "{ \"TXHASH\": \"$TXHASH\" }," -#NAMED -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet -named sendtoaddress address="$SELF_ADDRESS" amount=0.$count$k$j comment=$TIME-$count-$k-$j ) -echo "{ \"TXHASH\": \"$TXHASH\" }," -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet -named sendtoaddress address="$PLAY_BITCOIN_ADDRESS" amount=0.$count$k$j comment=$TIME-$count-$k-$j ) -echo "{ \"TXHASH\": \"$TXHASH\" }," - -echo "{ \"settxfee 0.0000$count$k$j\": \"$(bitcoin-cli settxfee 0.0000$count$k$j)\" }," -#UNAMED -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet sendtoaddress "$SELF_ADDRESS" 0.$count$k$j) -echo "{ \"TXHASH\": \"$TXHASH\" }," -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet sendtoaddress "$PLAY_BITCOIN_ADDRESS" 0.$count$k$j) -echo "{ \"TXHASH\": \"$TXHASH\" }," -#NAMED -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet -named sendtoaddress address="$SELF_ADDRESS" amount=0.$count$k$j comment=$TIME-$count-$k-$j ) -echo "{ \"TXHASH\": \"$TXHASH\" }," -TXHASH=$(bitcoin-cli -rpcwallet=playground-wallet -named sendtoaddress address="$PLAY_BITCOIN_ADDRESS" amount=0.$count$k$j comment=$TIME-$count-$k-$j ) -echo "{ \"TXHASH\": \"$TXHASH\" }," - -} -end_time(){ -echo "{ \"END_TIME\": $(date +%s) }]}" -} -################################################################################ -for (( i = 1; i <= 200; i++ )) ### i loop -do - export i - for (( j = 1 ; j <= 9; j++ )) ### j loop - do - export j - padtowidth=$j - for z in 0 {1..30} {30..100}; do - k=$(printf "%0*d\n" $padtowidth $z;) - export k - echo "}," - echo "{ \"inner-loop\": [" - #host-cli-automate - #trap1 - trap 'end_time; exit' SIGINT SIGQUIT - count=0 - while : - do - sleep 1 - count=$(expr $count + 1) - export count - echo "{ \"count\": \"$count\" }," - echo "{ \"i\": \"$i\" }," - echo "{ \"j\": \"$j\" }," - echo "{ \"k\": \"$k\" }," - - #play-getcoins -a $( echo play-getcoins -a tb1qv07v5f0mmvnzczfs50c8wv8s76rrrdcr875y7z -r true) > /dev/null 2>&1 - host-cli-automate - echo $(bitcoin-cli -rpcwallet=playground-wallet getbalances), - echo $(play-bitcoin getbalances), - #play-getcoins -a $( echo play-getcoins -a tb1qv07v5f0mmvnzczfs50c8wv8s76rrrdcr875y7z -r true) > /dev/null 2>&1 - - #echo "{ \"COUNT\": \"$count\" }," - done - #cli-with-play-bitcoin - done - done -done -blocknotify -# \ No newline at end of file