Last active
October 2, 2020 11:36
-
-
Save carnhofdaki/60edef577f637ef2dbf4d244e4e279c2 to your computer and use it in GitHub Desktop.
custom-signet 10/2020
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
#!/bin/sh | |
cd ~/src/bitcoin/src | |
./bitcoind -regtest -daemon=1 | |
printf "Waiting for regtest bitcoind to start" | |
while ! ./bitcoin-cli -regtest getconnectioncount 2>/dev/null 1>&2 | |
do printf .; sleep 1 | |
done; echo | |
./bitcoin-cli -regtest createwallet default >/dev/null 2>&1 | |
./bitcoin-cli -regtest loadwallet default >/dev/null 2>&1 | |
ADDR=$(./bitcoin-cli -regtest getnewaddress '' bech32) | |
PRIVKEY=$(./bitcoin-cli -regtest dumpprivkey $ADDR) | |
PUBKEY=$(./bitcoin-cli -regtest getaddressinfo $ADDR | jq -r .pubkey) | |
LENX2=$(printf $PUBKEY | wc -c) | |
LEN=$((LENX2/2)) | |
LENHEX=$(echo "obase=16; $LEN" | bc) | |
SCRIPT=$(echo 51${LENHEX}${PUBKEY}51ae) | |
cat <<EOF | |
ADDR=$ADDR | |
PRIVKEY=$PRIVKEY | |
PUBKEY=$PUBKEY | |
SCRIPT=$SCRIPT | |
EOF | |
./bitcoin-cli -regtest stop 2>&1 | |
datadir=$HOME/signet-custom-$$ | |
mkdir $datadir | |
cat > $datadir/bitcoin.conf <<EOF | |
signet=1 | |
[signet] | |
daemon=1 | |
signetchallenge=$SCRIPT | |
EOF | |
./bitcoind -datadir=$datadir | |
printf "Waiting for custom Signet bitcoind to start" | |
while ! ./bitcoin-cli -datadir=$datadir getconnectioncount 2>/dev/null 1>&2 | |
do printf .; sleep 1 | |
done; echo | |
./bitcoin-cli -datadir=$datadir createwallet default >/dev/null 2>&1 | |
./bitcoin-cli -datadir=$datadir loadwallet default >/dev/null 2>&1 | |
./bitcoin-cli -datadir=$datadir importprivkey "$PRIVKEY" | |
NADDR=$(./bitcoin-cli -datadir=$datadir getnewaddress) | |
# Examples from | |
# https://github.com/bitcoin/bitcoin/pull/19937#issuecomment-696419619 | |
../contrib/signet/generate.py --cli="./bitcoin-cli -datadir=$datadir" generate 1 --block-time=1 --address="$NADDR" --grind-cmd='./bitcoin-util grind' | |
#../contrib/signet/generate.py --cli="./bitcoin-cli -datadir=$datadir" generate 1 --block-time=1 --address="$NADDR" --backdate 0 | |
#../contrib/signet/generate.py --cli="./bitcoin-cli -datadir=$datadir" generate 1 --block-time=1 --descriptor="wpkh(...)#..." --secondary | |
./bitcoin-cli -datadir=$datadir getblocktemplate '{"rules": ["signet","segwit"]}' \ | |
| ../contrib/signet/generate.py --cli="./bitcoin-cli -datadir=$datadir" genpsbt --address="$NADDR" \ | |
| ./bitcoin-cli -datadir=$datadir -stdin walletprocesspsbt | |
#../contrib/signet/generate.py solvepsbt --grind-cmd='./bitcoin-util grind' | ./bitcoin-cli -datadir=$datadir submitblock | |
./bitcoin-cli -datadir=$datadir stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Signet IV updated version of this script is available at https://en.bitcoin.it/wiki/Signet:Custom:Script
bitcoin/bitcoin#19937 needs to be merged in master or use that source tree to compile bitcoind