wallet: Add missing cs_db lock
wallet: Add missing cs_db lock

Without this lock BerkeleyEnvironment::~BerkeleyEnvironment and
GetWalletEnv would race for g_dbenvs. This wasn't detected before
because thread safety analysis does not check constructors and
destructors.

bitcoin/bitcoin,namecoin/namecore,jlopp/statoshi,AkioNak/bitcoin,apoelstra/bitcoin,jtimon/bitcoin,Sjors/bitcoin,practicalswift/bitcoin,pataquets/namecoin-core,r8921039/bitcoin,EthanHeilman/bitcoin,r8921039/bitcoin,apoelstra/bitcoin,domob1812/namecore,pataquets/namecoin-core,JeremyRubin/bitcoin,jtimon/bitcoin,domob1812/bitcoin,bitcoinsSG/bitcoin,FeatherCoin/Feathercoin,myriadcoin/myriadcoin,ajtowns/bitcoin,Sjors/bitcoin,Sjors/bitcoin,andreaskern/bitcoin,AkioNak/bitcoin,namecoin/namecoin-core,practicalswift/bitcoin,myriadteam/myriadcoin,jamesob/bitcoin,cdecker/bitcoin,bespike/litecoin,domob1812/bitcoin,Sjors/bitcoin,tjps/bitcoin,midnightmagic/bitcoin,anditto/bitcoin,prusnak/bitcoin,prusnak/bitcoin,wellenreiter01/Feathercoin,practicalswift/bitcoin,mm-s/bitcoin,DigitalPandacoin/pandacoin,fanquake/bitcoin,JeremyRubin/bitcoin,jlopp/statoshi,practicalswift/bitcoin,yenliangl/bitcoin,dscotese/bitcoin,sstone/bitcoin,jambolo/bitcoin,nikkitan/bitcoin,namecoin/namecoin-core,qtumproject/qtum,pstratem/bitcoin,afk11/bitcoin,instagibbs/bitcoin,bitcoin/bitcoin,ahmedbodi/vertcoin,CryptArc/bitcoin,FeatherCoin/Feathercoin,droark/bitcoin,domob1812/bitcoin,apoelstra/bitcoin,OmniLayer/omnicore,litecoin-project/litecoin,anditto/bitcoin,monacoinproject/monacoin,Xekyo/bitcoin,andreaskern/bitcoin,kallewoof/bitcoin,jonasschnelli/bitcoin,EthanHeilman/bitcoin,midnightmagic/bitcoin,qtumproject/qtum,rnicoll/dogecoin,dscotese/bitcoin,ajtowns/bitcoin,fujicoin/fujicoin,particl/particl-core,mitchellcash/bitcoin,kallewoof/bitcoin,mm-s/bitcoin,GroestlCoin/GroestlCoin,andreaskern/bitcoin,jonasschnelli/bitcoin,peercoin/peercoin,rnicoll/dogecoin,mruddy/bitcoin,afk11/bitcoin,fanquake/bitcoin,instagibbs/bitcoin,rnicoll/dogecoin,myriadcoin/myriadcoin,droark/bitcoin,dscotese/bitcoin,instagibbs/bitcoin,namecoin/namecore,GroestlCoin/bitcoin,yenliangl/bitcoin,pstratem/bitcoin,jambolo/bitcoin,n1bor/bitcoin,midnightmagic/bitcoin,CryptArc/bitcoin,r8921039/bitcoin,peercoin/peercoin,GroestlCoin/bitcoin,qtumproject/qtum,peercoin/peercoin,mitchellcash/bitcoin,domob1812/namecore,jtimon/bitcoin,fujicoin/fujicoin,untrustbank/litecoin,yenliangl/bitcoin,namecoin/namecore,nikkitan/bitcoin,MarcoFalke/bitcoin,MarcoFalke/bitcoin,midnightmagic/bitcoin,kallewoof/bitcoin,pataquets/namecoin-core,bitcoin/bitcoin,domob1812/namecore,bespike/litecoin,lateminer/bitcoin,namecoin/namecore,achow101/bitcoin,Xekyo/bitcoin,domob1812/namecore,rnicoll/bitcoin,sstone/bitcoin,domob1812/namecore,cdecker/bitcoin,OmniLayer/omnicore,MeshCollider/bitcoin,achow101/bitcoin,Xekyo/bitcoin,gjhiggins/vcoincore,OmniLayer/omnicore,EthanHeilman/bitcoin,wellenreiter01/Feathercoin,lateminer/bitcoin,litecoin-project/litecoin,rnicoll/bitcoin,GroestlCoin/GroestlCoin,dscotese/bitcoin,alecalve/bitcoin,droark/bitcoin,ElementsProject/elements,JeremyRubin/bitcoin,nikkitan/bitcoin,MeshCollider/bitcoin,myriadteam/myriadcoin,jambolo/bitcoin,bitcoinknots/bitcoin,ahmedbodi/vertcoin,jamesob/bitcoin,monacoinproject/monacoin,sstone/bitcoin,qtumproject/qtum,AkioNak/bitcoin,gjhiggins/vcoincore,wellenreiter01/Feathercoin,GroestlCoin/GroestlCoin,namecoin/namecoin-core,cdecker/bitcoin,anditto/bitcoin,bitcoinsSG/bitcoin,nikkitan/bitcoin,jonasschnelli/bitcoin,kallewoof/bitcoin,particl/particl-core,qtumproject/qtum,tjps/bitcoin,tecnovert/particl-core,vertcoin/vertcoin,CryptArc/bitcoin,fujicoin/fujicoin,droark/bitcoin,namecoin/namecore,andreaskern/bitcoin,fanquake/bitcoin,jonasschnelli/bitcoin,litecoin-project/litecoin,n1bor/bitcoin,mruddy/bitcoin,jnewbery/bitcoin,domob1812/bitcoin,particl/particl-core,mruddy/bitcoin,vertcoin/vertcoin,kallewoof/bitcoin,cdecker/bitcoin,rnicoll/dogecoin,untrustbank/litecoin,monacoinproject/monacoin,wellenreiter01/Feathercoin,monacoinproject/monacoin,tjps/bitcoin,ElementsProject/elements,tecnovert/particl-core,instagibbs/bitcoin,jtimon/bitcoin,myriadcoin/myriadcoin,yenliangl/bitcoin,myriadteam/myriadcoin,MeshCollider/bitcoin,mitchellcash/bitcoin,sipsorcery/bitcoin,tecnovert/particl-core,apoelstra/bitcoin,peercoin/peercoin,ahmedbodi/vertcoin,myriadteam/myriadcoin,jonasschnelli/bitcoin,fanquake/bitcoin,tjps/bitcoin,alecalve/bitcoin,instagibbs/bitcoin,tjps/bitcoin,EthanHeilman/bitcoin,sipsorcery/bitcoin,sstone/bitcoin,MarcoFalke/bitcoin,MarcoFalke/bitcoin,tecnovert/particl-core,bespike/litecoin,r8921039/bitcoin,sipsorcery/bitcoin,anditto/bitcoin,midnightmagic/bitcoin,MeshCollider/bitcoin,MarcoFalke/bitcoin,untrustbank/litecoin,bitcoinknots/bitcoin,bitcoin/bitcoin,qtumproject/qtum,bitcoinsSG/bitcoin,gjhiggins/vcoincore,CryptArc/bitcoin,litecoin-project/litecoin,jnewbery/bitcoin,prusnak/bitcoin,droark/bitcoin,MeshCollider/bitcoin,bitcoinknots/bitcoin,droark/bitcoin,EthanHeilman/bitcoin,r8921039/bitcoin,GroestlCoin/bitcoin,lateminer/bitcoin,FeatherCoin/Feathercoin,jlopp/statoshi,nikkitan/bitcoin,fujicoin/fujicoin,namecoin/namecoin-core,n1bor/bitcoin,fujicoin/fujicoin,rnicoll/bitcoin,namecoin/namecoin-core,cdecker/bitcoin,achow101/bitcoin,rnicoll/bitcoin,litecoin-project/litecoin,andreaskern/bitcoin,tecnovert/particl-core,nikkitan/bitcoin,fanquake/bitcoin,bitcoinsSG/bitcoin,bespike/litecoin,achow101/bitcoin,pataquets/namecoin-core,bitcoinknots/bitcoin,pataquets/namecoin-core,AkioNak/bitcoin,mitchellcash/bitcoin,afk11/bitcoin,lateminer/bitcoin,vertcoin/vertcoin,jambolo/bitcoin,kallewoof/bitcoin,rnicoll/bitcoin,AkioNak/bitcoin,myriadcoin/myriadcoin,gjhiggins/vcoincore,vertcoin/vertcoin,rnicoll/dogecoin,r8921039/bitcoin,tecnovert/particl-core,gjhiggins/vcoincore,GroestlCoin/GroestlCoin,bespike/litecoin,particl/particl-core,apoelstra/bitcoin,jnewbery/bitcoin,mruddy/bitcoin,monacoinproject/monacoin,instagibbs/bitcoin,GroestlCoin/GroestlCoin,ElementsProject/elements,n1bor/bitcoin,peercoin/peercoin,domob1812/bitcoin,fanquake/bitcoin,bitcoinsSG/bitcoin,bitcoinknots/bitcoin,JeremyRubin/bitcoin,Xekyo/bitcoin,jnewbery/bitcoin,peercoin/peercoin,rnicoll/bitcoin,wellenreiter01/Feathercoin,ElementsProject/elements,ElementsProject/elements,domob1812/bitcoin,bitcoinsSG/bitcoin,ajtowns/bitcoin,yenliangl/bitcoin,FeatherCoin/Feathercoin,yenliangl/bitcoin,n1bor/bitcoin,prusnak/bitcoin,GroestlCoin/GroestlCoin,vertcoin/vertcoin,OmniLayer/omnicore,ajtowns/bitcoin,tjps/bitcoin,ahmedbodi/vertcoin,namecoin/namecore,ahmedbodi/vertcoin,anditto/bitcoin,alecalve/bitcoin,jambolo/bitcoin,bitcoin/bitcoin,vertcoin/vertcoin,anditto/bitcoin,domob1812/namecore,alecalve/bitcoin,achow101/bitcoin,jlopp/statoshi,mitchellcash/bitcoin,particl/particl-core,DigitalPandacoin/pandacoin,qtumproject/qtum,dscotese/bitcoin,ajtowns/bitcoin,AkioNak/bitcoin,myriadcoin/myriadcoin,practicalswift/bitcoin,GroestlCoin/bitcoin,gjhiggins/vcoincore,pstratem/bitcoin,prusnak/bitcoin,untrustbank/litecoin,n1bor/bitcoin,DigitalPandacoin/pandacoin,mruddy/bitcoin,apoelstra/bitcoin,OmniLayer/omnicore,sstone/bitcoin,EthanHeilman/bitcoin,bespike/litecoin,afk11/bitcoin,jnewbery/bitcoin,cdecker/bitcoin,mm-s/bitcoin,jamesob/bitcoin,Xekyo/bitcoin,OmniLayer/omnicore,jlopp/statoshi,ElementsProject/elements,myriadcoin/myriadcoin,MarcoFalke/bitcoin,sstone/bitcoin,GroestlCoin/bitcoin,jamesob/bitcoin,pstratem/bitcoin,untrustbank/litecoin,mm-s/bitcoin,pataquets/namecoin-core,bitcoin/bitcoin,monacoinproject/monacoin,jtimon/bitcoin,practicalswift/bitcoin,GroestlCoin/bitcoin,myriadteam/myriadcoin,CryptArc/bitcoin,sipsorcery/bitcoin,pstratem/bitcoin,afk11/bitcoin,sipsorcery/bitcoin,FeatherCoin/Feathercoin,andreaskern/bitcoin,mitchellcash/bitcoin,achow101/bitcoin,JeremyRubin/bitcoin,Sjors/bitcoin,jamesob/bitcoin,wellenreiter01/Feathercoin,mruddy/bitcoin,jambolo/bitcoin,ajtowns/bitcoin,DigitalPandacoin/pandacoin,ahmedbodi/vertcoin,namecoin/namecoin-core,prusnak/bitcoin,particl/particl-core,lateminer/bitcoin,midnightmagic/bitcoin,DigitalPandacoin/pandacoin,jtimon/bitcoin,dscotese/bitcoin,CryptArc/bitcoin,untrustbank/litecoin,JeremyRubin/bitcoin,alecalve/bitcoin,jamesob/bitcoin,pstratem/bitcoin,sipsorcery/bitcoin,litecoin-project/litecoin,MeshCollider/bitcoin,mm-s/bitcoin,mm-s/bitcoin,fujicoin/fujicoin,alecalve/bitcoin,FeatherCoin/Feathercoin,afk11/bitcoin,Xekyo/bitcoin,myriadteam/myriadcoin,jlopp/statoshi,DigitalPandacoin/pandacoin,lateminer/bitcoin