mynode/rootfs/standard/usr/bin/create_lnd_wallet.tcl

68 lines
1.5 KiB
Tcl
Raw Normal View History

2019-06-15 23:02:44 +00:00
#!/usr/bin/expect
set timeout 5
set f [open "/mnt/hdd/mynode/settings/.lndpw"]
2019-06-15 23:02:44 +00:00
set pw [read $f]
close $f
set seed [lindex $argv 0];
set backup_args ""
if { [file exists "/tmp/lnd_channel_backup"] == 1} {
set backup_args "--multi_file=/tmp/lnd_channel_backup"
}
2019-06-15 23:02:44 +00:00
set tls_cert "/home/bitcoin/.lnd/tls.cert"
set macaroon "/home/bitcoin/.lnd/data/chain/mainnet/admin.macaroon"
2021-03-09 03:55:39 +00:00
set network "--network=mainnet"
if { [file exists "/mnt/hdd/mynode/settings/.testnet_enabled"] == 1} {
set macaroon "/home/bitcoin/.lnd/data/chain/testnet/admin.macaroon"
set network "--network=testnet"
}
2019-06-15 23:02:44 +00:00
2021-03-09 03:55:39 +00:00
spawn lncli $network --tlscertpath $tls_cert --macaroonpath $macaroon create $backup_args
2019-06-15 23:02:44 +00:00
expect {
"recover funds from a static channel backup? (Enter y/n):" {
send -- "y\n"
exp_continue
}
2019-06-15 23:02:44 +00:00
"Input wallet password:" {
send -- "$pw\n"
}
timeout { exit 2 }
}
expect {
"password:" {
2019-06-15 23:02:44 +00:00
send -- "$pw\n"
}
timeout { exit 2 }
}
expect {
"want to use? (Enter y/n):" {
send -- "y\n"
}
timeout { exit 2 }
}
expect {
"spaces:" {
send -- "$seed\n"
}
timeout { exit 2 }
}
expect {
"passphrase):" {
send -- "\n"
}
timeout { exit 2 }
}
expect {
"0):" {
send -- "\n"
}
timeout { exit 2 }
}
expect eof
lassign [wait] pid spawnid os_error_flag return_code
exit $return_code