@@ -6,14 +6,13 @@ import (
66 "strings"
77
88 "github.com/ethereum/go-ethereum/common"
9- "github.com/urfave/cli"
109
1110 "github.com/rocket-pool/smartnode/shared/services/rocketpool"
1211 "github.com/rocket-pool/smartnode/shared/utils/cli/color"
1312 promptcli "github.com/rocket-pool/smartnode/shared/utils/cli/prompt"
1413)
1514
16- func recoverWallet (c * cli. Context ) error {
15+ func recoverWallet (password , mnemonic , addressFlag string , skipValidatorKeyRecovery bool , derivationPath string , walletIndex uint ) error {
1716
1817 // Get RP client
1918 rp , ready , err := rocketpool .NewClient ().WithStatus ()
@@ -46,10 +45,7 @@ func recoverWallet(c *cli.Context) error {
4645
4746 // Set password if not set
4847 if ! status .PasswordSet {
49- var password string
50- if c .String ("password" ) != "" {
51- password = c .String ("password" )
52- } else {
48+ if password == "" {
5349 password = promptPassword ()
5450 }
5551 if _ , err := rp .SetPassword (password ); err != nil {
@@ -58,7 +54,6 @@ func recoverWallet(c *cli.Context) error {
5854 }
5955
6056 // Handle validator key recovery skipping
61- skipValidatorKeyRecovery := c .Bool ("skip-validator-key-recovery" )
6257 if ! skipValidatorKeyRecovery && ! ready {
6358 fmt .Println (color .Yellow ("Eth Clients are not available." ) + " Validator keys cannot be recovered until they are synced and ready." )
6459 fmt .Println ("You can recover them later with 'rocketpool wallet rebuild'" )
@@ -70,10 +65,7 @@ func recoverWallet(c *cli.Context) error {
7065 }
7166
7267 // Prompt for mnemonic
73- var mnemonic string
74- if c .String ("mnemonic" ) != "" {
75- mnemonic = c .String ("mnemonic" )
76- } else {
68+ if mnemonic == "" {
7769 mnemonic = PromptMnemonic ()
7870 }
7971 mnemonic = strings .TrimSpace (mnemonic )
@@ -101,11 +93,9 @@ func recoverWallet(c *cli.Context) error {
10193 }
10294
10395 // Check for a search-by-address operation
104- addressString := c .String ("address" )
105- if addressString != "" {
106-
96+ if addressFlag != "" {
10797 // Get the address to search for
108- address := common .HexToAddress (addressString )
98+ address := common .HexToAddress (addressFlag )
10999 fmt .Printf ("Searching for the derivation path and index for wallet %s...\n NOTE: this may take several minutes depending on how large your wallet's index is.\n " , address .Hex ())
110100
111101 if ! skipValidatorKeyRecovery {
@@ -139,13 +129,11 @@ func recoverWallet(c *cli.Context) error {
139129 } else {
140130
141131 // Get the derivation path
142- derivationPath := c .String ("derivation-path" )
143132 if derivationPath != "" {
144133 fmt .Printf ("Using a custom derivation path (%s).\n " , derivationPath )
145134 }
146135
147136 // Get the wallet index
148- walletIndex := c .Uint ("wallet-index" )
149137 if walletIndex != 0 {
150138 fmt .Printf ("Using a custom wallet index (%d).\n " , walletIndex )
151139 }
0 commit comments