Removed duplicated lock

Around line 167 there is already a LOCK(bitdb.cs_db) that covers everything. Re-locking is useless.

Backported from bitcoin commit 028ec224b8acb9273e79c1c10c5278a102e3f305
Removed unused function EndMessageAbortIfEmpty
Added locks on the setpwalletRegistered functions in main.cpp and added an UnregisterAllWallets function.

Backported from bitcoin commit e5cefb9be12009114e2f86e8b9a421951c41f02d