Include IP address in RPC auth failure log message.
Rework and improve websocket notification system.

This commit refactors the entire websocket client code to resolve several
issues with the previous implementation.  Note that this commit does not
change the public API for websockets.  It only consists of internal
improvements.

The following is the major issues which have been addressed:
- A slow websocket client could impede notifications to all clients
- Long-running operations such as rescans would block all other requests
  until it had completed
- The above two points taken together could lead to apparant hangs since
  the client doing the rescan would eventually run out of channel buffer
  and block the entire group of clients until the rescan completed
- Disconnecting a websocket during certain operations could lead to a hang
- Stopping the rpc server with operations under way could lead to a hang
- There were no limits to the number of websocket clients that could
  connect

The following is a summary of the major changes:

- The websocket code has been split into two entities: a
  connection/notification manager and a websocket client
- The new connection/notification manager acts as the entry point from
  the rest of the subsystems to feed data which potentially needs to
  notify clients
- Each websocket client now has its own instance of the new websocket
  client type which controls its own lifecycle
- The data flow has been completely redesigned to closely resemble the
  peer data flow
- Each websocket now has its own long-lived goroutines for input, output,
  and queuing of notifications
- Notifications use the new notification queue goroutine along with
  queueing to ensure they dont't block on stalled or slow peers
- There is a new infrastructure for asynchronously executing long-running
  commands such as a rescan while still allowing the faster operations to
  continue to be serviced by the same client
- Since long-running operations now run asynchronously, they have been
  limited to one at a time
- Added a limit of 10 websocket clients.  This is hard coded for now, but
  will be made configurable in the future

Taken together these changes make the code far easier to reason about and
update as well solve the aforementioned issues.

Further optimizations to improve performance are possible in regards to
the way the connection/notification manager works, however this commit
already contains a ton of changes, so they are being left for another
time.
Add --rpcmaxwebsockets option with default of 25.

This commit adds a new configuration option, --rpcmaxwebsockets, to limit the
number of max RPC websocket clients that are served concurrently.
Remove tracking requests from websocket client too.

When a spent notification and address notification is removed, the
tracking entry in the client which is used to track what to remove on
shutdown needs to be removed as well.
Allow notifications to work for all address types.

Previously the websocket notifications for addresses were limited to
pay-to-pubkey-hash only.  This commit removes that restriction so
all btcutil.Address types are supported.  This includes pay-to-pubkey,
pay-to-pubkey-hash, and pay-to-script-hash.
Increase block prio size and max standard tx size.

This commit increases the block priority size to 50000 and the max
standard tx size to 100k.  This matches relatively recent changes in the
reference implementation.  The max block size was also increased to
750000, but since btcd does not currently create blocks, there is no
constant for it.  That constant will likely be added as a part of the
getwork implementation since it requires block creation.

Closes #71.
Rate limit free-to-relay transactions.

Closes #40

ok @davecgh
Make non-canoncial data pushes non-standard.

This commit makes use of the new btcscript.HasCanonicalPushes to enforce
canonical data pushes for transactions that are considered standard.

A canonical data push is one where the fewest number of bytes possible to
encode the size of the data being pushed is used.  This includes using the
small integer opcodes for single byte data that can be represented
directly.
Prepare for release 0.7.0.
Return errors for any sendrawtransaction rejection.

This changes the implementation of the sendrawtransaction RPC handler
to match bitcoind behavior by always returning a rejection error for
any error processing or accepting the tx by the mempool.  Previously,
if the tx was rejected for a rule error rather than an actual failure,
a client would still receive the tx sha as a result with no error.
Improve websocket transaction notifications.

This change improves the mechanism by which btcd notifies a websocket
client of transaction relating to watched address and unspent outputs
in the following ways:

1. The old processedtx notification has been replaced with the new
   recvtx notification.  This notification, rather than parsing out
   details used by wallet clients, sends the serialized transaction
   (as hexadecimal) and any block details (if mined) if any transaction
   output sends to one of the websocket client's watched addresses.

2. The old txspent notification has been replaced with the new
   redeemingtx notification.  This notification, rather than parsing
   out details used by wallet clients, sends the serialized transaction
   (as hexadecimal) and any block details (if mined) if any transaction
   input spends a watched output.

3. When processing notifications for transaction outputs, if any output
   spends to a client's watched address, a corresponding spent request
   is automatically registered.

4. Transaction notifications originating from mempool now include both
   transaction inputs and outputs, rather than only processing

5. When processing notifications for transaction inputs, a client's
   output spent request is only removed if the transaction being
   processed has also been mined into a block.  In combination with the
   4th change, this results in two redeemingtx notifications for
   transactions which first appear in mempool and are subsequently mined
   into a block.
Use mtx to control disconnect of websocket client.

This commit changes the websocket client code to use a mutex for
disconnect since it's theoretically possible a non-blocking select on the
quit channel could fall through from two different goroutines thus causing
a second call to close.

ok @jrick.
Update for recent btcutil Addr interface changes.
Update sample conf regarding debuglevel subsystems.

The debuglevel parameter has accepted subsystems in additional to an
overall level for quite some time, but the sample config file was not
updated to reflect that.

This commit updates the sample config file accordingly.
Add IP address to peer error messages.

Closes #102.
Fix typo on previous commit.

The peer and error were reversed for the regression test error message
case.

Spotted by @dajohi.
Add IP address to a few more peer error messages.

This commit adds the peer IP to a few more error messages as originally
noted by #102.
Alphabetize subsystem loggers.

This commit simply alphabetizes the subsystem logger variables, map, and
use switch so the order in the code is consistent with the sorted output
displayed when using --debuglevel.
recieve -> receive
Lower min transaction relay fee to 1000 satoshi.

This mirrors a recent change in the reference implementation.  Since the
vast majority of the network still uses it and transactions which aren't
considered standard won't be relayed, the rules for standard transactions
need to be kept consistent.

Ideally this should be handled via floating fees, but we're rather limited
until we have miner support and a larger network share so the probability
of a transaction being relayed and confirmed is high.

Closes #100.

ok @owainga