@@ -7,6 +7,8 @@ headless_install=0
7
7
is_root=0
8
8
skip_account_setup=0
9
9
migrate_host_based_setup=0
10
+ kmd_token=" "
11
+ wallet_password=" "
10
12
11
13
bold=$( tput bold)
12
14
normal=$( tput sgr0)
@@ -229,12 +231,43 @@ catchup_node() {
229
231
display_banner " Caught up with the network!"
230
232
}
231
233
234
+ ask_for_password () {
235
+ local password
236
+ local password_repeat
237
+ while true ; do
238
+ # shellcheck disable=SC2162
239
+ read -sp " Password: " password
240
+ echo
241
+ # shellcheck disable=SC2162
242
+ read -sp " Repeat password: " password_repeat
243
+ echo
244
+ if [[ ${password} == " ${password_repeat} " ]]; then
245
+ wallet_password=${password}
246
+ break
247
+ else
248
+ # shellcheck disable=SC2028
249
+ echo -e " \n"
250
+ echo " Passwords do not match. Please try again."
251
+ fi
252
+ done
253
+ }
254
+
232
255
create_wallet () {
233
256
if [[ $( execute_docker_command " goal wallet list | wc -l" ) -eq 1 ]]; then
234
257
echo " Let's create a new wallet for you. Please provide a password for security."
235
- echo " Seeing the wallet's mnemonic is optional. Any Voi will be linked with the account we'll create or import after wallet creation."
236
258
237
- execute_interactive_docker_command " goal wallet new voi"
259
+ get_kmd_token
260
+
261
+ ask_for_password
262
+
263
+ read -r -d ' ' json_data << EOF
264
+ {\"wallet_name\": \"voi\",\"wallet_driver_name\": \"sqlite\", \"wallet_password\": \"${wallet_password} \"}
265
+ EOF
266
+
267
+ response_code=$( execute_docker_command " curl -s -o /dev/null -w '%{http_code}' -X POST -H 'Content-Type: application/json' -H 'X-KMD-API-Token: ${kmd_token} ' -d '${json_data} ' http://localhost:7833/v1/wallet" )
268
+ if [[ response_code -ne 200 ]]; then
269
+ abort " Error creating wallet. Exiting the program."
270
+ fi
238
271
else
239
272
echo " Wallet already exists. Skipping wallet creation."
240
273
fi
@@ -260,7 +293,7 @@ get_account_info() {
260
293
allow_one_account=$1
261
294
262
295
if execute_sudo ' test ! -f "/var/lib/voi/algod/data/voitest-v1/accountList.json"' ; then
263
- abort " Account list not found. Exiting the program. "
296
+ return 0
264
297
fi
265
298
266
299
accounts_json=$( execute_sudo ' cat /var/lib/voi/algod/data/voitest-v1/accountList.json' )
@@ -388,6 +421,14 @@ generate_participation_key() {
388
421
fi
389
422
}
390
423
424
+ start_kmd () {
425
+ execute_docker_command " goal kmd start -t 600"
426
+ }
427
+
428
+ get_kmd_token () {
429
+ kmd_token=$( execute_docker_command " cat /algod/data/kmd-v0.5/kmd.token" )
430
+ }
431
+
391
432
display_banner () {
392
433
echo
393
434
echo " ********************************************************************************"
707
748
mkdir -p " ${voi_home} "
708
749
709
750
display_banner " Fetching the latest Voi Network updates and scripts."
710
- curl -L https://api.github.com/repos/VoiNetwork/voi-swarm/tarball/main --output " ${voi_home} " /voi-swarm.tar.gz
751
+ curl -sSL https://api.github.com/repos/VoiNetwork/voi-swarm/tarball/main --output " ${voi_home} " /voi-swarm.tar.gz
711
752
tar -xzf " ${voi_home} " /voi-swarm.tar.gz -C " ${voi_home} " --strip-components=1
712
753
rm " ${voi_home} " /voi-swarm.tar.gz
713
754
@@ -727,12 +768,13 @@ if [[ -n ${VOINETWORK_SKIP_WALLET_SETUP} && ${VOINETWORK_SKIP_WALLET_SETUP} -eq
727
768
exit 0
728
769
fi
729
770
771
+ start_kmd
772
+
730
773
display_banner " Initiating setup for Voi wallets and accounts."
731
774
732
775
create_wallet
733
776
734
777
if [[ -n ${VOINETWORK_IMPORT_ACCOUNT} && ${VOINETWORK_IMPORT_ACCOUNT} -eq 1 ]]; then
735
-
736
778
if ! (check_if_account_exists true); then
737
779
echo " An account already exists. No need to import, skipping this step."
738
780
else
0 commit comments