walletunlocker: check that password is at least 8 characters

This commit is contained in:
johan 2017-11-14 04:12:49 +00:00 committed by Johan T. Halseth
parent b98e993d76
commit 92f4f4fbda
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

View File

@ -45,6 +45,14 @@ func New(authSvc *bakery.Service, chainDir string,
func (u *UnlockerService) CreateWallet(ctx context.Context,
in *lnrpc.CreateWalletRequest) (*lnrpc.CreateWalletResponse, error) {
// Require the provided password to have a length of at
// least 8 characters.
password := in.Password
if len(password) < 8 {
return nil, fmt.Errorf("password must have " +
"at least 8 characters")
}
netDir := btcwallet.NetworkDir(u.chainDir, u.netParams)
loader := wallet.NewLoader(u.netParams, netDir)
@ -61,7 +69,7 @@ func (u *UnlockerService) CreateWallet(ctx context.Context,
// We send the password over the CreatePasswords channel, such that it
// can be used by lnd to open or create the wallet.
u.CreatePasswords <- in.Password
u.CreatePasswords <- password
return &lnrpc.CreateWalletResponse{}, nil
}