Signet:Custom:Script: Difference between revisions
Jump to navigation
Jump to search
Add modified version of cdaki's script from https://gist.github.com/carnhofdaki/60edef577f637ef2dbf4d244e4e279c2 |
m Signet Script: Use -wallet="test" instead of createwallet || loadwallet (as per https://github.com/bitcoin/bitcoin/pull/15454 and https://github.com/ElementsProject/lightning/pull/4088) |
||
Line 4: | Line 4: | ||
cd ~/src/bitcoin/src | cd ~/src/bitcoin/src | ||
./bitcoind -regtest -daemon=1 | ./bitcoind -regtest -daemon=1 -wallet="test" | ||
printf "Waiting for regtest bitcoind to start" | printf "Waiting for regtest bitcoind to start" | ||
while ! ./bitcoin-cli -regtest getconnectioncount 2>/dev/null 1>&2 | while ! ./bitcoin-cli -regtest getconnectioncount 2>/dev/null 1>&2 | ||
Line 10: | Line 10: | ||
done; echo | done; echo | ||
ADDR=$(./bitcoin-cli -regtest getnewaddress '' bech32) | ADDR=$(./bitcoin-cli -regtest getnewaddress '' bech32) | ||
PRIVKEY=$(./bitcoin-cli -regtest dumpprivkey $ADDR) | PRIVKEY=$(./bitcoin-cli -regtest dumpprivkey $ADDR) | ||
Line 39: | Line 37: | ||
EOF | EOF | ||
./bitcoind -datadir=$datadir | ./bitcoind -datadir=$datadir -wallet="test" | ||
printf "Waiting for custom Signet bitcoind to start" | printf "Waiting for custom Signet bitcoind to start" | ||
Line 46: | Line 44: | ||
done; echo | done; echo | ||
./bitcoin-cli -datadir=$datadir importprivkey "$PRIVKEY" | ./bitcoin-cli -datadir=$datadir importprivkey "$PRIVKEY" | ||
NADDR=$(./bitcoin-cli -datadir=$datadir getnewaddress) | NADDR=$(./bitcoin-cli -datadir=$datadir getnewaddress) |
Latest revision as of 15:17, 12 November 2020
#!/bin/sh cd ~/src/bitcoin/src ./bitcoind -regtest -daemon=1 -wallet="test" printf "Waiting for regtest bitcoind to start" while ! ./bitcoin-cli -regtest getconnectioncount 2>/dev/null 1>&2 do printf .; sleep 1 done; echo 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 -wallet="test" 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 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