@@ -13,15 +13,8 @@ import (
1313 "unicode"
1414
1515 "github.com/goccy/go-json"
16- "github.com/mitchellh/go-homedir"
17- "gopkg.in/yaml.v2"
1816
19- "github.com/rocket-pool/smartnode/bindings/types"
20- "github.com/rocket-pool/smartnode/shared/services/config"
21- "github.com/rocket-pool/smartnode/shared/services/rocketpool"
22- "github.com/rocket-pool/smartnode/shared/types/api"
2317 "github.com/rocket-pool/smartnode/shared/utils/cli/prompt"
24- hexutils "github.com/rocket-pool/smartnode/shared/utils/hex"
2518)
2619
2720// IPInfo API
@@ -255,75 +248,3 @@ func promptTimezone() string {
255248 fmt .Printf ("Using timezone %s.\n " , timezone )
256249 return timezone
257250}
258-
259- // Prompt for the password to a solo validator key as part of migration
260- func promptForSoloKeyPassword (rp * rocketpool.Client , cfg * config.RocketPoolConfig , pubkey types.ValidatorPubkey ) (string , error ) {
261-
262- // Check for the custom key directory
263- datapath , err := homedir .Expand (cfg .Smartnode .DataPath .Value .(string ))
264- if err != nil {
265- return "" , fmt .Errorf ("error expanding data directory: %w" , err )
266- }
267- customKeyDir := filepath .Join (datapath , "custom-keys" )
268- info , err := os .Stat (customKeyDir )
269- if os .IsNotExist (err ) || ! info .IsDir () {
270- return "" , nil
271- }
272-
273- // Get the custom keystore files
274- files , err := os .ReadDir (customKeyDir )
275- if err != nil {
276- return "" , fmt .Errorf ("error enumerating custom keystores: %w" , err )
277- }
278- if len (files ) == 0 {
279- return "" , nil
280- }
281-
282- // Get the pubkeys for the custom keystores
283- pubkeyPasswords := map [string ]string {}
284- for _ , file := range files {
285- // Read the file
286- bytes , err := os .ReadFile (filepath .Join (customKeyDir , file .Name ()))
287- if err != nil {
288- return "" , fmt .Errorf ("error reading custom keystore %s: %w" , file .Name (), err )
289- }
290-
291- // Deserialize it
292- keystore := api.ValidatorKeystore {}
293- err = json .Unmarshal (bytes , & keystore )
294- if err != nil {
295- return "" , fmt .Errorf ("error deserializing custom keystore %s: %w" , file .Name (), err )
296- }
297-
298- if keystore .Pubkey == pubkey {
299- // Found it, prompt for the password
300- password := prompt .PromptPassword (
301- fmt .Sprintf ("Please enter the password that the keystore for %s was encrypted with:" , pubkey .Hex ()), "^.*$" , "" ,
302- )
303-
304- formattedPubkey := strings .ToUpper (hexutils .RemovePrefix (pubkey .Hex ()))
305- pubkeyPasswords [formattedPubkey ] = password
306-
307- fmt .Println ()
308- break
309- }
310- }
311-
312- if len (pubkeyPasswords ) == 0 {
313- return "" , fmt .Errorf ("couldn't find the keystore for validator %s in the custom-keys directory; if you want to import this key into the Smart Node stack, you will need to put its keystore file into custom-keys first" , pubkey .String ())
314- }
315-
316- // Store it in the file
317- fileBytes , err := yaml .Marshal (pubkeyPasswords )
318- if err != nil {
319- return "" , fmt .Errorf ("error serializing keystore passwords file: %w" , err )
320- }
321- passwordFile := filepath .Join (datapath , "custom-key-passwords" )
322- err = os .WriteFile (passwordFile , fileBytes , 0600 )
323- if err != nil {
324- return "" , fmt .Errorf ("error writing keystore passwords file: %w" , err )
325- }
326-
327- return passwordFile , nil
328-
329- }
0 commit comments