import/export accounts

- cli: add passwordfile flag
- cli: change unlock flag only takes account
- cli: with unlock you are prompted for password or use passfile with password flag
- cli: unlockAccount used in normal client start (run) and accountExport
- cli: getPassword used in accountCreate and accountImport
- accounts: Manager.Import, Manager.Export
- crypto: SaveECDSA (to complement LoadECDSA) to save to file
- crypto: NewKeyFromECDSA added (used in accountImport and New = generated constructor)
This commit is contained in:
zelig
2015-03-23 13:00:06 +00:00
parent 658204bafc
commit c4ea921876
5 changed files with 190 additions and 39 deletions

View File

@ -139,6 +139,11 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
return ToECDSA(buf), nil
}
// SaveECDSA saves a secp256k1 private key from the given file.
func SaveECDSA(file string, key *ecdsa.PrivateKey) error {
return common.WriteFile(file, FromECDSA(key))
}
func GenerateKey() (*ecdsa.PrivateKey, error) {
return ecdsa.GenerateKey(S256(), rand.Reader)
}