Outputs database fixes

Changed scriptPubKey_has from KEY to INDEX, because it is not unique.

Added some error checking and handling.

Fixed a couple SQL query syntax problems.
More error handling

Running into EADDRNOTAVAIL issues with RPC due to so many queries. More
handling will probably be needed.