From 92f4f4fbda4860b0090b0d64820da7d50bd13de4 Mon Sep 17 00:00:00 2001 From: johan Date: Tue, 14 Nov 2017 04:12:49 +0000 Subject: [PATCH] walletunlocker: check that password is at least 8 characters --- walletunlocker/service.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/walletunlocker/service.go b/walletunlocker/service.go index 8b639cbf..51aaf805 100644 --- a/walletunlocker/service.go +++ b/walletunlocker/service.go @@ -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 }