Persistent db object
Shamelessly copy RPC code from Bitcoin. Fix openssl linking.