Merge review comments/changes
This commit is contained in:
parent
6c623b203e
commit
add15b5b28
|
@ -77,21 +77,26 @@ func ReadPassphraseFromStdin(name string) (string, error) {
|
|||
|
||||
// TODO make keybase take a database not load from the directory
|
||||
|
||||
// initialize a keybase based on the configuration
|
||||
// GetKeyBase initializes a keybase based on the configuration.
|
||||
func GetKeyBase() (keys.Keybase, error) {
|
||||
rootDir := viper.GetString(cli.HomeFlag)
|
||||
return getKeyBaseFromDirWithOpts(rootDir, &opt.Options{ReadOnly: true})
|
||||
return GetKeyBaseFromDir(rootDir)
|
||||
}
|
||||
|
||||
// initialize a keybase based on the configuration with write permission
|
||||
// GetKeyBaseWithWritePerm initialize a keybase based on the configuration with write permissions.
|
||||
func GetKeyBaseWithWritePerm() (keys.Keybase, error) {
|
||||
rootDir := viper.GetString(cli.HomeFlag)
|
||||
return GetKeyBaseFromDirWithWritePerm(rootDir)
|
||||
}
|
||||
|
||||
// initialize a keybase at particular dir with write permission
|
||||
// GetKeyBaseFromDirWithWritePerm initializes a keybase at a particular dir with write permissions.
|
||||
func GetKeyBaseFromDirWithWritePerm(rootDir string) (keys.Keybase, error) {
|
||||
return getKeyBaseFromDirWithOpts(rootDir, &opt.Options{ReadOnly: false})
|
||||
return getKeyBaseFromDirWithOpts(rootDir, nil)
|
||||
}
|
||||
|
||||
// GetKeyBaseFromDir initializes a read-only keybase at a particular dir.
|
||||
func GetKeyBaseFromDir(rootDir string) (keys.Keybase, error) {
|
||||
return getKeyBaseFromDirWithOpts(rootDir, &opt.Options{ReadOnly: true})
|
||||
}
|
||||
|
||||
func getKeyBaseFromDirWithOpts(rootDir string, o *opt.Options) (keys.Keybase, error) {
|
||||
|
|
|
@ -426,6 +426,11 @@ func (kb dbKeybase) Update(name, oldpass string, getNewpass func() (string, erro
|
|||
}
|
||||
}
|
||||
|
||||
// CloseDB releases the lock and closes the storage backend.
|
||||
func (kb dbKeybase) CloseDB() {
|
||||
kb.db.Close()
|
||||
}
|
||||
|
||||
func (kb dbKeybase) writeLocalKey(priv tmcrypto.PrivKey, name, passphrase string) Info {
|
||||
// encrypt private key using passphrase
|
||||
privArmor := mintkey.EncryptArmorPrivKey(priv, passphrase)
|
||||
|
|
|
@ -47,6 +47,9 @@ type Keybase interface {
|
|||
|
||||
// *only* works on locally-stored keys. Temporary method until we redo the exporting API
|
||||
ExportPrivateKeyObject(name string, passphrase string) (crypto.PrivKey, error)
|
||||
|
||||
// Close closes the database.
|
||||
CloseDB()
|
||||
}
|
||||
|
||||
// KeyType reflects a human-readable type for key listing.
|
||||
|
|
Loading…
Reference in New Issue