1+ name : Run Setup Script
2+
3+ on :
4+ push :
5+ branches :
6+ - main # Trigger on pushes to the main branch
7+
8+ jobs :
9+ bitcoin-setup :
10+ runs-on : ubuntu-latest # Use the latest Ubuntu environment
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4 # Check out the repository code
15+
16+ - name : Cache Bitcoin Core
17+ id : cache-bitcoin
18+ uses : actions/cache@v3
19+ with :
20+ path : |
21+ bitcoin-28.0
22+ bitcoin-28.0-x86_64-linux-gnu.tar.gz
23+ key : bitcoin-core-28.0
24+
25+ - name : Setup Bitcoin Core
26+ run : |
27+ if [ "${{ steps.cache-bitcoin.outputs.cache-hit }}" != 'true' ]; then
28+ wget https://bitcoincore.org/bin/bitcoin-core-28.0/bitcoin-28.0-x86_64-linux-gnu.tar.gz
29+ tar -xzvf bitcoin-28.0-x86_64-linux-gnu.tar.gz
30+ fi
31+ sudo bash .github/setup.sh
32+
33+ - name : Start bitcoind in regtest mode
34+ run : |
35+ bitcoind -regtest -daemon
36+ echo "Waiting for bitcoind to be ready..."
37+
38+ # Wait for bitcoind to start (max 30s)
39+ for i in {1..30}; do
40+ if bitcoin-cli -regtest getblockchaininfo > /dev/null 2>&1; then
41+ echo "✅ bitcoind is ready!"
42+ break
43+ fi
44+ echo "Still waiting for bitcoind..."
45+ sleep 1
46+ done
47+
48+ - name : Verify Wallet Creation
49+ run : |
50+ chmod +x submission/01.sh
51+ WALLET=$(submission/01.sh)
52+ if [[ "$WALLET" == *"btrustwallet"* ]]; then
53+ echo "✅ Success: Wallet creation passed!"
54+ else
55+ echo "❌ Error: Wallet creation failed!"
56+ exit 1
57+ fi
58+
59+ - name : Verify Change Address Generation
60+ run : |
61+ chmod +x submission/02.sh
62+ CHANGE_ADDRESS=$(submission/02.sh)
63+ echo "CHANGE_ADDRESS=$CHANGE_ADDRESS"
64+ if [[ "$CHANGE_ADDRESS" =~ ^bcrt1[ac-hj-np-z02-9]{8,87}$ ]]; then
65+ echo "✅ Success: Change address generation passed!"
66+ else
67+ echo "❌ Error: Change address generation failed!"
68+ exit 1
69+ fi
70+
71+ - name : Verify Adding Funds to SegWit Address
72+ run : |
73+ chmod +x submission/03.sh
74+ ADD=$(submission/03.sh)
75+ echo "ADD=$ADD"
76+ BALANCE=$(bitcoin-cli -regtest getreceivedbyaddress "$ADD" 0)
77+ if (( $(echo "$BALANCE > 0" | bc -l) )); then
78+ echo "✅ Success: Adding funds to SegWit address passed!"
79+ else
80+ echo "❌ Error: Adding funds to SegWit address failed!"
81+ exit 1
82+ fi
83+
84+ - name : Verify Listing the current UTXOs in your wallet.
85+ run : |
86+ chmod +x submission/04.sh
87+ UTXOs=$(submission/04.sh)
88+ if [[ "$UTXOs" != "[]" && "$UTXOs" =~ "txid" ]]; then
89+ echo "✅ Success: Listing the current UTXOs in your wallet passed!"
90+ else
91+ echo "❌ Error: Listing the current UTXOs in your wallet failed!"
92+ exit 1
93+ fi
94+
95+ - name : Verify Transaction ID
96+ run : |
97+ chmod +x submission/05.sh
98+ TRANSACTION_ID=$(submission/05.sh)
99+ EXPECTED_OUTPUT=23c19f37d4e92e9a115aab86e4edc1b92a51add4e0ed0034bb166314dde50e16
100+ if [[ "$TRANSACTION_ID" == "$EXPECTED_OUTPUT" ]]; then
101+ echo "✅ Success: Transaction ID Check passed!"
102+ else
103+ echo "❌ Error: Transaction ID Check failed!"
104+ exit 1
105+ fi
106+
107+ - name : Verify Total Transaction Output
108+ run : |
109+ chmod +x submission/06.sh
110+ ACTUAL_OUTPUT=$(submission/06.sh)
111+ EXPECTED_OUTPUT=23679108
112+ if [[ "$ACTUAL_OUTPUT" == "$EXPECTED_OUTPUT" ]]; then
113+ echo "✅ Success: Total Transaction Output Check passed!"
114+ else
115+ echo "❌ Error: Total Transaction Output Check failed!"
116+ exit 1
117+ fi
118+
119+ - name : Verify Raw Transaction Hex
120+ run : |
121+ chmod +x submission/07.sh
122+ ACTUAL_OUTPUT=$(submission/07.sh)
123+ EXPECTED_OUTPUT=0200000002160ee5dd146316bb3400ede0d4ad512ab9c1ede486ab5a119a2ee9d4379fc1230000000000fdffffff160ee5dd146316bb3400ede0d4ad512ab9c1ede486ab5a119a2ee9d4379fc1230100000000fdffffff01002d31010000000017a91421ed90762e16eaaea188aae19142e5b25bf75d238700000000
124+ if [[ "$ACTUAL_OUTPUT" == "$EXPECTED_OUTPUT" ]]; then
125+ echo "✅ Success: Total Transaction Output Check passed!"
126+ else
127+ echo "❌ Error: Total Transaction Output Check failed!"
128+ exit 1
129+ fi
130+
131+ - name : Verify Raw Transaction Hex
132+ run : |
133+ chmod +x submission/08.sh
134+ ACTUAL_OUTPUT=$(submission/08.sh)
135+ EXPECTED_OUTPUT=0200000002160ee5dd146316bb3400ede0d4ad512ab9c1ede486ab5a119a2ee9d4379fc123000000000001000000160ee5dd146316bb3400ede0d4ad512ab9c1ede486ab5a119a2ee9d4379fc12301000000000100000001002d31010000000017a91421ed90762e16eaaea188aae19142e5b25bf75d238700000000
136+ if [[ "$ACTUAL_OUTPUT" == "$EXPECTED_OUTPUT" ]]; then
137+ echo "✅ Success: Total Transaction Output Check passed!"
138+ else
139+ echo "❌ Error: Total Transaction Output Check failed!"
140+ exit 1
141+ fi
142+
0 commit comments