From fc77f8b5b213ea400632686d68addd8fca64e58a Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 13 Aug 2020 12:01:18 +0300 Subject: [PATCH] consensus: exit if wrong password is provided in configuration --- pkg/consensus/consensus.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index 1909397e4..9d5638eca 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -133,6 +133,19 @@ func NewService(cfg Config) (Service, error) { return nil, err } + // Check that wallet password is correct for at least one account. + var ok bool + for _, acc := range srv.wallet.Accounts { + err := acc.Decrypt(srv.Config.Wallet.Password) + if err == nil { + ok = true + break + } + } + if !ok { + return nil, errors.New("no account with provided password was found") + } + defer srv.wallet.Close() srv.dbft = dbft.New(