copied non-ssl base58 functions from satoshi src + added unit tests.
tidied up base58 encoding.