When fuzzing the base58 functions I noticed that `DecodeBase58(const std::string& str, …)` is perhaps a bit too liberal in what input it accepts when decoding.

I naïvely assumed that `DecodeBase58(const std::string& str, …)` would return `false` when passing it a `str` which contains at least one character that is not any of the base58 characters (all alphanumeric characters except for "0", "I", "O", and "l") or the whitespace characters.

That is not the case:
* `str` contains `good` → `DecodeBase58(const std::string& str, …) == true` (as expected)
* `str` contains `bad0IOl` → `DecodeBase58(const std::string& str, …) == false` (as expected)
* `str` contains `good\x00bad0IOl` → `DecodeBase58(const std::string& str, …) == true`(!)

The reason is that `DecodeBase58(const std::string& str, …)` calls `DecodeBase58(const char* psz, …)` which will only consider the string up to the first `\x00`.
BOOST_CHECK(!DecodeBase58(std::string("bad0IOl", 7), result, 100));
    BOOST_CHECK(!DecodeBase58(std::string("goodbad0IOl", 11), result, 100));
    BOOST_CHECK(!DecodeBase58(std::string("good\0bad0IOl", 12), result, 100));
    
    BOOST_CHECK(!DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t a", result, 3));
    BOOST_CHECK( DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t ", result, 3));
    std::vector<unsigned char> expected = ParseHex("971a55");
    BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expected.end());
    BOOST_CHECK(DecodeBase58Check(std::string("3vQB7B6MrGQZaxCuFg4oh", 21), result, 100));
    BOOST_CHECK(!DecodeBase58Check(std::string("3vQB7B6MrGQZaxCuFg4oi", 21), result, 100));
    BOOST_CHECK(!DecodeBase58Check(std::string("3vQB7B6MrGQZaxCuFg4oh0IOl", 25), result, 100));
    BOOST_CHECK(!DecodeBase58Check(std::string("3vQB7B6MrGQZaxCuFg4oh\00IOl", 26), result, 100));
}
BOOST_AUTO_TEST_CASE(base58_random_encode_decode)
{
    for (int n = 0; n < 1000; ++n) {
        unsigned int len = 1 + InsecureRandBits(8);
        unsigned int zeroes = InsecureRandBool() ? InsecureRandRange(len + 1) : 0;
        auto data = Cat(std::vector<unsigned char>(zeroes, '\000'), g_insecure_rand_ctx.randbytes(len - zeroes));
        auto encoded = EncodeBase58Check(data);
        std::vector<unsigned char> decoded;
        auto ok_too_small = DecodeBase58Check(encoded, decoded, InsecureRandRange(len));
        BOOST_CHECK(!ok_too_small);
        auto ok = DecodeBase58Check(encoded, decoded, len + InsecureRandRange(257 - len));
        BOOST_CHECK(ok);
        BOOST_CHECK(data == decoded);
    }
}
BOOST_AUTO_TEST_SUITE_END()