Implement getwork RPC.

This commit adds full support for the getwork RPC which can be used to
support external mining through applications such as cgminer.

Closes #125.