Skip to content

Commit

Permalink
Fix: Includes updates to the local dev env setup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
emailnjv committed Jun 17, 2024
1 parent 154a573 commit 94a28b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions etc/config/jwt/jwt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a
24 changes: 12 additions & 12 deletions scripts/utils/bitcoin.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
function stop_bitcoin() {
bitcoin-cli -regtest stop
bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword stop
}

function fund_wallet() {
# create a new wallet
bitcoin-cli -regtest -rpcwait createwallet $1 >/dev/null 2>&1
bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -rpcwait createwallet $1 >/dev/null 2>&1
# load the wallet if it already exists
bitcoin-cli -regtest -rpcwait loadwallet $1 >/dev/null 2>&1
bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -rpcwait loadwallet $1 >/dev/null 2>&1
# mine enough blocks so the funds are spendable
bitcoin-cli -regtest generatetoaddress 101 $(bitcoin-cli -regtest -rpcwallet=$1 getnewaddress) >/dev/null
bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword generatetoaddress 101 $(bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -rpcwallet=$1 getnewaddress) >/dev/null
}

function maybe_fund_wallet() {
if ! bitcoin-cli -regtest getwalletinfo >/dev/null 2>&1; then
if bitcoin-cli -regtest loadwallet $1 >/dev/null 2>&1; then
if ! bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword getwalletinfo >/dev/null 2>&1; then
if bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword loadwallet $1 >/dev/null 2>&1; then
echo "Loaded wallet"
else
echo "Funding wallet"
Expand All @@ -25,7 +25,7 @@ function maybe_fund_wallet() {
function start_bitcoin() {
# clear and start bitcoin regtest
rm -rf $HOME/.bitcoin/regtest/
bitcoind -regtest -server -fallbackfee=0.002 -daemon
bitcoind -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -server -fallbackfee=0.002 -daemon
# fund default alice wallet
fund_wallet "alice"
}
Expand All @@ -34,14 +34,14 @@ function start_bitcoin() {
function pegin() {
payment='[{"'$1'":"'$2'"},{"data":"'$3'"}]'
# Step 1: Generate the transaction
unfunded=$(bitcoin-cli -regtest -rpcwallet=alice createrawtransaction '[]' $payment)
unfunded=$(bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -rpcwallet=alice createrawtransaction '[]' $payment)
# Step 2: Fund the transaction
funded=$(bitcoin-cli -regtest -rpcwallet=alice fundrawtransaction $unfunded | jq -r '.hex')
funded=$(bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -rpcwallet=alice fundrawtransaction $unfunded | jq -r '.hex')
# Step 3: Sign the transaction
signed=$(bitcoin-cli -regtest -rpcwallet=alice signrawtransactionwithwallet $funded | jq -r '.hex' )
signed=$(bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -rpcwallet=alice signrawtransactionwithwallet $funded | jq -r '.hex' )
# Step 4: Send the transaction
txid=$(bitcoin-cli -regtest -rpcwallet=alice sendrawtransaction $signed)
txid=$(bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -rpcwallet=alice sendrawtransaction $signed)
# Step 5: Mine the transaction
block=$(bitcoin-cli -regtest -rpcwallet=alice generatetoaddress 7 bcrt1qewndkwr0evznxz7urnhlv5eav9rx2clsf0lh77 | jq -r '.[0]')
block=$(bitcoin-cli -regtest -rpcuser=rpcuser -rpcpassword=rpcpassword -rpcwallet=alice generatetoaddress 7 bcrt1qewndkwr0evznxz7urnhlv5eav9rx2clsf0lh77 | jq -r '.[0]')
echo $block
}
8 changes: 4 additions & 4 deletions scripts/utils/geth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ function start_geth() {
WS_PORT=$((8546 + $NUM * 10))
PORT=$((30303 + $NUM * 10))

geth init --state.scheme "hash" --datadir "./data/execution/node${NUM}" ./data/genesis.json > "$PWD/data/logs/geth${NUM}.txt" 2>&1
geth --datadir "./data/execution/node${NUM}" \
geth init --state.scheme "hash" --datadir "./etc/data/execution/node${NUM}" ./etc/config/genesis.json > "$PWD/etc/data/logs/geth${NUM}.txt" 2>&1
geth --datadir "./etc/data/execution/node${NUM}" \
--state.scheme "hash" \
--networkid 212121 \
--authrpc.vhosts "*" \
--authrpc.addr "0.0.0.0" \
--authrpc.jwtsecret "./data/jwtsecret" \
--authrpc.jwtsecret "./etc/config/jwt/jwt" \
--authrpc.port ${AUTHRPC_PORT} \
--http \
--http.addr "0.0.0.0" \
Expand All @@ -38,7 +38,7 @@ function start_geth() {
--port ${PORT} \
--gcmode "archive" \
--maxpeers 0 \
>> "$PWD/data/logs/geth${NUM}.txt" 2>&1 &
>> "$PWD/etc/data/logs/geth${NUM}.txt" 2>&1 &
GETH_PIDS[$i]=$!
}

Expand Down

0 comments on commit 94a28b8

Please sign in to comment.