diff --git a/cli/wallet.go b/cli/wallet.go index 61946a463..8d44d3ef2 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -7,7 +7,9 @@ import ( "encoding/json" "fmt" "os" + "os/signal" "strings" + "syscall" "github.com/urfave/cli/v2" "golang.org/x/term" @@ -335,6 +337,20 @@ var walletImport = &cli.Command{ if !cctx.Args().Present() || cctx.Args().First() == "-" { if term.IsTerminal(int(os.Stdin.Fd())) { fmt.Print("Enter private key(not display in the terminal): ") + + // Create a channel to receive OS signals + sigCh := make(chan os.Signal, 1) + // Notify the channel when SIGINT is received + signal.Notify(sigCh, syscall.SIGINT) + + go func() { + // Wait for SIGINT signal + <-sigCh + // Perform cleanup or other actions as needed + fmt.Println("\nInterrupt signal received. Exiting...") + os.Exit(1) + }() + inpdata, err = term.ReadPassword(int(os.Stdin.Fd())) if err != nil { return err