-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: create non-descriptor wallet (#487)
* dev(regtest): remove nbxplorer in favor of simpler custom regtest-initializer * dev(regtest): use jsonrpc 2.0 requests to create and load wallet * dev(regtest): upgrade bitcoin core from v22 to v23 * fix(regtest): wait-for-bitcoind should wait for at least >=0 blocks * dev(regtest): use jam-dev-standalone * dev(regtest): add npm script regtest:build this command will build the development setup with docker cache enabled. usually must fast as it will only pull in newer base images and not download and recompile jm again. this is the preferred way if you made only a few adaptions to the images and e.g. not want to fetch the current master of jm.
- Loading branch information
1 parent
ace3734
commit 0d70415
Showing
9 changed files
with
139 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
docker/regtest/dockerfile-deps/bitcoin/regtest-initializer/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM alpine:3.16 | ||
|
||
# install build dependencies | ||
RUN apk add --no-cache --update curl jq | ||
|
||
COPY wait-for-bitcoind.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/wait-for-bitcoind.sh | ||
|
||
COPY wait-for-blocks.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/wait-for-blocks.sh | ||
|
||
COPY mine-blocks.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/mine-blocks.sh | ||
|
||
COPY entrypoint.sh / | ||
RUN chmod +x /entrypoint.sh | ||
|
||
ENTRYPOINT [ "/entrypoint.sh" ] |
23 changes: 23 additions & 0 deletions
23
docker/regtest/dockerfile-deps/bitcoin/regtest-initializer/entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
set -Eeuo pipefail | ||
|
||
export _BTC_USER="${RPC_USER}:${RPC_PASSWORD}" | ||
export _BTC_URL="http://${RPC_HOST}:${RPC_PORT}" | ||
|
||
if [ -f "${READY_FILE}" ]; then | ||
echo "Removing $READY_FILE..." | ||
rm -f "${READY_FILE}" | ||
echo "Removed $READY_FILE." | ||
fi | ||
|
||
MINE_BLOCKS=101 | ||
|
||
source /usr/local/bin/wait-for-bitcoind.sh | ||
source /usr/local/bin/mine-blocks.sh "${MINE_BLOCKS}" | ||
source /usr/local/bin/wait-for-blocks.sh "${MINE_BLOCKS}" | ||
|
||
if [ "${READY_FILE}" ] && [ ! -f "${READY_FILE}" ]; then | ||
echo "Creating $READY_FILE..." | ||
echo "1" > "${READY_FILE}" | ||
echo "Created $READY_FILE." | ||
fi |
16 changes: 16 additions & 0 deletions
16
docker/regtest/dockerfile-deps/bitcoin/regtest-initializer/mine-blocks.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
set -Eeuo pipefail | ||
|
||
BLOCKS=${1:-101} # default to mine a single block | ||
ADDRESS=${2:-bcrt1qrnz0thqslhxu86th069r9j6y7ldkgs2tzgf5wx} # default to a "random" address | ||
|
||
echo "Mining ${BLOCKS} blocks to address ${ADDRESS}..." | ||
payload="{\ | ||
\"jsonrpc\":\"1.0\",\ | ||
\"id\":\"curl\",\ | ||
\"method\":\"generatetoaddress\",\ | ||
\"params\":[${BLOCKS},\"${ADDRESS}\"]\ | ||
}" | ||
curl --silent --user "${_BTC_USER}" --data-binary "${payload}" "${_BTC_URL}" > /dev/null 2>&1 | ||
|
||
echo "Successfully mined ${BLOCKS} blocks to address ${ADDRESS}." |
4 changes: 4 additions & 0 deletions
4
docker/regtest/dockerfile-deps/bitcoin/regtest-initializer/wait-for-bitcoind.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
set -Eeuo pipefail | ||
|
||
source /usr/local/bin/wait-for-blocks.sh 0 |
18 changes: 18 additions & 0 deletions
18
docker/regtest/dockerfile-deps/bitcoin/regtest-initializer/wait-for-blocks.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
set -Eeuo pipefail | ||
|
||
BLOCKS=${1:-0} # wait for x amount of blocks | ||
|
||
echo "Waiting for bitcoind to report at least ${BLOCKS} blocks..." | ||
payload="{\ | ||
\"jsonrpc\":\"1.0\",\ | ||
\"id\":\"curl\",\ | ||
\"method\":\"getblockchaininfo\",\ | ||
\"params\":[]\ | ||
}" | ||
until curl --silent --user "${_BTC_USER}" --data-binary "${payload}" "${_BTC_URL}" | jq -e ".result.blocks >= ${BLOCKS}" > /dev/null 2>&1 | ||
do | ||
echo -n "." | ||
sleep 1 | ||
done | ||
echo "Successfully waited for ${BLOCKS} blocks to be reported." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters