wallet: update passphrase user experience.
For users don't want to set/manage a passphrase a default passphrase "passphrase" will be used during wallet creation. At startup, the wallet tries to unlock itself using the default passphrase, or a user provided one (using -p). Users that prefer a passphrase can override the default one at wallet creation time using -p, or use the walletpassphrase rpc when the wallet is running. This will prevent the wallet from auto-unlock, and preserve the lock-by-default behavior.
This commit is contained in:
parent
3aca0be46a
commit
1fa143fa0e
3 changed files with 9 additions and 7 deletions
|
@ -58,7 +58,7 @@ type config struct {
|
||||||
DBTimeout time.Duration `long:"dbtimeout" description:"The timeout value to use when opening the wallet database."`
|
DBTimeout time.Duration `long:"dbtimeout" description:"The timeout value to use when opening the wallet database."`
|
||||||
|
|
||||||
// Passphrase options
|
// Passphrase options
|
||||||
Passphrase string `short:"p" long:"passphrase" default-mask:"-" description:"The wallet passphrase (default: \"insecurepassphrase\")"`
|
Passphrase string `short:"p" long:"passphrase" default-mask:"-" description:"The wallet passphrase (default: \"passphrase\")"`
|
||||||
|
|
||||||
// RPC client options
|
// RPC client options
|
||||||
RPCConnect string `short:"c" long:"rpcconnect" description:"Hostname/IP and port of lbcd RPC server to connect to (default localhost:9245, testnet: localhost:19245, regtest: localhost:29245)"`
|
RPCConnect string `short:"c" long:"rpcconnect" description:"Hostname/IP and port of lbcd RPC server to connect to (default localhost:9245, testnet: localhost:19245, regtest: localhost:29245)"`
|
||||||
|
|
|
@ -85,6 +85,11 @@ func walletMain() error {
|
||||||
|
|
||||||
loader.RunAfterLoad(func(w *wallet.Wallet) {
|
loader.RunAfterLoad(func(w *wallet.Wallet) {
|
||||||
startWalletRPCServices(w, legacyRPCServer)
|
startWalletRPCServices(w, legacyRPCServer)
|
||||||
|
log.Infof("Unlocking wallet with the default or specified passphrase...")
|
||||||
|
err = w.Unlock([]byte(cfg.Passphrase), nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Infof("Unable to unlock wallet: %v", err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
_, err = loader.OpenExistingWallet()
|
_, err = loader.OpenExistingWallet()
|
||||||
|
|
|
@ -46,12 +46,9 @@ func createWallet(cfg *config) error {
|
||||||
)
|
)
|
||||||
|
|
||||||
// Start by prompting for the passphrase.
|
// Start by prompting for the passphrase.
|
||||||
reader := bufio.NewReader(os.Stdin)
|
passphrase := []byte(cfg.Passphrase)
|
||||||
privPass, err := prompt.Passphrase(true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
|
reader := bufio.NewReader(os.Stdin)
|
||||||
// Ascertain the wallet generation seed. This will either be an
|
// Ascertain the wallet generation seed. This will either be an
|
||||||
// automatically generated value the user has already confirmed or a
|
// automatically generated value the user has already confirmed or a
|
||||||
// value the user has entered which has already been validated.
|
// value the user has entered which has already been validated.
|
||||||
|
@ -61,7 +58,7 @@ func createWallet(cfg *config) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Creating the wallet...")
|
fmt.Println("Creating the wallet...")
|
||||||
w, err := loader.CreateNewWallet(privPass, seed, bday)
|
w, err := loader.CreateNewWallet(passphrase, seed, bday)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue