-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.sh
More file actions
30 lines (23 loc) · 787 Bytes
/
create.sh
File metadata and controls
30 lines (23 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
function executeCommand() {
command=$1
result=$(eval $command)
echo $result
return $?
}
walletName=$(executeCommand 'bitcoin-cli -regtest getwalletinfo | jq -r '.walletname'')
if [ "$walletName" == "ord" ]; then
echo "Wallet named ord exists, exiting."
exit 1
fi
executeCommand 'ord -r wallet create'
receiveAddress=$(executeCommand 'ord -r wallet receive')
if [[ $receiveAddress == *"RpcError code -4"* ]]; then
echo "Error: Wallet file verification failed. Wallet already created."
exit 1
fi
receiveAddress=$(echo $receiveAddress | jq -r '.address')
executeCommand "bitcoin-cli -regtest generatetoaddress 120 $receiveAddress"
balance=$(executeCommand 'ord -r wallet balance')
balance=$(echo $balance | jq -r '.balance')
echo 'Initialized ord wallet'