Skip to content
This repository was archived by the owner on Dec 4, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions devenv/miner/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ curl --user devnet:devnet --data-binary '{"jsonrpc": "1.0", "id": "curltest", "m
echo "devnet bitcoin wallet created"
# Import miner address
curl --user devnet:devnet --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "importaddress", "params": ["n3GRiDLKWuKLCw1DZmV75W1mE35qmW2tQm"]}' -H 'content-type: text/plain;' http://bitcoin:18443/
# Mine the first N blocks
# Mine the first N blocks to the stacks miner wallet address
curl --user devnet:devnet --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "generatetoaddress", "params": ['''${INIT_BTC_BLOCKS}''', "n3GRiDLKWuKLCw1DZmV75W1mE35qmW2tQm"]}' -H 'content-type: text/plain;' http://bitcoin:18443/
echo "mined initial blocks"
# Mine a single block every 10 seconds
echo "mined initial blocks to stacks miner wallet"
# Mine the first N blocks to the stacks deployer wallet address
curl --user devnet:devnet --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "generatetoaddress", "params": ['''${INIT_BTC_BLOCKS}''', "bcrt1q3zl64vadtuh3vnsuhdgv6pm93n82ye8q6cr4ch"]}' -H 'content-type: text/plain;' http://bitcoin:18443/
echo "mined initial blocks to stacks deployer wallet"
# Mine a single block every 10 seconds to the stacks deployer wallet address
while true
do
curl --user devnet:devnet --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "generatetoaddress", "params": [1, "n3GRiDLKWuKLCw1DZmV75W1mE35qmW2tQm"]}' -H 'content-type: text/plain;' http://bitcoin:18443/
curl --user devnet:devnet --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "generatetoaddress", "params": [1, "bcrt1q3zl64vadtuh3vnsuhdgv6pm93n82ye8q6cr4ch"]}' -H 'content-type: text/plain;' http://bitcoin:18443/
echo "mined a single block"
sleep ${BTC_BLOCK_GEN_TIME}
done
2 changes: 1 addition & 1 deletion devenv/sbtc/bin/sbtc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

docker exec -it sbtc sbtc $@
docker exec -it sbtc sbtc "$@"
10 changes: 7 additions & 3 deletions devenv/utils/deposit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ stacks_address=$(source $dir/get_credentials.sh | jq -r '.credentials["1"].stack

amount=$((RANDOM%9000+1000))

json=$(sbtc deposit \
json=$($dir/../sbtc/bin/sbtc deposit \
-w $btc_wif \
-n regtest \
-r $stacks_address \
-a $amount \
-d $btc_p2tr_address \
-u localhost:60401)
-u electrs:60401)

echo $json

if [ $? -ne 0 ]; then
echo 'The deposit failed, did you forget to run "mine_btc.sh"?'
Expand All @@ -28,4 +30,6 @@ fi

tx=$(echo -n $json | jq -r .hex)

sbtc broadcast localhost:60401 $tx | jq -r .
echo $tx

$dir/../sbtc/bin/sbtc broadcast electrs:60401 $tx | jq -r .
4 changes: 3 additions & 1 deletion devenv/utils/get_credentials.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash

dir="$(dirname "$0")"

# Returns the default credentials for the devnet

mnemonic="twice kind fence tip hidden tilt action fragile skin nothing glory cousin green tomorrow spring wrist shed math olympic multiply hip blue scout claw"

sbtc generate-from -s testnet -b regtest --accounts 2 mnemonic "$mnemonic"
$dir/../sbtc/bin/sbtc generate-from -s testnet -b regtest --accounts 2 mnemonic "$mnemonic"
2 changes: 1 addition & 1 deletion devenv/utils/mine_btc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ fi

btc_address=$(source $dir/get_credentials.sh | jq -r '.credentials["1"].bitcoin.p2wpkh.address')

bitcoin-cli -rpcconnect=localhost -rpcport=18443 -rpcuser=devnet -rpcpassword=devnet generatetoaddress $num_blocks $btc_address
$dir/../bitcoin/bin/bitcoin-cli generatetoaddress $num_blocks $btc_address
6 changes: 3 additions & 3 deletions devenv/utils/withdraw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ stacks_wif=$(source $dir/get_credentials.sh | jq -r '.credentials["1"].stacks.wi
amount=$((RANDOM%1000+1000))
fulfillment_fee=$((RANDOM%1000+1000))

json=$(sbtc withdraw \
json=$($dir/../sbtc/bin/sbtc withdraw \
-w $btc_wif \
-n regtest \
-d $stacks_wif \
-b $btc_address \
-a $amount \
-f $fulfillment_fee \
-p $btc_p2tr_address \
-u localhost:60401)
-u electrs:60401)


if [ $? -ne 0 ]; then
Expand All @@ -36,4 +36,4 @@ fi

tx=$(echo -n $json | jq -r .hex)

sbtc broadcast localhost:60401 $tx | jq -r .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this work before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pr depends on stacks-sbtc/sbtc#229

Copy link
Contributor

@friedger friedger Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We all had installed the sbtc binary locally..

$dir/../sbtc/bin/sbtc broadcast electrs:60401 $tx | jq -r .